mcpField
S
shellcode-loader-generate

shellcode-loader-generate

github.com/wgpsecSecurity1.8k48 installsUpdated 4d ago
Repository

About shellcode-loader-generate

A skill for generating shellcode loaders in C, C++, or Rust by combining storage, allocation, copying, and execution components. It requires checking component and scenario references and validating generated code with a cross-compiler.

Key features

  1. 01Compose loaders from four component types
  2. 02Consult component and existing-scenario references
  3. 03Support C, C++, and Rust
  4. 04Validate code with cross-compilation
  5. 05Record new scenarios in the scenario database

Use cases

  1. 01Generate a loader from selected components
  2. 02Check for duplicate scenarios
  3. 03Build a loader for a Windows target
  4. 04Compile-check generated code

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/wgpsec/aboutsecurity --skill shellcode-loader-generate

After installing, type/shellcode-loader-generatein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

evals/
evals.json
recall.json
references/
loader-architecture.md
loader-components-db.json
loader-scenarios.json

Details

From the project README

Shellcode Loader 组合生成

⛔ 深入参考


4 组件选择矩阵

Loader = Storage × Allocator × Copier × Executor
Storage(存储方式)— 15 种

内部嵌入 | 资源段 | 远程URL | 注册表 | ADS | ...

Allocator(内存分配)— 14 种
方法复杂度代码模式
VirtualAllocsimpleVirtualAlloc(NULL, size, MEM_COMMIT|MEM_RESERVE, PAGE_RWX)
HeapCreatemediumHeapCreate(HEAP_CREATE_ENABLE_EXECUTE, 0, 0)
NtAllocateVirtualMemorycomplex直接 NT syscall
Copier(数据复制)— 9 种

memcpy | RtlMoveMemory | 循环字节复制 | WriteProcessMemory | ...

Executor(执行方式)— 47 种
方法复杂度
函数指针simple
CreateThreadsimple
EnumWindows 回调medium
APC 注入medium
Fibercomplex
NtCreateThreadExcomplex

生成流程

1. 查组件库 → references/loader-components-db.json
2. 查已有场景 → references/loader-scenarios.json(避免重复)
3. 选择 4 组件组合
4. 选择语言(C/C++/Rust)
5. 生成代码(使用 references/loader-architecture.md 中的模板)
6. 交叉编译验证(mingw-gcc / cargo)
7. 记录场景到知识库

编译命令速查

# C
x86_64-w64-mingw32-gcc -o loader.exe loader.c

# C++
x86_64-w64-mingw32-g++ -o loader.exe loader.cpp

# Rust
cargo build --release --target x86_64-pc-windows-gnu

Rust Loader 注意事项

  • Rust 错误处理:使用 Result / Option 类型,避免 unwrap panic

⛔ Agent 行为规则

⛔ NEVER
  • NEVER 生成前不查 references/loader-scenarios.json — 避免重复已有场景
  • NEVER 使用 PAGE_EXECUTE_READWRITE 以外的权限分配可执行内存时不注释说明
  • NEVER 硬编码 shellcode 在源码中 — 必须使用 storage 组件加载
  • NEVER 生成代码后不交叉编译验证 — 编译通过才算完成
  • NEVER 在 Loader 代码中包含明文字符串(如 "shellcode", "payload")
✅ ALWAYS
  • 先读取组件库 references/loader-components-db.json 再选组件
  • ALWAYS 4 组件都必须明确选择(storage + allocator + copier + executor)
  • ALWAYS 使用 mingw 或对应交叉编译工具链验证编译
  • ALWAYS 新场景记录到 loader-scenarios.json
  • ALWAYS 代码中添加错误检查(分配失败、句柄无效)
🔧 工具偏好
  1. 读取 references/... — 查组件库和场景
  2. bash — 交叉编译验证
  3. 直接创建文件 — 生成 Loader 源码

Comments

Markdown supported