Reverse Engineering Dotnet Malware With Dnspy
Overview
Cybersecurity skill for reverse engineering dotnet malware with dnspy. Follows industry best practices and security standards.
When to Use
Trigger phrases:
"reverse engineering dotnet malware with dnspy"
"reverseing engineering dotnet malware with dnspy"
"Reverse engineers "
A malware sample is identified as a .NET assembly (C#, VB.NET, F#) requiring decompilation
Analyzing .NET-based malware families (AgentTesla, AsyncRAT, RedLine Stealer, Quasar RAT)
Deobfuscating .NET code protected by ConfuserEx, SmartAssembly, or custom obfuscators
Extracting hardcoded C2 configurations, encryption keys, and credentials from managed assemblies
Debugging .NET malware at runtime to observe decryption routines and dynamic behavior
Do not use for native (unmanaged) PE binaries; use Ghidra or IDA for native code analysis.
When NOT to Use
- When you lack proper authorization for testing
- For production systems without change management
- When the task requires legal or compliance expertise beyond technical scope
Prerequisites
- dnSpy or dnSpyEx installed (https://github.com/dnSpyEx/dnSpy - community maintained fork)
- de4dot for automated .NET deobfuscation (
https://github.com/de4dot/de4dot)
- ILSpy as an alternative decompiler for cross-validation
- .NET SDK installed for recompiling modified assemblies during analysis
- Isolated Windows VM for running dnSpy debugger on live malware
- Detect It Easy (DIE) for identifying the .NET obfuscator used
Workflow
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- Define Objectives — Clarify the goals and scope for engineering dotnet malware.
- Gather Resources — Collect tools, data, and access needed for engineering dotnet malware.
- Execute Process — Carry out engineering dotnet malware operations methodically.
- Verify Quality — Check results against acceptance criteria.
- Document Outcomes — Record findings, decisions, and next steps.
Tools
- dnspy — Primary tool for this skill
- Analysis Platform — Data processing and visualization
- Collaboration Tools — Team coordination and knowledge sharing
Process
- Reconnaissance — Gather target information, identify attack surface, enumerate services
- Analysis/Exploitation — Execute the technique, analyze results, document findings
- Reporting — Document IOCs, write findings, provide remediation recommendations
Verification
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: reverse-engineering-dotnet-malware-with-dnspy3description: Use when reverse engineers .NET malware using dnSpy decompiler and debugger4 to analyze C#/VB.NET source code, identify obfuscation techniques, extract configurations,5 and understand malicious functionality including stealers, RATs, and loaders. Activates6 for requests involving .NET malware analysis, C# malware decompilation, managed7 code reverse engineering, or .NET obfuscation analysis. . Use when working with8 reverse engineering dotnet malware with dnspy.9domain: cybersecurity10tags:11- malware12- dotnet13- reverse-engineering14- dnSpy15- decompilation16subdomain: malware-analysis17version: 1.0.018author: oyi7719license: Apache-2.020nist_csf:21- DE.AE-0222- RS.AN-0323- ID.RA-0124- DE.CM-0125category: cybersecurity26metadata:27 source: https://skillmd.com/skills/oyi77/reverse-engineering-dotnet-malware-with-dnspy28---2930# Reverse Engineering Dotnet Malware With Dnspy3132## Overview3334Cybersecurity skill for reverse engineering dotnet malware with dnspy. Follows industry best practices and security standards.3536## When to Use37**Trigger phrases:**38- "reverse engineering dotnet malware with dnspy"39- "reverseing engineering dotnet malware with dnspy"40- "Reverse engineers "414243- A malware sample is identified as a .NET assembly (C#, VB.NET, F#) requiring decompilation44- Analyzing .NET-based malware families (AgentTesla, AsyncRAT, RedLine Stealer, Quasar RAT)45- Deobfuscating .NET code protected by ConfuserEx, SmartAssembly, or custom obfuscators46- Extracting hardcoded C2 configurations, encryption keys, and credentials from managed assemblies47- Debugging .NET malware at runtime to observe decryption routines and dynamic behavior4849**Do not use** for native (unmanaged) PE binaries; use Ghidra or IDA for native code analysis.505152## When NOT to Use5354- When you lack proper authorization for testing55- For production systems without change management56- When the task requires legal or compliance expertise beyond technical scope575859## Prerequisites6061- dnSpy or dnSpyEx installed (https://github.com/dnSpyEx/dnSpy - community maintained fork)62- de4dot for automated .NET deobfuscation (`https://github.com/de4dot/de4dot`)63- ILSpy as an alternative decompiler for cross-validation64- .NET SDK installed for recompiling modified assemblies during analysis65- Isolated Windows VM for running dnSpy debugger on live malware66- Detect It Easy (DIE) for identifying the .NET obfuscator used6768## Workflow6970```python71# Example: IOC detection72import re7374IOC_PATTERNS = {75 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",76 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",77 "hash_md5": r"\b[a-f0-9]{32}\b",78 "hash_sha256": r"\b[a-f0-9]{64}\b",79}8081def extract_iocs(text: str) -> dict:82 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}83```84851. **Define Objectives** — Clarify the goals and scope for engineering dotnet malware.862. **Gather Resources** — Collect tools, data, and access needed for engineering dotnet malware.873. **Execute Process** — Carry out engineering dotnet malware operations methodically.884. **Verify Quality** — Check results against acceptance criteria.895. **Document Outcomes** — Record findings, decisions, and next steps.9091## Tools9293- **dnspy** — Primary tool for this skill94- **Analysis Platform** — Data processing and visualization95- **Collaboration Tools** — Team coordination and knowledge sharing969798## Process991001. **Reconnaissance** — Gather target information, identify attack surface, enumerate services1011. **Analysis/Exploitation** — Execute the technique, analyze results, document findings1021. **Reporting** — Document IOCs, write findings, provide remediation recommendations103104## Verification105106- [ ] All engineering dotnet malware procedures executed completely and documented107- [ ] Findings validated against multiple data sources108- [ ] False positives identified and filtered109- [ ] Results documented with evidence and timestamps110- [ ] Recommendations provided with risk-based prioritization111112## Anti-Rationalization Table113114| Rationalization | Reality |115|---|---|116| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |117| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |118| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |