costrict-plugins-repo/mukul975-anthropic-cybersecurity-skills-cybersecurity-skills/analyzing-packed-malware-with-upx-unpacker
Claude Code and agent skill by costrict-plugins-repo/mukul975-anthropic-cybersecurity-skills-cybersecurity-skills
- community
Checking that the SKILL.md file is still in the repository.
'Identifies and unpacks UPX-packed malware samples, including binaries with modified UPX magic bytes or headers that block automated decompression, to recover the original executable for static analysis. Use when a sample shows high entropy, minimal imports, or only LoadLibrary/GetProcAddress in its import table, or when preparing a packed binary for disassembly in Ghidra or IDA.
Install
npx vskill@latest install costrict-plugins-repo/mukul975-anthropic-cybersecurity-skills-cybersecurity-skills/analyzing-packed-malware-with-upx-unpackerSKILL.md
The same SKILL.md was published earlier as costrict-plugins-repo/mukul975-anthropic-cybersecurity-skills-cybersecurity-skills/analyzing-packed-malware-with-upx-unpacker.
Analyzing Packed Malware with UPX Unpacker
When to Use
- Static analysis reveals high entropy sections and minimal imports indicating the binary is packed
- PEiD, Detect It Easy, or PEStudio identifies UPX or another known packer
- The import table contains only LoadLibrary and GetProcAddress (runtime import resolution typical of packed binaries)
- You need to recover the original binary for proper disassembly and decompilation in Ghidra or IDA
- Automated UPX decompression fails because the malware author modified UPX magic bytes or headers
Do not use when dealing with custom packers, VM-based protectors (Themida, VMProtect), or samples where dynamic unpacking via debugging is more appropriate.
Prerequisites
- UPX (Ultimate Packer for eXecutables) installed (
apt install upx-uclor download from https://upx.github.io/) - Detect It Easy (DIE) for packer identification
- Python 3.8+ with
pefilelibrary for manual header repair - x64dbg or x32dbg for manual unpacking when automated tools fail
- PE-bear or CFF Explorer for PE header inspection and repair
- Isolated analysis VM without network connectivity
Workflow
Step 1: Identify the Packer
Determine if the sample is packed and identify the packer:
Step 2: Attempt Standard UPX Decompression
Try the built-in UPX decompression:
Step 3: Repair Modified UPX Headers
If standard decompression fails, repair tampered magic bytes:
Step 4: Manual Unpacking with Debugger
When automated unpacking fails entirely, use dynamic unpacking:
Step 5: Validate Unpacked Binary
Verify the unpacked sample is valid and complete:
Key Concepts
| Term | Definition | |
|---|---|---|
| Packing | Compressing or encrypting executable code to reduce file size and hinder static analysis; the binary contains an unpacking stub that restores code at runtime | |
| UPX | Ultimate Packer for eXecutables; open-source executable packer commonly abused by malware authors because it is free and effective | |
| Original Entry Point (OEP) | The real starting address of the malware code before packing; the unpacking stub decompresses code then jumps to the OEP | |
| Import Reconstruction | Process of rebuilding the import address table after dumping an unpacked process from memory using tools like Scylla or ImpRec | |
| PUSHAD/POPAD | x86 instructions that save/restore all general-purpose registers; UPX uses this pattern to preserve register state during unpacking | |
| Section Entropy | Randomness measure of PE section data; packed sections show entropy > 7.0 while normal code sections average 5.0-6.5 | |
| Magic Bytes | Signature bytes within a file identifying its format; UPX uses "UPX!" which malware authors modify to prevent automated decompression |
Tools & Systems
- UPX: Open-source executable packer with built-in decompression capability for properly packed files
- Detect It Easy (DIE): Packer, compiler, and linker detection tool that identifies protection on PE, ELF, and Mach-O files
- x64dbg/x32dbg: Open-source Windows debugger used for manual unpacking through dynamic execution and breakpoint-based OEP finding
- Scylla: Import reconstruction tool integrated with x64dbg for rebuilding IAT after memory dumping
- PE-bear: PE file viewer and editor for inspecting and repairing PE headers after unpacking
Common Scenarios
Scenario: Unpacking Malware with Modified UPX Headers
Context: A malware sample is identified as UPX-packed by section names (UPX0, UPX1) but upx -d fails with "CantUnpackException: header corrupted". The malware author modified the UPX magic bytes to prevent automated decompression.
Approach:
- Open the binary in a hex editor and search for the UPX header area (typically at the end of packed data)
- Identify the modified magic bytes (e.g., "UPX!" changed to "UPX\x00" or completely zeroed)
- Use the Python repair script to restore "UPX!" magic and correct section names
- Retry
upx -don the repaired binary - If repair fails, fall back to manual unpacking with x64dbg (PUSHAD -> hardware BP on ESP -> POPAD -> JMP OEP)
- Validate the unpacked binary has proper imports and reasonable entropy values
- Import into Ghidra or IDA for full static analysis
Pitfalls:
- Assuming UPX is the only packer; the binary may be double-packed (UPX + custom layer)
- Modifying the original packed sample instead of working on a copy
- Not reconstructing imports after manual memory dump (the dumped binary will crash without IAT fix)
- Forgetting to check for overlay data appended after the UPX-packed PE sections
Output Format
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/analyzing-packed-malware-with-upx-unpacker/SKILL.md
Popularity
- Repository stars
- 72
- Repository forks
- 11
- 7-day trend score
- 21
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/costrict-plugins-repo/mukul975-anthropic-cybersecurity-skills-cybersecurity-skills/analyzing-packed-malware-with-upx-unpacker)