[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ESQ4Z4HSS07XBATG2KZFR3":3,"skill-same:01M6ESQ4Z4HSS07XBATG2KZFR3":98},{"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":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":14,"repositoryHtmlUrl":62,"repositoryHomepageUrl":63,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":65,"updatedAt":66,"install":67,"resources":80},"01M6ESQ4Z4HSS07XBATG2KZFR3","analyzing-packed-malware-with-upx-unpacker",null,"Identifies and unpacks UPX-packed and other packed malware samples to expose the original executable code for static analysis. Covers both standard UPX unpacking and handling modified UPX headers that prevent automated decompression. Activates for requests involving malware unpacking, UPX decompression, packer removal, or preparing packed samples for analysis.","henriquescastilho\u002Fmy-claude","henriquescastilho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F153296945?v=4","01M6ESH7EXPXTH9CVQ4K16SRG8","Henrique Scheer","01M6ESH7JHEK2PTNNH4HEH787Z",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-packed-malware-with-upx-unpacker\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"UPX","with","analyzing packed malware with upx unpacker","analyzing","malware","malware-analysis","static-analysis","unpacking","static analysis","packing","code","analysis","cm","id","de","packer","cybersecurity","2026-11-10 10:12:30",false,"---\nname: analyzing-packed-malware-with-upx-unpacker\ndescription: 'Identifies and unpacks UPX-packed and other packed malware samples to\n  expose the original executable code for static analysis. Covers both standard UPX\n  unpacking and handling modified UPX headers that prevent automated decompression.\n  Activates for requests involving malware unpacking, UPX decompression, packer removal,\n  or preparing packed samples for analysis.\n\n  '\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- malware\n- unpacking\n- UPX\n- packing\n- static-analysis\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.002\n- T1140\n- T1620\n---\n\n# Analyzing Packed Malware with UPX Unpacker\n\n## When to Use\n\n- Static analysis reveals high entropy sections and minimal imports indicating the binary is packed\n- PEiD, Detect It Easy, or PEStudio identifies UPX or another known packer\n- The import table contains only LoadLibrary and GetProcAddress (runtime import resolution typical of packed binaries)\n- You need to recover the original binary for proper disassembly and decompilation in Ghidra or IDA\n- Automated UPX decompression fails because the malware author modified UPX magic bytes or headers\n\n**Do not use** when dealing with custom packers, VM-based protectors (Themida, VMProtect), or samples where dynamic unpacking via debugging is more appropriate.\n\n## Prerequisites\n\n- UPX (Ultimate Packer for eXecutables) installed (`apt install upx-ucl` or download from https:\u002F\u002Fupx.github.io\u002F)\n- Detect It Easy (DIE) for packer identification\n- Python 3.8+ with `pefile` library for manual header repair\n- x64dbg or x32dbg for manual unpacking when automated tools fail\n- PE-bear or CFF Explorer for PE header inspection and repair\n- Isolated analysis VM without network connectivity\n\n## Workflow\n\n### Step 1: Identify the Packer\n\nDetermine if the sample is packed and identify the packer:\n\n```bash\n# Check with Detect It Easy\ndiec suspect.exe\n\n# Check with UPX (test without unpacking)\nupx -t suspect.exe\n\n# Python-based entropy and packer detection\npython3 \u003C\u003C 'PYEOF'\nimport pefile\nimport math\n\npe = pefile.PE(\"suspect.exe\")\n\nprint(\"Section Analysis:\")\nfor section in pe.sections:\n    name = section.Name.decode().rstrip('\\x00')\n    entropy = section.get_entropy()\n    raw = section.SizeOfRawData\n    virtual = section.Misc_VirtualSize\n    print(f\"  {name:8s} Entropy: {entropy:.2f}  Raw: {raw:>8}  Virtual: {virtual:>8}\")\n\n# Check for UPX section names\nsection_names = [s.Name.decode().rstrip('\\x00') for s in pe.sections]\nif 'UPX0' in section_names or 'UPX1' in section_names:\n    print(\"\\n[!] UPX section names detected\")\nelif '.upx' in [s.lower() for s in section_names]:\n    print(\"\\n[!] UPX variant section names detected\")\n\n# Check import count (packed binaries have very few)\nif hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n    total_imports = sum(len(e.imports) for e in pe.DIRECTORY_ENTRY_IMPORT)\n    print(f\"\\nTotal imports: {total_imports}\")\n    if total_imports \u003C 10:\n        print(\"[!] Very few imports - likely packed\")\nelse:\n    print(\"\\n[!] No import directory - heavily packed\")\nPYEOF\n```\n\n### Step 2: Attempt Standard UPX Decompression\n\nTry the built-in UPX decompression:\n\n```bash\n# Standard UPX decompress\nupx -d suspect.exe -o unpacked.exe\n\n# If UPX fails with \"not packed by UPX\" error, the headers may be modified\n# Verbose output for debugging\nupx -d suspect.exe -o unpacked.exe -v 2>&1\n\n# Verify the unpacked file\nfile unpacked.exe\ndiec unpacked.exe\n```\n\n### Step 3: Repair Modified UPX Headers\n\nIf standard decompression fails, repair tampered magic bytes:\n\n```python\n# Repair modified UPX headers\nimport struct\n\nwith open(\"suspect.exe\", \"rb\") as f:\n    data = bytearray(f.read())\n\n# UPX magic bytes: \"UPX!\" (0x55505821)\n# Malware authors commonly modify these to prevent automatic unpacking\n\n# Search for modified UPX signatures\nupx_magic = b\"UPX!\"\nmodified_patterns = [b\"UPX0\", b\"UPX\\x00\", b\"\\x00PX!\", b\"UPx!\"]\n\n# Find and restore section names\npe_offset = struct.unpack_from(\"\u003CI\", data, 0x3C)[0]\nnum_sections = struct.unpack_from(\"\u003CH\", data, pe_offset + 6)[0]\nsection_table_offset = pe_offset + 0x18 + struct.unpack_from(\"\u003CH\", data, pe_offset + 0x14)[0]\n\nprint(f\"PE offset: 0x{pe_offset:X}\")\nprint(f\"Number of sections: {num_sections}\")\nprint(f\"Section table offset: 0x{section_table_offset:X}\")\n\nfor i in range(num_sections):\n    offset = section_table_offset + (i * 40)\n    name = data[offset:offset+8]\n    print(f\"Section {i}: {name}\")\n\n# Restore UPX magic bytes in the binary\n# Search for the UPX header signature location (typically near the end of packed data)\nfor i in range(len(data) - 4):\n    if data[i:i+3] == b\"UPX\" and data[i+3] != ord(\"!\"):\n        print(f\"Found modified UPX magic at offset 0x{i:X}: {data[i:i+4]}\")\n        data[i:i+4] = b\"UPX!\"\n        print(f\"Restored to: UPX!\")\n\n# Also restore section names if modified\nfor i in range(num_sections):\n    offset = section_table_offset + (i * 40)\n    name = data[offset:offset+8].rstrip(b'\\x00')\n    if name in [b\"UPX0\", b\"UPX1\", b\"UPX2\"]:\n        continue  # Already correct\n    # Check for common modifications\n    if name.startswith(b\"UP\") or name.startswith(b\"ux\"):\n        original = f\"UPX{i}\".encode().ljust(8, b'\\x00')\n        data[offset:offset+8] = original\n        print(f\"Restored section name at 0x{offset:X} to {original}\")\n\nwith open(\"suspect_fixed.exe\", \"wb\") as f:\n    f.write(data)\n\nprint(\"\\nFixed file written. Retry: upx -d suspect_fixed.exe -o unpacked.exe\")\n```\n\n### Step 4: Manual Unpacking with Debugger\n\nWhen automated unpacking fails entirely, use dynamic unpacking:\n\n```\nManual UPX Unpacking with x64dbg:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n1. Load packed sample in x64dbg\n2. Run to the entry point (system breakpoint then F9)\n3. UPX unpacking stub pattern:\n   a. PUSHAD (saves all registers)\n   b. Decompression loop (processes packed sections)\n   c. Resolves imports (LoadLibrary\u002FGetProcAddress calls)\n   d. POPAD (restores registers)\n   e. JMP to OEP (original entry point)\n4. Set hardware breakpoint on ESP after PUSHAD:\n   - After PUSHAD, right-click ESP in registers -> Follow in Dump\n   - Set hardware breakpoint on access at [ESP] address\n   - Run (F9) - breaks at POPAD before JMP to OEP\n5. Step forward (F7\u002FF8) until you reach the JMP to OEP\n6. At OEP: Use Scylla plugin to dump and fix imports:\n   - Plugins -> Scylla -> OEP = current EIP\n   - Click \"IAT Autosearch\" -> \"Get Imports\"\n   - Click \"Dump\" to save unpacked binary\n   - Click \"Fix Dump\" to repair import table\n```\n\n### Step 5: Validate Unpacked Binary\n\nVerify the unpacked sample is valid and complete:\n\n```bash\n# Verify unpacked PE is valid\npython3 \u003C\u003C 'PYEOF'\nimport pefile\n\npe = pefile.PE(\"unpacked.exe\")\n\n# Check sections are normal\nprint(\"Unpacked Section Analysis:\")\nfor section in pe.sections:\n    name = section.Name.decode().rstrip('\\x00')\n    entropy = section.get_entropy()\n    print(f\"  {name:8s} Entropy: {entropy:.2f}\")\n\n# Verify imports are resolved\nprint(f\"\\nImport count:\")\nif hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n    for entry in pe.DIRECTORY_ENTRY_IMPORT:\n        dll = entry.dll.decode()\n        count = len(entry.imports)\n        print(f\"  {dll}: {count} functions\")\n    total = sum(len(e.imports) for e in pe.DIRECTORY_ENTRY_IMPORT)\n    print(f\"  Total: {total} imports\")\n\n# Compare file sizes\nimport os\npacked_size = os.path.getsize(\"suspect.exe\")\nunpacked_size = os.path.getsize(\"unpacked.exe\")\nprint(f\"\\nPacked:   {packed_size:>10} bytes\")\nprint(f\"Unpacked: {unpacked_size:>10} bytes\")\nprint(f\"Ratio:    {unpacked_size\u002Fpacked_size:.1f}x\")\nPYEOF\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **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 |\n| **UPX** | Ultimate Packer for eXecutables; open-source executable packer commonly abused by malware authors because it is free and effective |\n| **Original Entry Point (OEP)** | The real starting address of the malware code before packing; the unpacking stub decompresses code then jumps to the OEP |\n| **Import Reconstruction** | Process of rebuilding the import address table after dumping an unpacked process from memory using tools like Scylla or ImpRec |\n| **PUSHAD\u002FPOPAD** | x86 instructions that save\u002Frestore all general-purpose registers; UPX uses this pattern to preserve register state during unpacking |\n| **Section Entropy** | Randomness measure of PE section data; packed sections show entropy > 7.0 while normal code sections average 5.0-6.5 |\n| **Magic Bytes** | Signature bytes within a file identifying its format; UPX uses \"UPX!\" which malware authors modify to prevent automated decompression |\n\n## Tools & Systems\n\n- **UPX**: Open-source executable packer with built-in decompression capability for properly packed files\n- **Detect It Easy (DIE)**: Packer, compiler, and linker detection tool that identifies protection on PE, ELF, and Mach-O files\n- **x64dbg\u002Fx32dbg**: Open-source Windows debugger used for manual unpacking through dynamic execution and breakpoint-based OEP finding\n- **Scylla**: Import reconstruction tool integrated with x64dbg for rebuilding IAT after memory dumping\n- **PE-bear**: PE file viewer and editor for inspecting and repairing PE headers after unpacking\n\n## Common Scenarios\n\n### Scenario: Unpacking Malware with Modified UPX Headers\n\n**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.\n\n**Approach**:\n1. Open the binary in a hex editor and search for the UPX header area (typically at the end of packed data)\n2. Identify the modified magic bytes (e.g., \"UPX!\" changed to \"UPX\\x00\" or completely zeroed)\n3. Use the Python repair script to restore \"UPX!\" magic and correct section names\n4. Retry `upx -d` on the repaired binary\n5. If repair fails, fall back to manual unpacking with x64dbg (PUSHAD -> hardware BP on ESP -> POPAD -> JMP OEP)\n6. Validate the unpacked binary has proper imports and reasonable entropy values\n7. Import into Ghidra or IDA for full static analysis\n\n**Pitfalls**:\n- Assuming UPX is the only packer; the binary may be double-packed (UPX + custom layer)\n- Modifying the original packed sample instead of working on a copy\n- Not reconstructing imports after manual memory dump (the dumped binary will crash without IAT fix)\n- Forgetting to check for overlay data appended after the UPX-packed PE sections\n\n## Output Format\n\n```\nUNPACKING ANALYSIS REPORT\n===========================\nSample:           suspect.exe\nSHA-256:          e3b0c44298fc1c149afbf4c8996fb924...\nPacker:           UPX 3.96 (modified headers)\n\nPACKED BINARY\nSections:         UPX0 (entropy: 0.00) UPX1 (entropy: 7.89) .rsrc (entropy: 3.45)\nImports:          2 (kernel32.dll: LoadLibraryA, GetProcAddress)\nFile Size:        98,304 bytes\n\nUNPACKING METHOD\nMethod:           Header repair + UPX -d\nHeader Fix:       Restored UPX! magic at offset 0x1F000\nCommand:          upx -d suspect_fixed.exe -o unpacked.exe\nResult:           SUCCESS\n\nUNPACKED BINARY\nSections:         .text (entropy: 6.21) .rdata (entropy: 4.56) .data (entropy: 3.12) .rsrc (entropy: 3.45)\nImports:          147 (kernel32, user32, advapi32, wininet, ws2_32)\nFile Size:        245,760 bytes (2.5x expansion)\nOEP:              0x00401000\n\nVALIDATION\nPE Valid:         Yes\nImports Resolved: Yes (147 functions across 8 DLLs)\nExecutable:       Yes (runs without crash in sandbox)\n\nNEXT STEPS\n- Import unpacked.exe into Ghidra for full disassembly\n- Run YARA rules against unpacked binary\n- Submit unpacked binary to VirusTotal for improved detection\n```\n","# Analyzing Packed Malware with UPX Unpacker\n\n## When to Use\n\n- Static analysis reveals high entropy sections and minimal imports indicating the binary is packed\n- PEiD, Detect It Easy, or PEStudio identifies UPX or another known packer\n- The import table contains only LoadLibrary and GetProcAddress (runtime import resolution typical of packed binaries)\n- You need to recover the original binary for proper disassembly and decompilation in Ghidra or IDA\n- Automated UPX decompression fails because the malware author modified UPX magic bytes or headers\n\n**Do not use** when dealing with custom packers, VM-based protectors (Themida, VMProtect), or samples where dynamic unpacking via debugging is more appropriate.\n\n## Prerequisites\n\n- UPX (Ultimate Packer for eXecutables) installed (`apt install upx-ucl` or download from https:\u002F\u002Fupx.github.io\u002F)\n- Detect It Easy (DIE) for packer identification\n- Python 3.8+ with `pefile` library for manual header repair\n- x64dbg or x32dbg for manual unpacking when automated tools fail\n- PE-bear or CFF Explorer for PE header inspection and repair\n- Isolated analysis VM without network connectivity\n\n## Workflow\n\n### Step 1: Identify the Packer\n\nDetermine if the sample is packed and identify the packer:\n\n```bash\n# Check with Detect It Easy\ndiec suspect.exe\n\n# Check with UPX (test without unpacking)\nupx -t suspect.exe\n\n# Python-based entropy and packer detection\npython3 \u003C\u003C 'PYEOF'\nimport pefile\nimport math\n\npe = pefile.PE(\"suspect.exe\")\n\nprint(\"Section Analysis:\")\nfor section in pe.sections:\n    name = section.Name.decode().rstrip('\\x00')\n    entropy = section.get_entropy()\n    raw = section.SizeOfRawData\n    virtual = section.Misc_VirtualSize\n    print(f\"  {name:8s} Entropy: {entropy:.2f}  Raw: {raw:>8}  Virtual: {virtual:>8}\")\n\n# Check for UPX section names\nsection_names = [s.Name.decode().rstrip('\\x00') for s in pe.sections]\nif 'UPX0' in section_names or 'UPX1' in section_names:\n    print(\"\\n[!] UPX section names detected\")\nelif '.upx' in [s.lower() for s in section_names]:\n    print(\"\\n[!] UPX variant section names detected\")\n\n# Check import count (packed binaries have very few)\nif hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n    total_imports = sum(len(e.imports) for e in pe.DIRECTORY_ENTRY_IMPORT)\n    print(f\"\\nTotal imports: {total_imports}\")\n    if total_imports \u003C 10:\n        print(\"[!] Very few imports - likely packed\")\nelse:\n    print(\"\\n[!] No import directory - heavily packed\")\nPYEOF\n```\n\n### Step 2: Attempt Standard UPX Decompression\n\nTry the built-in UPX decompression:\n\n```bash\n# Standard UPX decompress\nupx -d suspect.exe -o unpacked.exe\n\n# If UPX fails with \"not packed by UPX\" error, the headers may be modified\n# Verbose output for debugging\nupx -d suspect.exe -o unpacked.exe -v 2>&1\n\n# Verify the unpacked file\nfile unpacked.exe\ndiec unpacked.exe\n```\n\n### Step 3: Repair Modified UPX Headers\n\nIf standard decompression fails, repair tampered magic bytes:\n\n```python\n# Repair modified UPX headers\nimport struct\n\nwith open(\"suspect.exe\", \"rb\") as f:\n    data = bytearray(f.read())\n\n# UPX magic bytes: \"UPX!\" (0x55505821)\n# Malware authors commonly modify these to prevent automatic unpacking\n\n# Search for modified UPX signatures\nupx_magic = b\"UPX!\"\nmodified_patterns = [b\"UPX0\", b\"UPX\\x00\", b\"\\x00PX!\", b\"UPx!\"]\n\n# Find and restore section names\npe_offset = struct.unpack_from(\"\u003CI\", data, 0x3C)[0]\nnum_sections = struct.unpack_from(\"\u003CH\", data, pe_offset + 6)[0]\nsection_table_offset = pe_offset + 0x18 + struct.unpack_from(\"\u003CH\", data, pe_offset + 0x14)[0]\n\nprint(f\"PE offset: 0x{pe_offset:X}\")\nprint(f\"Number of sections: {num_sections}\")\nprint(f\"Section table offset: 0x{section_table_offset:X}\")\n\nfor i in range(num_sections):\n    offset = section_table_offset + (i * 40)\n    name = data[offset:offset+8]\n    print(f\"Section {i}: {name}\")\n\n# Restore UPX magic bytes in the binary\n# Search for the UPX header signature location (typically near the end of packed data)\nfor i in range(len(data) - 4):\n    if data[i:i+3] == b\"UPX\" and data[i+3] != ord(\"!\"):\n        print(f\"Found modified UPX magic at offset 0x{i:X}: {data[i:i+4]}\")\n        data[i:i+4] = b\"UPX!\"\n        print(f\"Restored to: UPX!\")\n\n# Also restore section names if modified\nfor i in range(num_sections):\n    offset = section_table_offset + (i * 40)\n    name = data[offset:offset+8].rstrip(b'\\x00')\n    if name in [b\"UPX0\", b\"UPX1\", b\"UPX2\"]:\n        continue  # Already correct\n    # Check for common modifications\n    if name.startswith(b\"UP\") or name.startswith(b\"ux\"):\n        original = f\"UPX{i}\".encode().ljust(8, b'\\x00')\n        data[offset:offset+8] = original\n        print(f\"Restored section name at 0x{offset:X} to {original}\")\n\nwith open(\"suspect_fixed.exe\", \"wb\") as f:\n    f.write(data)\n\nprint(\"\\nFixed file written. Retry: upx -d suspect_fixed.exe -o unpacked.exe\")\n```\n\n### Step 4: Manual Unpacking with Debugger\n\nWhen automated unpacking fails entirely, use dynamic unpacking:\n\n```\nManual UPX Unpacking with x64dbg:\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n1. Load packed sample in x64dbg\n2. Run to the entry point (system breakpoint then F9)\n3. UPX unpacking stub pattern:\n   a. PUSHAD (saves all registers)\n   b. Decompression loop (processes packed sections)\n   c. Resolves imports (LoadLibrary\u002FGetProcAddress calls)\n   d. POPAD (restores registers)\n   e. JMP to OEP (original entry point)\n4. Set hardware breakpoint on ESP after PUSHAD:\n   - After PUSHAD, right-click ESP in registers -> Follow in Dump\n   - Set hardware breakpoint on access at [ESP] address\n   - Run (F9) - breaks at POPAD before JMP to OEP\n5. Step forward (F7\u002FF8) until you reach the JMP to OEP\n6. At OEP: Use Scylla plugin to dump and fix imports:\n   - Plugins -> Scylla -> OEP = current EIP\n   - Click \"IAT Autosearch\" -> \"Get Imports\"\n   - Click \"Dump\" to save unpacked binary\n   - Click \"Fix Dump\" to repair import table\n```\n\n### Step 5: Validate Unpacked Binary\n\nVerify the unpacked sample is valid and complete:\n\n```bash\n# Verify unpacked PE is valid\npython3 \u003C\u003C 'PYEOF'\nimport pefile\n\npe = pefile.PE(\"unpacked.exe\")\n\n# Check sections are normal\nprint(\"Unpacked Section Analysis:\")\nfor section in pe.sections:\n    name = section.Name.decode().rstrip('\\x00')\n    entropy = section.get_entropy()\n    print(f\"  {name:8s} Entropy: {entropy:.2f}\")\n\n# Verify imports are resolved\nprint(f\"\\nImport count:\")\nif hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):\n    for entry in pe.DIRECTORY_ENTRY_IMPORT:\n        dll = entry.dll.decode()\n        count = len(entry.imports)\n        print(f\"  {dll}: {count} functions\")\n    total = sum(len(e.imports) for e in pe.DIRECTORY_ENTRY_IMPORT)\n    print(f\"  Total: {total} imports\")\n\n# Compare file sizes\nimport os\npacked_size = os.path.getsize(\"suspect.exe\")\nunpacked_size = os.path.getsize(\"unpacked.exe\")\nprint(f\"\\nPacked:   {packed_size:>10} bytes\")\nprint(f\"Unpacked: {unpacked_size:>10} bytes\")\nprint(f\"Ratio:    {unpacked_size\u002Fpacked_size:.1f}x\")\nPYEOF\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **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 |\n| **UPX** | Ultimate Packer for eXecutables; open-source executable packer commonly abused by malware authors because it is free and effective |\n| **Original Entry Point (OEP)** | The real starting address of the malware code before packing; the unpacking stub decompresses code then jumps to the OEP |\n| **Import Reconstruction** | Process of rebuilding the import address table after dumping an unpacked process from memory using tools like Scylla or ImpRec |\n| **PUSHAD\u002FPOPAD** | x86 instructions that save\u002Frestore all general-purpose registers; UPX uses this pattern to preserve register state during unpacking |\n| **Section Entropy** | Randomness measure of PE section data; packed sections show entropy > 7.0 while normal code sections average 5.0-6.5 |\n| **Magic Bytes** | Signature bytes within a file identifying its format; UPX uses \"UPX!\" which malware authors modify to prevent automated decompression |\n\n## Tools & Systems\n\n- **UPX**: Open-source executable packer with built-in decompression capability for properly packed files\n- **Detect It Easy (DIE)**: Packer, compiler, and linker detection tool that identifies protection on PE, ELF, and Mach-O files\n- **x64dbg\u002Fx32dbg**: Open-source Windows debugger used for manual unpacking through dynamic execution and breakpoint-based OEP finding\n- **Scylla**: Import reconstruction tool integrated with x64dbg for rebuilding IAT after memory dumping\n- **PE-bear**: PE file viewer and editor for inspecting and repairing PE headers after unpacking\n\n## Common Scenarios\n\n### Scenario: Unpacking Malware with Modified UPX Headers\n\n**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.\n\n**Approach**:\n1. Open the binary in a hex editor and search for the UPX header area (typically at the end of packed data)\n2. Identify the modified magic bytes (e.g., \"UPX!\" changed to \"UPX\\x00\" or completely zeroed)\n3. Use the Python repair script to restore \"UPX!\" magic and correct section names\n4. Retry `upx -d` on the repaired binary\n5. If repair fails, fall back to manual unpacking with x64dbg (PUSHAD -> hardware BP on ESP -> POPAD -> JMP OEP)\n6. Validate the unpacked binary has proper imports and reasonable entropy values\n7. Import into Ghidra or IDA for full static analysis\n\n**Pitfalls**:\n- Assuming UPX is the only packer; the binary may be double-packed (UPX + custom layer)\n- Modifying the original packed sample instead of working on a copy\n- Not reconstructing imports after manual memory dump (the dumped binary will crash without IAT fix)\n- Forgetting to check for overlay data appended after the UPX-packed PE sections\n\n## Output Format\n\n```\nUNPACKING ANALYSIS REPORT\n===========================\nSample:           suspect.exe\nSHA-256:          e3b0c44298fc1c149afbf4c8996fb924...\nPacker:           UPX 3.96 (modified headers)\n\nPACKED BINARY\nSections:         UPX0 (entropy: 0.00) UPX1 (entropy: 7.89) .rsrc (entropy: 3.45)\nImports:          2 (kernel32.dll: LoadLibraryA, GetProcAddress)\nFile Size:        98,304 bytes\n\nUNPACKING METHOD\nMethod:           Header repair + UPX -d\nHeader Fix:       Restored UPX! magic at offset 0x1F000\nCommand:          upx -d suspect_fixed.exe -o unpacked.exe\nResult:           SUCCESS\n\nUNPACKED BINARY\nSections:         .text (entropy: 6.21) .rdata (entropy: 4.56) .data (entropy: 3.12) .rsrc (entropy: 3.45)\nImports:          147 (kernel32, user32, advapi32, wininet, ws2_32)\nFile Size:        245,760 bytes (2.5x expansion)\nOEP:              0x00401000\n\nVALIDATION\nPE Valid:         Yes\nImports Resolved: Yes (147 functions across 8 DLLs)\nExecutable:       Yes (runs without crash in sandbox)\n\nNEXT STEPS\n- Import unpacked.exe into Ghidra for full disassembly\n- Run YARA rules against unpacked binary\n- Submit unpacked binary to VirusTotal for improved detection\n```\n",{"name":5,"tags":46,"author":47,"domain":40,"license":15,"version":48,"nist_csf":49,"subdomain":29,"description":54,"mitre_attack":55},[28,31,24,33,30],"mahipal","1.0.0",[50,51,52,53],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","Identifies and unpacks UPX-packed and other packed malware samples to expose the original executable code for static analysis. Covers both standard UPX unpacking and handling modified UPX headers that prevent automated decompression. Activates for requests involving malware unpacking, UPX decompression, packer removal, or preparing packed samples for analysis.\n",[56,57,58],"T1027.002","T1140","T1620","main","7925716f065257435fdb12e97f7e52842147d5ad",".claude\u002Fskills\u002Fanalyzing-packed-malware-with-upx-unpacker","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude","https:\u002F\u002Fclaude.com\u002Fclaude-code","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho","Software · Applied AI · Quantitative Modeling · Building with Claude.","2026-06-10 12:24:46",{"source":8,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add henriquescastilho\u002Fmy-claude --skill analyzing-packed-malware-with-upx-unpacker",{"tool":73,"command":74},"bunx","bunx skills add henriquescastilho\u002Fmy-claude --skill analyzing-packed-malware-with-upx-unpacker",{"tool":76,"command":77},"pnpm","pnpm dlx skills add henriquescastilho\u002Fmy-claude --skill analyzing-packed-malware-with-upx-unpacker","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-packed-malware-with-upx-unpacker\u002FSKILL.md",true,[81,86,92],{"path":82,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-packed-malware-with-upx-unpacker\u002FLICENSE",{"path":87,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fapi-reference.md","REFERENCE","参考文档",3143,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-packed-malware-with-upx-unpacker\u002Freferences\u002Fapi-reference.md",{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"scripts\u002Fagent.py","SCRIPT","脚本",8699,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-packed-malware-with-upx-unpacker\u002Fscripts\u002Fagent.py",[99,139,148,157,179,204],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":103,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":120,"publishedAt":41},"01M6F0B6XPQ65AX2X0DWK8KT3E","markitdown","Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.","MIT","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[106,109,112,115],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":110,"categoryName":111,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":113,"categoryName":114,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000004","电子表格",{"categoryNo":116,"categoryName":117,"taxonomyType":118,"taxonomyTypeDesc":119},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[101,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,25],"docx","PDF","pptx","xlsx","documents","csv","ocr","Audio","Bash","markdown","convert","read","write","edit","html","images","files","youtube",{"skillNo":140,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":103,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":147,"publishedAt":41},"01M6F06SBHR9F0SDWE282Y8075","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fscientific_writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[143,144,145,146],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":110,"categoryName":111,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":113,"categoryName":114,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":116,"categoryName":117,"taxonomyType":118,"taxonomyTypeDesc":119},[101,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,25],{"skillNo":149,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":103,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":156,"publishedAt":41},"01M6F02D4R14EJAPBWVDF9J9VQ","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[152,153,154,155],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":110,"categoryName":111,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":113,"categoryName":114,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":116,"categoryName":117,"taxonomyType":118,"taxonomyTypeDesc":119},[101,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,25],{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":103,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":41},"01M6F000KS6YB4MKS774G4R8ND","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fzarr-python\u002FSKILL.md",[],[164,165,166,167,168,169,170,171,172,173,174,175,176,177,178],"python","zarr python","storage","integration","s3","gcs","cloud","dask","parallel","pipelines","arrays","numpy","scientific computing","scale","scientific",{"skillNo":180,"name":181,"nameZh":6,"description":182,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":103,"licenseFileUrl":6,"sourceHtmlUrl":183,"categories":184,"keywords":186,"publishedAt":41},"01M6EZZJWFXM1GR78KTW6J0DN8","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fwhat-if-oracle\u002FSKILL.md",[185],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[187,188,189,190,191,192,35,193,194,195,196,132,133,197,198,199,200,201,202,203],"oracle","what if oracle","go","run","ux","futures","explore","decision","branch","question","idea","exploration","options","stress-test","strategies","scenario","stress",{"skillNo":205,"name":206,"nameZh":6,"description":207,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":103,"licenseFileUrl":6,"sourceHtmlUrl":208,"categories":209,"keywords":220,"publishedAt":41},"01M6EZZCXAEB49RXGQCJX5E8GB","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fvenue-templates\u002FSKILL.md",[210,213,216,217],{"categoryNo":211,"categoryName":212,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":214,"categoryName":215,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":218,"categoryName":219,"taxonomyType":118,"taxonomyTypeDesc":119},"01JBSEEDCAT000000000000036","内容创作者",[221,222,223,224,225,226,227,228,129,229,132,133,134,230,231,232,233,234,178,235],"templates","venue templates","research","guidelines","NeurIPS","ICML","LaTeX","science","access","proposals","Academic","requirements","formatting","journal","chi"]