一个轻量级的测试工具,旨在通过提供集成崩溃诊断和调试输出重定向的执行环境,加速 shellcode 的开发。
g++ -o loader.exe loader.cc -ladvapi32 -luser32 -lkernel32 -static
# 使用默认宿主 DLL 执行 payload
loader.exe --bin payload.bin
# 通过踩踏特定 DLL 执行 payload
loader.exe --bin payload.bin --dll mscoree.dll
# 扫描所有兼容的 DLL
loader.exe --scan
# 扫描具有足够大 .text 节以容纳特定 payload 的 DLL
loader.exe --scan --bin payload.bin
#if defined(DEBUG)
#define PDEBUG(format, ...) \
{ \
ntdll.DbgPrint(symbol<PCH>("%-48s " format), symbol<PCH>(({ \
char __buf[48]; \
memory::snprintf(__buf, sizeof(__buf), "[%s:%d]", \
__FUNCTION__, __LINE__); \
__buf; \
})), \
##__VA_ARGS__); \
}
#define PDEBUG_CTX(ctx, format, ...) \
{ \
if ((ctx) && (ctx)->ntdll.DbgPrint) { \
(ctx)->ntdll.DbgPrint(symbol<PCH>("%-48s " format), symbol<PCH>(({ \
char __buf[48]; \
memory::snprintf(__buf, sizeof(__buf), "[%s:%d]",\
__FUNCTION__, __LINE__); \
__buf; \
})), \
##__VA_ARGS__); \
} \
}
#else
#define PDEBUG(format, ...) \
{ \
; \
}
#define PDEBUG_CTX(ctx, format, ...) \
{ \
; \
}
#endif
PSYSCALL_TABLE pTable = NULL;
SIZE_T regionSize = sizeof(SYSCALL_TABLE);
ntdll.NtAllocateVirtualMemory(
(HANDLE)-1,
(PVOID*)&pTable,
0,
®ionSize,
MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE
);
if (pTable) {
pTable->NtTerminateProcess = 0x2c; // 示例系统调用号
PDEBUG("HEXDUMP:%p:%zu", pTable, sizeof(SYSCALL_TABLE));
}
