[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AB2VZ7GNAYS9WE585TP9KB":3,"skill-same:01M7AB2VZ7GNAYS9WE585TP9KB":83},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":14,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M7AB2VZ7GNAYS9WE585TP9KB","reverse-engineering-dotnet-malware-with-dnspy",null,"Reverse engineers .NET malware samples using the dnSpy decompiler and debugger to read C#\u002FVB.NET source, deobfuscate code protected by tools like ConfuserEx or SmartAssembly, and extract hardcoded C2 configurations, keys, and credentials. Use when a sample is identified as a .NET assembly (e.g. AgentTesla, AsyncRAT, RedLine Stealer, Quasar RAT) and needs decompilation, deobfuscation, or config extraction.","NeelakshSaxena\u002FVayu","NeelakshSaxena","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F87892838?v=4","01M7A3B9YFS6F6N9DD1787DT86","Neelaksh Saxena","01M7A3B9ZKBT09MNMPX2XN69BY",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-dotnet-malware-with-dnspy\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-dotnet-malware-with-dnspy\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: reverse-engineering-dotnet-malware-with-dnspy\ndescription: 'Reverse engineers .NET malware samples using the dnSpy decompiler and\n  debugger to read C#\u002FVB.NET source, deobfuscate code protected by tools like ConfuserEx\n  or SmartAssembly, and extract hardcoded C2 configurations, keys, and credentials.\n  Use when a sample is identified as a .NET assembly (e.g. AgentTesla, AsyncRAT, RedLine\n  Stealer, Quasar RAT) and needs decompilation, deobfuscation, or config extraction.\n\n  '\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- malware\n- dotnet\n- reverse-engineering\n- dnSpy\n- decompilation\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- DE.AE-02\n- RS.AN-03\n- ID.RA-01\n- DE.CM-01\nmitre_attack:\n- T1027\n- T1055\n- T1140\n- T1497\n---\n\n# Reverse Engineering .NET Malware with dnSpy\n\n## When to Use\n\n- A malware sample is identified as a .NET assembly (C#, VB.NET, F#) requiring decompilation\n- Analyzing .NET-based malware families (AgentTesla, AsyncRAT, RedLine Stealer, Quasar RAT)\n- Deobfuscating .NET code protected by ConfuserEx, SmartAssembly, or custom obfuscators\n- Extracting hardcoded C2 configurations, encryption keys, and credentials from managed assemblies\n- Debugging .NET malware at runtime to observe decryption routines and dynamic behavior\n\n**Do not use** for native (unmanaged) PE binaries; use Ghidra or IDA for native code analysis.\n\n## Prerequisites\n\n- dnSpy or dnSpyEx installed (https:\u002F\u002Fgithub.com\u002FdnSpyEx\u002FdnSpy - community maintained fork)\n- de4dot for automated .NET deobfuscation (`https:\u002F\u002Fgithub.com\u002Fde4dot\u002Fde4dot`)\n- ILSpy as an alternative decompiler for cross-validation\n- .NET SDK installed for recompiling modified assemblies during analysis\n- Isolated Windows VM for running dnSpy debugger on live malware\n- Detect It Easy (DIE) for identifying the .NET obfuscator used\n\n## Workflow\n\n### Step 1: Identify .NET Assembly and Obfuscator\n\nVerify the sample is a .NET binary and detect protection:\n\n```bash\n# Check if file is .NET assembly\nfile suspect.exe\n# Output should contain \"PE32 executable\" with .NET metadata\n\n# Detect obfuscator with Detect It Easy\ndiec suspect.exe\n\n# Python-based .NET detection\npython3 \u003C\u003C 'PYEOF'\nimport pefile\n\npe = pefile.PE(\"suspect.exe\")\n\n# Check for .NET COM descriptor\nif hasattr(pe, 'DIRECTORY_ENTRY_COM_DESCRIPTOR'):\n    print(\"[*] .NET assembly detected\")\n    print(f\"    Runtime version: {pe.DIRECTORY_ENTRY_COM_DESCRIPTOR}\")\nelse:\n    # Check for mscoree.dll import (alternative detection)\n    for entry in pe.DIRECTORY_ENTRY_IMPORT:\n        if entry.dll.decode().lower() == \"mscoree.dll\":\n            print(\"[*] .NET assembly detected (mscoree.dll import)\")\n            break\n    else:\n        print(\"[!] Not a .NET assembly\")\n\n# Check section names for .NET indicators\nfor section in pe.sections:\n    name = section.Name.decode().rstrip('\\x00')\n    if name in ['.text', '.rsrc', '.reloc']:\n        print(f\"    Section: {name} (typical .NET)\")\nPYEOF\n```\n\n### Step 2: Deobfuscate with de4dot\n\nRemove common .NET obfuscation before manual analysis:\n\n```bash\n# Run de4dot to identify and remove obfuscation\nde4dot suspect.exe -o suspect_cleaned.exe\n\n# Force specific deobfuscator\nde4dot suspect.exe -p cf  # ConfuserEx\nde4dot suspect.exe -p sa  # SmartAssembly\nde4dot suspect.exe -p dr  # Dotfuscator\nde4dot suspect.exe -p rv  # Reactor\nde4dot suspect.exe -p bl  # Babel.NET\n\n# Verbose output for debugging\nde4dot -v suspect.exe -o suspect_cleaned.exe\n\n# Handle multi-file assemblies\nde4dot suspect.exe suspect_helper.dll -o cleaned\u002F\n```\n\n```\nCommon .NET Obfuscators:\n━━━━━━━━━━━━━━━━━━━━━━━\nConfuserEx:      String encryption, control flow, anti-debug, anti-tamper\nSmartAssembly:   String encoding, flow obfuscation, pruning\nDotfuscator:     Renaming, string encryption, control flow\n.NET Reactor:    Native code generation, necrobit, anti-debug\nBabel.NET:       String encryption, resource encryption, code virtualization\nCrypto Obfuscator: String encryption, anti-debug, watermarking\nCustom:          Malware-specific obfuscation (manual de4dot configuration needed)\n```\n\n### Step 3: Open in dnSpy and Analyze Code\n\nLoad the deobfuscated assembly in dnSpy for source-level analysis:\n\n```\ndnSpy Analysis Workflow:\n━━━━━━━━━━━━━━━━━━━━━━━\n1. File -> Open -> Select cleaned assembly\n2. Navigate to the entry point:\n   - Assembly Explorer -> \u003Cnamespace> -> Program class -> Main method\n   - Or: Right-click assembly -> Go to Entry Point\n\n3. Key areas to examine:\n   - Entry point (Main) for initialization and execution flow\n   - Form classes for UI-based malware (RATs, stealers)\n   - Network\u002FHTTP classes for C2 communication\n   - Crypto\u002Fencryption classes for data protection\n   - Resource access for embedded payloads\n   - Timer\u002FThread classes for persistence and scheduling\n\n4. Navigation shortcuts:\n   Ctrl+G       - Go to token\u002Faddress\n   Ctrl+Shift+K - Search assemblies\n   F12          - Go to definition\n   Ctrl+R       - Analyze (find usages)\n   F5           - Start debugging\n   F9           - Toggle breakpoint\n```\n\n### Step 4: Extract Configuration and C2 Data\n\nLocate hardcoded configuration in the decompiled source:\n\n```csharp\n\u002F\u002F Common .NET malware configuration patterns:\n\n\u002F\u002F Pattern 1: Static class with hardcoded values\npublic static class Config {\n    public static string Host = \"185.220.101.42\";\n    public static int Port = 4782;\n    public static string Key = \"GhOsT_RaT_2025\";\n    public static string Mutex = \"AsyncMutex_6SI8OkPnk\";\n    public static bool Install = true;\n    public static string InstallFolder = \"%AppData%\";\n}\n\n\u002F\u002F Pattern 2: Encrypted strings decrypted at runtime\npublic static string Decrypt(string input) {\n    byte[] data = Convert.FromBase64String(input);\n    byte[] key = Encoding.UTF8.GetBytes(\"SecretKey123\");\n    for (int i = 0; i \u003C data.Length; i++) {\n        data[i] ^= key[i % key.Length];\n    }\n    return Encoding.UTF8.GetString(data);\n}\n\n\u002F\u002F Pattern 3: Resource-embedded configuration\nbyte[] configData = Properties.Resources.config;\nstring config = AES.Decrypt(configData, derivedKey);\n```\n\n```python\n# Python script to extract .NET resource strings\nimport subprocess\nimport re\nimport base64\n\n# Use monodis (Mono) or ildasm (.NET SDK) to dump IL\nresult = subprocess.run(\n    [\"monodis\", \"--output=il_dump.il\", \"suspect_cleaned.exe\"],\n    capture_output=True, text=True\n)\n\n# Search for string literals in IL dump\nwith open(\"il_dump.il\", errors=\"ignore\") as f:\n    il_code = f.read()\n\n# Find ldstr (load string) instructions\nstrings = re.findall(r'ldstr\\s+\"([^\"]+)\"', il_code)\nfor s in strings:\n    # Check for Base64 encoded strings\n    try:\n        decoded = base64.b64decode(s).decode('utf-8', errors='ignore')\n        if len(decoded) > 3 and decoded.isprintable():\n            print(f\"  Base64: {s[:40]}... -> {decoded[:100]}\")\n    except:\n        pass\n    # Check for URLs\u002FIPs\n    if re.match(r'https?:\u002F\u002F', s) or re.match(r'\\d+\\.\\d+\\.\\d+\\.\\d+', s):\n        print(f\"  Network: {s}\")\n```\n\n### Step 5: Debug with dnSpy\n\nSet breakpoints and debug the malware to observe runtime behavior:\n\n```\ndnSpy Debugging Workflow:\n━━━━━━━━━━━━━━━━━━━━━━━\n1. Set breakpoints on key methods:\n   - String decryption functions (to capture decrypted values)\n   - Network connection methods (to capture C2 URLs)\n   - File write operations (to see what is dropped)\n   - Registry modification methods (to see persistence)\n\n2. Debug -> Start Debugging (F5)\n   - Select the assembly to debug\n   - Set command-line arguments if needed\n   - Configure exception handling (break on all CLR exceptions)\n\n3. At each breakpoint:\n   - Inspect local variables (Locals window)\n   - Evaluate expressions (Immediate window)\n   - View call stack to understand execution context\n   - Step over (F10) \u002F Step into (F11) \u002F Step out (Shift+F11)\n\n4. Capture decrypted strings:\n   - Set breakpoint after decryption function returns\n   - Read the return value from the Locals window\n   - Document all decrypted configuration values\n```\n\n### Step 6: Document Findings\n\nCompile analysis results into a structured report:\n\n```\nAnalysis documentation should include:\n- .NET assembly metadata (CLR version, target framework, compilation info)\n- Obfuscator identified and deobfuscation method used\n- Complete C2 configuration (hosts, ports, encryption keys, mutex names)\n- Malware capabilities (keylogging, screen capture, file theft, etc.)\n- Persistence mechanisms (registry, scheduled tasks, startup folder)\n- Anti-analysis techniques (VM detection, debugger detection, sandbox evasion)\n- Extracted IOCs (C2 IPs\u002Fdomains, file hashes, mutex names, registry keys)\n- YARA rule based on unique code patterns or strings\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **CIL\u002FMSIL** | Common Intermediate Language; the bytecode format .NET assemblies compile to, which can be decompiled back to high-level C#\u002FVB.NET |\n| **Metadata Token** | Unique identifier for .NET types, methods, and fields within the assembly metadata tables; used for navigation in dnSpy |\n| **de4dot** | Open-source .NET deobfuscator that identifies and removes protection from many commercial and malware-specific obfuscators |\n| **ConfuserEx** | Popular open-source .NET obfuscator frequently used by malware authors for string encryption and control flow obfuscation |\n| **String Encryption** | Obfuscation technique replacing string literals with encrypted data and runtime decryption calls to hide IOCs from static analysis |\n| **Resource Embedding** | Storing configuration, payloads, or additional assemblies in .NET embedded resources, often encrypted with a key derived from assembly metadata |\n| **Assembly.Load** | .NET method loading assemblies from byte arrays in memory, enabling fileless execution of embedded payloads |\n\n## Tools & Systems\n\n- **dnSpy\u002FdnSpyEx**: Open-source .NET assembly editor, decompiler, and debugger supporting C# and VB.NET decompilation\n- **de4dot**: Automated .NET deobfuscator supporting ConfuserEx, SmartAssembly, Dotfuscator, Reactor, and many other protectors\n- **ILSpy**: Open-source .NET decompiler providing C#, VB.NET, and IL views of assembly code\n- **dotPeek**: JetBrains' free .NET decompiler with symbol server and cross-reference navigation\n- **Detect It Easy (DIE)**: Multi-format file analyzer identifying .NET framework version, obfuscator, and compiler information\n\n## Common Scenarios\n\n### Scenario: Analyzing an AgentTesla Information Stealer\n\n**Context**: A phishing email delivers a .NET executable identified as AgentTesla. The sample needs analysis to determine what credentials it steals, how it exfiltrates data, and its C2 configuration.\n\n**Approach**:\n1. Run Detect It Easy to identify the obfuscator (commonly ConfuserEx or custom)\n2. Deobfuscate with de4dot to restore readable class\u002Fmethod names and decrypt strings\n3. Open in dnSpy and navigate to the entry point to understand initialization\n4. Locate the credential harvesting modules (browser, email, FTP, VPN password theft classes)\n5. Find the exfiltration method (SMTP email, FTP upload, HTTP POST, Telegram bot API)\n6. Extract C2 configuration (SMTP server, credentials, recipient email, or HTTP URL)\n7. Set debugger breakpoints on the decryption function to capture all decrypted strings at once\n\n**Pitfalls**:\n- Analyzing without de4dot first (ConfuserEx makes manual analysis extremely difficult)\n- Not checking for multi-stage loading (initial .NET executable may load additional assemblies from resources)\n- Missing configuration stored in .NET resources rather than hardcoded strings\n- Running the debugger without network isolation (AgentTesla will attempt to exfiltrate immediately)\n\n## Output Format\n\n```\n.NET MALWARE ANALYSIS REPORT\n================================\nSample:           invoice_scanner.exe\nSHA-256:          e3b0c44298fc1c149afbf4c8996fb924...\nType:             .NET Assembly (C#)\nFramework:        .NET Framework 4.8\nObfuscator:       ConfuserEx v1.6\nDeobfuscated:     Yes (de4dot -p cf)\n\nCLASSIFICATION\nFamily:           AgentTesla v3\nType:             Information Stealer \u002F Keylogger\nCompile Date:     2025-09-10\n\nC2 CONFIGURATION\nExfil Method:     SMTP (Email)\nSMTP Server:      smtp.yandex[.]com:587\nSMTP User:        exfil.account@yandex[.]com\nSMTP Pass:        Str0ngP@ssw0rd2025\nRecipient:        operator@protonmail[.]com\nInterval:         30 minutes\nEncryption:       AES-256 with key \"AgentTesla_2025_key\"\n\nCAPABILITIES\n[*] Browser credential theft (Chrome, Firefox, Edge, Opera)\n[*] Email client passwords (Outlook, Thunderbird)\n[*] FTP client credentials (FileZilla, WinSCP)\n[*] VPN credentials (NordVPN, OpenVPN)\n[*] Keylogging (SetWindowsHookEx)\n[*] Screenshot capture (every 30 seconds)\n[*] Clipboard monitoring\n\nPERSISTENCE\nMethod:           Registry Run key + Scheduled Task\nRegistry:         HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\WindowsUpdate\nTask:             \\Microsoft\\Windows\\WindowsUpdate\\Updater\n\nEXTRACTED IOCs\nSMTP Server:      smtp.yandex[.]com\nExfil Email:      exfil.account@yandex[.]com\nRecipient:        operator@protonmail[.]com\nMutex:            AgentTesla_2025_Q3_MUTEX\nInstall Path:     %AppData%\\Microsoft\\Windows\\svchost.exe\n```\n","# Reverse Engineering .NET Malware with dnSpy\n\n## When to Use\n\n- A malware sample is identified as a .NET assembly (C#, VB.NET, F#) requiring decompilation\n- Analyzing .NET-based malware families (AgentTesla, AsyncRAT, RedLine Stealer, Quasar RAT)\n- Deobfuscating .NET code protected by ConfuserEx, SmartAssembly, or custom obfuscators\n- Extracting hardcoded C2 configurations, encryption keys, and credentials from managed assemblies\n- Debugging .NET malware at runtime to observe decryption routines and dynamic behavior\n\n**Do not use** for native (unmanaged) PE binaries; use Ghidra or IDA for native code analysis.\n\n## Prerequisites\n\n- dnSpy or dnSpyEx installed (https:\u002F\u002Fgithub.com\u002FdnSpyEx\u002FdnSpy - community maintained fork)\n- de4dot for automated .NET deobfuscation (`https:\u002F\u002Fgithub.com\u002Fde4dot\u002Fde4dot`)\n- ILSpy as an alternative decompiler for cross-validation\n- .NET SDK installed for recompiling modified assemblies during analysis\n- Isolated Windows VM for running dnSpy debugger on live malware\n- Detect It Easy (DIE) for identifying the .NET obfuscator used\n\n## Workflow\n\n### Step 1: Identify .NET Assembly and Obfuscator\n\nVerify the sample is a .NET binary and detect protection:\n\n```bash\n# Check if file is .NET assembly\nfile suspect.exe\n# Output should contain \"PE32 executable\" with .NET metadata\n\n# Detect obfuscator with Detect It Easy\ndiec suspect.exe\n\n# Python-based .NET detection\npython3 \u003C\u003C 'PYEOF'\nimport pefile\n\npe = pefile.PE(\"suspect.exe\")\n\n# Check for .NET COM descriptor\nif hasattr(pe, 'DIRECTORY_ENTRY_COM_DESCRIPTOR'):\n    print(\"[*] .NET assembly detected\")\n    print(f\"    Runtime version: {pe.DIRECTORY_ENTRY_COM_DESCRIPTOR}\")\nelse:\n    # Check for mscoree.dll import (alternative detection)\n    for entry in pe.DIRECTORY_ENTRY_IMPORT:\n        if entry.dll.decode().lower() == \"mscoree.dll\":\n            print(\"[*] .NET assembly detected (mscoree.dll import)\")\n            break\n    else:\n        print(\"[!] Not a .NET assembly\")\n\n# Check section names for .NET indicators\nfor section in pe.sections:\n    name = section.Name.decode().rstrip('\\x00')\n    if name in ['.text', '.rsrc', '.reloc']:\n        print(f\"    Section: {name} (typical .NET)\")\nPYEOF\n```\n\n### Step 2: Deobfuscate with de4dot\n\nRemove common .NET obfuscation before manual analysis:\n\n```bash\n# Run de4dot to identify and remove obfuscation\nde4dot suspect.exe -o suspect_cleaned.exe\n\n# Force specific deobfuscator\nde4dot suspect.exe -p cf  # ConfuserEx\nde4dot suspect.exe -p sa  # SmartAssembly\nde4dot suspect.exe -p dr  # Dotfuscator\nde4dot suspect.exe -p rv  # Reactor\nde4dot suspect.exe -p bl  # Babel.NET\n\n# Verbose output for debugging\nde4dot -v suspect.exe -o suspect_cleaned.exe\n\n# Handle multi-file assemblies\nde4dot suspect.exe suspect_helper.dll -o cleaned\u002F\n```\n\n```\nCommon .NET Obfuscators:\n━━━━━━━━━━━━━━━━━━━━━━━\nConfuserEx:      String encryption, control flow, anti-debug, anti-tamper\nSmartAssembly:   String encoding, flow obfuscation, pruning\nDotfuscator:     Renaming, string encryption, control flow\n.NET Reactor:    Native code generation, necrobit, anti-debug\nBabel.NET:       String encryption, resource encryption, code virtualization\nCrypto Obfuscator: String encryption, anti-debug, watermarking\nCustom:          Malware-specific obfuscation (manual de4dot configuration needed)\n```\n\n### Step 3: Open in dnSpy and Analyze Code\n\nLoad the deobfuscated assembly in dnSpy for source-level analysis:\n\n```\ndnSpy Analysis Workflow:\n━━━━━━━━━━━━━━━━━━━━━━━\n1. File -> Open -> Select cleaned assembly\n2. Navigate to the entry point:\n   - Assembly Explorer -> \u003Cnamespace> -> Program class -> Main method\n   - Or: Right-click assembly -> Go to Entry Point\n\n3. Key areas to examine:\n   - Entry point (Main) for initialization and execution flow\n   - Form classes for UI-based malware (RATs, stealers)\n   - Network\u002FHTTP classes for C2 communication\n   - Crypto\u002Fencryption classes for data protection\n   - Resource access for embedded payloads\n   - Timer\u002FThread classes for persistence and scheduling\n\n4. Navigation shortcuts:\n   Ctrl+G       - Go to token\u002Faddress\n   Ctrl+Shift+K - Search assemblies\n   F12          - Go to definition\n   Ctrl+R       - Analyze (find usages)\n   F5           - Start debugging\n   F9           - Toggle breakpoint\n```\n\n### Step 4: Extract Configuration and C2 Data\n\nLocate hardcoded configuration in the decompiled source:\n\n```csharp\n\u002F\u002F Common .NET malware configuration patterns:\n\n\u002F\u002F Pattern 1: Static class with hardcoded values\npublic static class Config {\n    public static string Host = \"185.220.101.42\";\n    public static int Port = 4782;\n    public static string Key = \"GhOsT_RaT_2025\";\n    public static string Mutex = \"AsyncMutex_6SI8OkPnk\";\n    public static bool Install = true;\n    public static string InstallFolder = \"%AppData%\";\n}\n\n\u002F\u002F Pattern 2: Encrypted strings decrypted at runtime\npublic static string Decrypt(string input) {\n    byte[] data = Convert.FromBase64String(input);\n    byte[] key = Encoding.UTF8.GetBytes(\"SecretKey123\");\n    for (int i = 0; i \u003C data.Length; i++) {\n        data[i] ^= key[i % key.Length];\n    }\n    return Encoding.UTF8.GetString(data);\n}\n\n\u002F\u002F Pattern 3: Resource-embedded configuration\nbyte[] configData = Properties.Resources.config;\nstring config = AES.Decrypt(configData, derivedKey);\n```\n\n```python\n# Python script to extract .NET resource strings\nimport subprocess\nimport re\nimport base64\n\n# Use monodis (Mono) or ildasm (.NET SDK) to dump IL\nresult = subprocess.run(\n    [\"monodis\", \"--output=il_dump.il\", \"suspect_cleaned.exe\"],\n    capture_output=True, text=True\n)\n\n# Search for string literals in IL dump\nwith open(\"il_dump.il\", errors=\"ignore\") as f:\n    il_code = f.read()\n\n# Find ldstr (load string) instructions\nstrings = re.findall(r'ldstr\\s+\"([^\"]+)\"', il_code)\nfor s in strings:\n    # Check for Base64 encoded strings\n    try:\n        decoded = base64.b64decode(s).decode('utf-8', errors='ignore')\n        if len(decoded) > 3 and decoded.isprintable():\n            print(f\"  Base64: {s[:40]}... -> {decoded[:100]}\")\n    except:\n        pass\n    # Check for URLs\u002FIPs\n    if re.match(r'https?:\u002F\u002F', s) or re.match(r'\\d+\\.\\d+\\.\\d+\\.\\d+', s):\n        print(f\"  Network: {s}\")\n```\n\n### Step 5: Debug with dnSpy\n\nSet breakpoints and debug the malware to observe runtime behavior:\n\n```\ndnSpy Debugging Workflow:\n━━━━━━━━━━━━━━━━━━━━━━━\n1. Set breakpoints on key methods:\n   - String decryption functions (to capture decrypted values)\n   - Network connection methods (to capture C2 URLs)\n   - File write operations (to see what is dropped)\n   - Registry modification methods (to see persistence)\n\n2. Debug -> Start Debugging (F5)\n   - Select the assembly to debug\n   - Set command-line arguments if needed\n   - Configure exception handling (break on all CLR exceptions)\n\n3. At each breakpoint:\n   - Inspect local variables (Locals window)\n   - Evaluate expressions (Immediate window)\n   - View call stack to understand execution context\n   - Step over (F10) \u002F Step into (F11) \u002F Step out (Shift+F11)\n\n4. Capture decrypted strings:\n   - Set breakpoint after decryption function returns\n   - Read the return value from the Locals window\n   - Document all decrypted configuration values\n```\n\n### Step 6: Document Findings\n\nCompile analysis results into a structured report:\n\n```\nAnalysis documentation should include:\n- .NET assembly metadata (CLR version, target framework, compilation info)\n- Obfuscator identified and deobfuscation method used\n- Complete C2 configuration (hosts, ports, encryption keys, mutex names)\n- Malware capabilities (keylogging, screen capture, file theft, etc.)\n- Persistence mechanisms (registry, scheduled tasks, startup folder)\n- Anti-analysis techniques (VM detection, debugger detection, sandbox evasion)\n- Extracted IOCs (C2 IPs\u002Fdomains, file hashes, mutex names, registry keys)\n- YARA rule based on unique code patterns or strings\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **CIL\u002FMSIL** | Common Intermediate Language; the bytecode format .NET assemblies compile to, which can be decompiled back to high-level C#\u002FVB.NET |\n| **Metadata Token** | Unique identifier for .NET types, methods, and fields within the assembly metadata tables; used for navigation in dnSpy |\n| **de4dot** | Open-source .NET deobfuscator that identifies and removes protection from many commercial and malware-specific obfuscators |\n| **ConfuserEx** | Popular open-source .NET obfuscator frequently used by malware authors for string encryption and control flow obfuscation |\n| **String Encryption** | Obfuscation technique replacing string literals with encrypted data and runtime decryption calls to hide IOCs from static analysis |\n| **Resource Embedding** | Storing configuration, payloads, or additional assemblies in .NET embedded resources, often encrypted with a key derived from assembly metadata |\n| **Assembly.Load** | .NET method loading assemblies from byte arrays in memory, enabling fileless execution of embedded payloads |\n\n## Tools & Systems\n\n- **dnSpy\u002FdnSpyEx**: Open-source .NET assembly editor, decompiler, and debugger supporting C# and VB.NET decompilation\n- **de4dot**: Automated .NET deobfuscator supporting ConfuserEx, SmartAssembly, Dotfuscator, Reactor, and many other protectors\n- **ILSpy**: Open-source .NET decompiler providing C#, VB.NET, and IL views of assembly code\n- **dotPeek**: JetBrains' free .NET decompiler with symbol server and cross-reference navigation\n- **Detect It Easy (DIE)**: Multi-format file analyzer identifying .NET framework version, obfuscator, and compiler information\n\n## Common Scenarios\n\n### Scenario: Analyzing an AgentTesla Information Stealer\n\n**Context**: A phishing email delivers a .NET executable identified as AgentTesla. The sample needs analysis to determine what credentials it steals, how it exfiltrates data, and its C2 configuration.\n\n**Approach**:\n1. Run Detect It Easy to identify the obfuscator (commonly ConfuserEx or custom)\n2. Deobfuscate with de4dot to restore readable class\u002Fmethod names and decrypt strings\n3. Open in dnSpy and navigate to the entry point to understand initialization\n4. Locate the credential harvesting modules (browser, email, FTP, VPN password theft classes)\n5. Find the exfiltration method (SMTP email, FTP upload, HTTP POST, Telegram bot API)\n6. Extract C2 configuration (SMTP server, credentials, recipient email, or HTTP URL)\n7. Set debugger breakpoints on the decryption function to capture all decrypted strings at once\n\n**Pitfalls**:\n- Analyzing without de4dot first (ConfuserEx makes manual analysis extremely difficult)\n- Not checking for multi-stage loading (initial .NET executable may load additional assemblies from resources)\n- Missing configuration stored in .NET resources rather than hardcoded strings\n- Running the debugger without network isolation (AgentTesla will attempt to exfiltrate immediately)\n\n## Output Format\n\n```\n.NET MALWARE ANALYSIS REPORT\n================================\nSample:           invoice_scanner.exe\nSHA-256:          e3b0c44298fc1c149afbf4c8996fb924...\nType:             .NET Assembly (C#)\nFramework:        .NET Framework 4.8\nObfuscator:       ConfuserEx v1.6\nDeobfuscated:     Yes (de4dot -p cf)\n\nCLASSIFICATION\nFamily:           AgentTesla v3\nType:             Information Stealer \u002F Keylogger\nCompile Date:     2025-09-10\n\nC2 CONFIGURATION\nExfil Method:     SMTP (Email)\nSMTP Server:      smtp.yandex[.]com:587\nSMTP User:        exfil.account@yandex[.]com\nSMTP Pass:        Str0ngP@ssw0rd2025\nRecipient:        operator@protonmail[.]com\nInterval:         30 minutes\nEncryption:       AES-256 with key \"AgentTesla_2025_key\"\n\nCAPABILITIES\n[*] Browser credential theft (Chrome, Firefox, Edge, Opera)\n[*] Email client passwords (Outlook, Thunderbird)\n[*] FTP client credentials (FileZilla, WinSCP)\n[*] VPN credentials (NordVPN, OpenVPN)\n[*] Keylogging (SetWindowsHookEx)\n[*] Screenshot capture (every 30 seconds)\n[*] Clipboard monitoring\n\nPERSISTENCE\nMethod:           Registry Run key + Scheduled Task\nRegistry:         HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\WindowsUpdate\nTask:             \\Microsoft\\Windows\\WindowsUpdate\\Updater\n\nEXTRACTED IOCs\nSMTP Server:      smtp.yandex[.]com\nExfil Email:      exfil.account@yandex[.]com\nRecipient:        operator@protonmail[.]com\nMutex:            AgentTesla_2025_Q3_MUTEX\nInstall Path:     %AppData%\\Microsoft\\Windows\\svchost.exe\n```\n",{"name":5,"tags":25,"author":31,"domain":32,"license":15,"version":33,"nist_csf":34,"subdomain":39,"description":40,"mitre_attack":41},[26,27,28,29,30],"malware","dotnet","reverse-engineering","dnSpy","decompilation","mahipal","cybersecurity","1.0.0",[35,36,37,38],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis","Reverse engineers .NET malware samples using the dnSpy decompiler and debugger to read C#\u002FVB.NET source, deobfuscate code protected by tools like ConfuserEx or SmartAssembly, and extract hardcoded C2 configurations, keys, and credentials. Use when a sample is identified as a .NET assembly (e.g. AgentTesla, AsyncRAT, RedLine Stealer, Quasar RAT) and needs decompilation, deobfuscation, or config extraction.\n",[42,43,44,45],"T1027","T1055","T1140","T1497","main","7540bbccf0c1ded6156a467b02c95b61ad62413f",".agents\u002Fskills\u002Freverse-engineering-dotnet-malware-with-dnspy","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena","Currently exploring the intersection of tech","2026-09-11 03:02:31",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add NeelakshSaxena\u002FVayu --skill reverse-engineering-dotnet-malware-with-dnspy",{"tool":59,"command":60},"bunx","bunx skills add NeelakshSaxena\u002FVayu --skill reverse-engineering-dotnet-malware-with-dnspy",{"tool":62,"command":63},"pnpm","pnpm dlx skills add NeelakshSaxena\u002FVayu --skill reverse-engineering-dotnet-malware-with-dnspy","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-dotnet-malware-with-dnspy\u002FSKILL.md",true,[67,71,77],{"path":68,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fapi-reference.md","REFERENCE","参考文档",2531,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-dotnet-malware-with-dnspy\u002Freferences\u002Fapi-reference.md",{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"scripts\u002Fagent.py","SCRIPT","脚本",8248,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freverse-engineering-dotnet-malware-with-dnspy\u002Fscripts\u002Fagent.py",[84,91,98,105,112,119],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":20},"01M7ACCCVNCFKMA9X6D15X6G98","runpodctl","Runpod CLI for managing GPU\u002FCPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send\u002Freceive). Use for terminal\u002FCI\u002Fscripting, Hub browse\u002Fdeploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpodctl\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":20},"01M7ACC63SRHEA5KMCHSMZK2TC","runpod","Start here for any Runpod task — running GPU\u002FCPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":20},"01M7ACC0Q1C89N9BZBV91CTQTF","runpod-usage","How Runpod works and how to work it — pods vs serverless, GPU\u002FVRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv\u002Fapt). Use to answer \"how does X work\", \"which GPU\", \"how do I build a container\", or \"how do I stand up a workload on a pod\". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-usage\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":20},"01M7ACBRPE345GF5GM5B8P8RRC","runpod-templates","Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says \"run \u003CX> on a pod\" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-templates\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":20},"01M7ACBJATHKVX1TWES2F44GY8","runpod-migrate","Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-migrate\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":20},"01M7ACBC7GHVH6T9YEAPCG2AP8","runpod-mcp","Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU\u002FCPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-mcp\u002FSKILL.md",[],[]]