Communitygithub.com

dotnet-reverse

.NET / C# 二进制逆向。当目标是 .NET assembly(PE 头含 CLR、.exe/.dll 托管程序)、C# 编译产物(含 NativeAOT)、红队 Sharp* 工具(Rubeus / SharpHound / SharpHound 等)、.NET 混淆程序(ConfuserEx / SmartAssembly / Babel / Eazfuscator)、.NET loader / info-stealer / 套壳 malware 时使用。优先用 dnSpyEx + de4dot,需要 AI 直接操作时联动 dnSpy MCP。不用于纯 native 二进制(走 reverse-engineering / ida-reverse)。

dotnet-reverse 是什么?

dotnet-reverse is a Claude Code agent skill that .NET / C# 二进制逆向。当目标是 .NET assembly(PE 头含 CLR、.exe/.dll 托管程序)、C# 编译产物(含 NativeAOT)、红队 Sharp* 工具(Rubeus / SharpHound / SharpHound 等)、.NET 混淆程序(ConfuserEx / SmartAssembly / Babel / Eazfuscator)、.NET loader / info-stealer / 套壳 malware 时使用。优先用 dnSpyEx + de4dot,需要 AI 直接操作时联动 dnSpy MCP。不用于纯 native 二进制(走 reverse-engineering / ida-reverse)。.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/zhaoxuya520/reverse-skill/tree/main/skills/dotnet-reverse

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

.NET / C# Reverse Engineering Workflow Specification

ACTION REQUIRED (Execute Immediately After Reading)

  1. NOW: Use DIE/file/CLR header to confirm the target is a .NET managed binary (otherwise SWITCH to ida-reverse/ / reverse-engineering/)
  2. NOW: If suspected of obfuscation → run de4dot first to unpack, produce *-clean.exe, and keep the original sample
  3. NEXT: dnSpyEx (or dnSpy MCP / ilspycmd) static: C# browse + IL view for key logic
  4. ACT: Dynamic debug when plaintext/C2 is needed; IL patch is preferred over C# recompilation when logic modification is required
  5. At the end, provide the user with a 3-6 item next-steps menu (including export report)

Scope

Use this skill when the task falls under one of the following scenarios:

  • Identify and reverse engineer .NET / C# compiled output (managed PE / .exe / .dll)
  • Analyze red team Sharp* toolchains (Rubeus, SharpHound, SharpShell, etc.)
  • Deobfuscate ConfuserEx / SmartAssembly / Babel / Eazfuscator / .NET Reactor and other protectors
  • Reverse engineer .NET loaders / info-stealers / RAT decryption and C2 logic
  • Patch C# programs (change conditions, constants, keygen)
  • Analyze the managed Mono/Unity layer before IL2CPP (note: after IL2CPP compilation it is native, go to reverse-engineering/ + seed-014)

If the target is a pure native binary (C/C++/Go/Rust compiled, no CLR), use reverse-engineering/, ida-reverse/, or radare2/ instead.

Core Principles

  • Identify first, then act: First confirm the binary is a .NET managed program (PE header CLR + #~ / #Strings streams + mscoree _CorExeMain), then decide to use dnSpy instead of IDA
  • IL over C#: dnSpyEx's C# decompiler can lose/distort information (compiler-generated state machines, async/await, yield). Key logic and patches must be examined in the IL Editor; C# view is for quick browsing only
  • de4dot first: When encountering an obfuscator, run de4dot first before static analysis, otherwise strings and control flow will be mangled
  • MCP integration: If the environment has registered dnSpy MCP (dnspy_* tools), prefer those tools for decompile / IL inspection to avoid switching back to the GUI
  • Evidence-based output: Save deobfuscated results, extracted config/C2/key, and patch diffs to disk

Toolchain Mapping

CapabilityPrimary ToolNotes
Decompilation + Debugging + PatchdnSpyExThe go-to tool, the only one with an IL editor GUI; legacy dnSpy is no longer maintained, use the Ex fork
Lightweight CLI / headless decompilationILSpy (ilspycmd)Suitable for batch processing, scripting, Linux/macOS
Deobfuscationde4dotDefault unpacker for ConfuserEx family, SmartAssembly, and other mainstream protectors
Obfuscator DetectionDetect It Easy (DIE) / fileIdentify the protector type first, then choose de4dot parameters
Programmatic IL manipulationdnlibWrite C# scripts to batch modify metadata / string decryptors
AI Direct OperationdnSpy MCPTools like dnspy_decompile / dnspy_inspect_il for automated analysis

Prerequisites: Windows host with dnSpyEx + de4dot installed (via choco or release); Linux/macOS use ilspycmd + dotnet runtime. See references/sharp-tools.md for the installation matrix.

Six-Phase Workflow

1. Identify (.NET)

Confirm the target is a managed program. Do not analyze a native PE as .NET:

# Windows
file target.exe                       # "PE32 executable ... for MS Windows" is insufficient
# Key: check for CLR
powershell -c "[System.Reflection.AssemblyName]::GetAssemblyName('target.exe')"
# Or
drop target.exe into dnSpyEx — if it opens, it's managed

# Universal
strings target.exe | grep -iE "mscoree|_CorExeMain|mscorlib|System\\."

.NET Identification Signs:

  • PE header Data Directory[14] (CLR Runtime Header) is non-zero
  • mscoree.dll import / _CorExeMain entry point
  • #~, #Strings, #US, #GUID, #Blob metadata streams
  • mscorlib / System.Private.CoreLib strings

NativeAOT Exception: Compiled to native, no CLR header, but contains System.Private.CoreLib strings and restructured type metadata — use reverse-engineering/ (IDA/r2) for these; this skill only provides identification hints.

2. Detect (Obfuscator Detection)

# DIE quick detection
diec target.exe                        # Detect It Easy CLI
# Or drop into dnSpyEx and look for large amounts of garbled class names / control flow obfuscation

Common obfuscators → unpacking strategy (see references/obfuscators.md):

ObfuscatorCharacteristicsde4dot Handling
ConfuserEx (1.0.0 / 2.x)<module> anti-tamper, control flow obfuscation, string encryptionde4dot target.exe usually auto-detects
SmartAssemblycircular/string encoding, resource compressionde4dot target.exe
Babel.NETMethod body encryption, control flowde4dot target.exe
Eazfuscator.NETString/resource encryptionde4dot, some versions may need manual handling
.NET Reactoranti-tamper + necrobitde4dot, newer versions may fail and require manual steps

3. Deobfuscate (Deobfuscation)

# de4dot automatically detects most protectors by default
de4dot target.exe -o target-clean.exe

# Specify type (when auto-detect fails)
de4dot --type cfze target.exe          # ConfuserEx
de4dot --type sa target.exe            # SmartAssembly

# Multi-layer obfuscation / de4dot reports unknown
de4dot --detect target.exe             # See what it identifies
# May need to patch anti-tamper first, then de4dot (see references/obfuscators.md)

Output: target-clean.exe. Use it for subsequent analysis. Keep the original sample for comparison.

4. Static Analyze (Static Analysis)

Load the deobfuscated sample in dnSpyEx:

  • C# view: Quickly browse class structure, method signatures, strings (for locating)
  • IL view: Key decisions, encryption logic, state machines must be viewed in IL (right-click → Edit IL or IL view)
  • Find entry points: Main / Startup / Module initializer (Module .cctor)
  • Find key logic: search for flag, password, verify, check, encrypt, http, Config
Locate string → cross-reference → find the method that uses it → IL view to see the decision logic

5. Dynamic (Dynamic Debugging)

dnSpyEx debugger: Attach to process / start debugging, set breakpoints in key methods, observe runtime:

  • Decrypted plaintext strings (many obfuscators decrypt strings only at runtime)
  • C2 addresses, configuration decryption results
  • Exception-driven control flow (commonly used by anti-debug to hide the real path using try/catch)

.NET dynamic debugging is much friendlier than native — you can directly see object values and string contents. Prioritize dynamic over static analysis.

6. Patch (Modify as Needed)

dnSpyEx → right-click method → Edit Method (C#) or Edit IL
  - Change condition: ldc.i4.0 → ldc.i4.1 (false→true)
  - Change constant: directly edit string/number
  - Remove check: NOP the entire block
File → Save Module → Replace original file

IL patch reliability > C# patch: C# recompilation may fail (missing references, syntax issues); IL editing almost never introduces distortion. See references/common-workflow.md for details.

Trigger Scenario Routing

Enter this skill when the user says:

  • ".NET / C# binary reverse engineering" / "C# program decompilation"
  • "dnSpy analysis" / "dnSpyEx patch"
  • "ConfuserEx / SmartAssembly / Babel deobfuscation / unpacking"
  • "Sharp* tool analysis" (Rubeus / SharpHound / SharpShell)
  • ".NET malware / loader / info-stealer reverse engineering"
  • "C# program patch / keygen / condition modification"

When to Switch Out

  • IL2CPP-compiled Unity games → reverse-engineering/ + seed-014_unity-il2cpp-reverse.md (IL2CPP is native, do not use dnSpy)
  • NativeAOT output → reverse-engineering/ (same, native)
  • Pure native PE (no CLR) → reverse-engineering/ / ida-reverse/
  • Need symbol/function bulk migration to another version → binary-diff/
  • Need to draw attack path / call chain diagram → diagram-generator/

Routing Context

Upstream entry: skills/SKILL.md (master), routing.md Downstream exits:

  • IL2CPP / NativeAOT (native) → reverse-engineering/
  • Deep native .so/.dll segment analysis → ida-reverse/ / radare2/
  • Need AI to directly operate dnSpy → register and integrate with dnSpy MCP (see references/sharp-tools.md)

Sibling related modules:

  • reverse-engineering/languages-compiled.md (.NET overview references this module)
  • apk-reverse/ (Xamarin/MAUI Android reverse engineering can switch back to this module for C# layer)

Reference Documents

  • references/obfuscators.md — Detailed deobfuscation guide for ConfuserEx / SmartAssembly / Babel / Eazfuscator / .NET Reactor, including anti-tamper bypass
  • references/common-workflow.md — Complete workflow, IL patch reliability, string decryptor extraction, state machine identification
  • references/sharp-tools.md — Red team Sharp* tool analysis, tool installation matrix, dnSpy MCP integration, community resource index

Task Completion Checklist

  • Have you confirmed the CLR / managed identity (or already SWITCHED out of this skill)?
  • Did you run de4dot / equivalent deobfuscation on the obfuscated sample before deep analysis?
  • Have you verified key logic using the IL view (not just C# pseudo-code)?
  • Are the outputs (clean sample / config / patch diff) saved to disk and reproducible?
  • Did you provide a next-steps menu or report export?

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

api-security

Use for authorized security assessment of REST, GraphQL, WebSocket, or SOAP APIs, including discovery, authentication, authorization, rate-limit, and CI/CD testing.

apk-reverse

在 CLI 环境下做 Android APK 逆向时使用。适用于 APK 解包、Java 反编译、smali 修改、重打包、Frida 动态 Hook,以及按需切换到 so/native 分析。优先使用本机已安装的 jadx、apktool、frida、adb、ida-reverse、radare2。

attack-chain

Use for authorized multi-stage attack-path planning and orchestration when a task spans reconnaissance, initial access, privilege escalation, lateral movement, or impact assessment. Route single-stage tasks directly to their specialist skill.

binary-diff

|

binary-ninja-reverse

Use for authorized binary analysis in Binary Ninja, including HLIL/MLIL/LLIL inspection, strings/imports/exports, cross-references, types, patch review, Python API automation, and optional Binary Ninja MCP or localhost HTTP integration.

browser-automation

|

browser-extension-reverse

Use for authorized reverse engineering of browser extensions (Chrome/Firefox) including manifest analysis, background workers, and extension-based credential or traffic logic recovery.

case-review

Reviews a reverse-skill case package for scope readiness, Evidence to Finding to Path traceability, work item coverage, timeline references, and optional artifact hash integrity before report handoff.

cloud-k8s

Use for authorized cloud, container, and Kubernetes security assessment including metadata SSRF, IAM misconfig, container escape paths, and cluster RBAC review.

code-audit

Use for authorized source-code security review and SAST workflows including Semgrep, CodeQL patterns, dangerous API hunting, and fix verification.

ctf-sandbox

Thin PRIMARY for CTF / AWD / 靶场 multi-type orchestration. Hands off to the sidecar CTF-Sandbox-Orchestrator. Use when the user says CTF, AWD, 靶场, or 比赛题 and no more specific pwn/APK/IDA route already won.

database-security

Use for authorized database security assessment covering PostgreSQL/MySQL/MSSQL/Mongo/Redis exposure, authz, UDF/command paths, and misconfiguration review.

diagram-generator

generate, refine, validate, and render diagrams from natural language, notes, code snippets, schemas, tables, or existing diagram source. use for flowcharts, swimlanes, sequence diagrams, state diagrams, er diagrams, class diagrams, architecture/c4-style diagrams, dependency graphs, gantt charts, mind maps, user journeys, sankey-style flows, org charts, network graphs, and other visual models. supports mermaid by default, graphviz dot for complex graph layout, plantuml for uml-heavy engineering diagrams, and svg output when direct markup is more reliable.

digital-forensics

Use for authorized digital forensics including memory dumps, disk timelines, PCAP investigation, artifact triage, and IR evidence preservation.

docs-generator

|

edr-bypass-re

|

email-security

Use for authorized email security review including phishing analysis, header authentication (SPF/DKIM/DMARC), BEC patterns, and mailbox token abuse research.

firmware-pentest

|

ghidra-reverse

Use for free/open reverse engineering with Ghidra (headless or GUI), including decompile, cross-refs, and optional Ghidra MCP workflows when IDA is unavailable.

go-rust-reverse

Use for reverse engineering stripped Go and Rust binaries including runtime recognition, pclntab/moduel data recovery, panic strings, and idiomatic decompilation recovery.

相关技能