用于非托管二进制文件的 C# 反射加载器。
Usage: RunPE.exe <file-to-run> <args-to-file-to-run>
e.g. RunPE.exe C:\Windows\System32\net.exe localgroup administrators
Alternative usage: RunPE.exe ---f <file-to-pretend-to-be> ---b <base64 blob of file bytes> ---a <base64 blob of args>
e.g: RunPE.exe ---f C:\Windows\System32\svchost.exe ---b <net.exe, base64 encoded> ---a <localgroup administrators, base64 encoded>
编辑编译符号以快速调整程序流程: (在 Visual Studio 中右键单击项目 -> 属性 -> 生成 -> 条件编译符号)
由 RunPE 启动的可执行文件必须静态链接,StdOut 和 StdErr 重定向才能正常工作。要在 Visual Studio 中更改此设置:
Configuration Properties -> C/C++ -> Code GenerationRuntime Library 的值更改为 Multi-threaded (/MT) 或 Multi-threaded Debug (/MTd)不使用 Windows API CommandLineToArgvW 来解析参数的可执行文件将无法通过 RunPE 正确传递参数。当操作者可以控制 PE 的编译时,建议添加使用此 API 解析参数的支持。
例如,以下代码在程序独立运行时可以正常工作,但传递给 RunPE 时会失败,因为 "foo" 被移位到了 argv[2]:
if (argv[1] == "foo") {
bar();
}
将 argv 重构为 CommandLineArgvW 的示例:
#include <stdio.h>
#include <Windows.h>
int main(int argc, char* argv[]) {
int nArgs;
LPWSTR *szArglist;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
for (int i = 0; i < nArgs; i++) {
printf("argv[%d]: %ws\n", i, szArglist[i]);
}
return 0;
}