मुख्य सामग्री पर जाएँ
Skillpedia
एनालिसिस और स्प्रेडशीट35k · #7642

analyzing-packed-malware-with-upx-unpacker

यह क्या करती है

यह टूल उन प्रोग्राम्स को खोलने (unpack) में मदद करता है जिन्हें UPX नाम के टूल से 'pack' किया गया है। यह तब काम आता है जब कोई खतरनाक सॉफ़्टवेयर (वायरस) छिपा हुआ हो और उसका असली कोड देखकर उसका विश्लेषण करना ज़रूरी हो।

कब इस्तेमाल करें

  • ✓जब कोई प्रोग्राम संदिग्ध लगे और उसमें दिखाने लायक जानकारी कम हो।
  • ✓जब दूसरे टूल बताएं कि प्रोग्राम UPX से 'pack' किया गया है।
  • ✓जब सुरक्षा के लिए किसी प्रोग्राम का असली कोड देखना हो।

Skill का लिंक

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-packed-malware-with-upx-unpacker/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-packed-malware-with-upx-unpacker/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“इस संदिग्ध फ़ाइल को unpack करो ताकि मैं उसका विश्लेषण कर सकूँ।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

टूल UPX से फ़ाइल को unpack करने की कोशिश करता है। अगर 'packer' में बदलाव होने की वजह से यह नहीं हो पाता, तो यह बदले हुए हिस्सों को ठीक करता है और फिर से unpack करने की कोशिश करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

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-ucl or download from https://upx.github.io/)
  • Detect It Easy (DIE) for packer identification
  • Python 3.8+ with pefile library 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:

# Check with Detect It Easy
diec suspect.exe

# Check with UPX (test without unpacking)
upx -t suspect.exe

# Python-based entropy and packer detection
python3 << 'PYEOF'
import pefile
import math

pe = pefile.PE("suspect.exe")

print("Section Analysis:")
for section in pe.sections:
    name = section.Name.decode().rstrip('\x00')
    entropy = section.get_entropy()
    raw = section.SizeOfRawData
    virtual = section.Misc_VirtualSize
    print(f"  {name:8s} Entropy: {entropy:.2f}  Raw: {raw:>8}  Virtual: {virtual:>8}")

# Check for UPX section names
section_names = [s.Name.decode().rstrip('\x00') for s in pe.sections]
if 'UPX0' in section_names or 'UPX1' in section_names:
    print("\n[!] UPX section names detected")
elif '.upx' in [s.lower() for s in section_names]:
    print("\n[!] UPX variant section names detected")

# Check import count (packed binaries have very few)
if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):
    total_imports = sum(len(e.imports) for e in pe.DIRECTORY_ENTRY_IMPORT)
    print(f"\nTotal imports: {total_imports}")
    if total_imports < 10:
        print("[!] Very few imports - likely packed")
else:
    print("\n[!] No import directory - heavily packed")
PYEOF

Step 2: Attempt Standard UPX Decompression

Try the built-in UPX decompression:

# Standard UPX decompress
upx -d suspect.exe -o unpacked.exe

# If UPX fails with "not packed by UPX" error, the headers may be modified
# Verbose output for debugging
upx -d suspect.exe -o unpacked.exe -v 2>&1

# Verify the unpacked file
file unpacked.exe
diec unpacked.exe

Step 3: Repair Modified UPX Headers

If standard decompression fails, repair tampered magic bytes:

# Repair modified UPX headers
import struct

with open("suspect.exe", "rb") as f:
    data = bytearray(f.read())

# UPX magic bytes: "UPX!" (0x55505821)
# Malware authors commonly modify these to prevent automatic unpacking

# Search for modified UPX signatures
upx_magic = b"UPX!"
modified_patterns = [b"UPX0", b"UPX\x00", b"\x00PX!", b"UPx!"]

# Find and restore section names
pe_offset = struct.unpack_from("<I", data, 0x3C)[0]
num_sections = struct.unpack_from("<H", data, pe_offset + 6)[0]
section_table_offset = pe_offset + 0x18 + struct.unpack_from("<H", data, pe_offset + 0x14)[0]

print(f"PE offset: 0x{pe_offset:X}")
print(f"Number of sections: {num_sections}")
print(f"Section table offset: 0x{section_table_offset:X}")

for i in range(num_sections):
    offset = section_table_offset + (i * 40)
    name = data[offset:offset+8]
    print(f"Section {i}: {name}")

# Restore UPX magic bytes in the binary
# Search for the UPX header signature location (typically near the end of packed data)
for i in range(len(data) - 4):
    if data[i:i+3] == b"UPX" and data[i+3] != ord("!"):
        print(f"Found modified UPX magic at offset 0x{i:X}: {data[i:i+4]}")
        data[i:i+4] = b"UPX!"
        print(f"Restored to: UPX!")

# Also restore section names if modified
for i in range(num_sections):
    offset = section_table_offset + (i * 40)
    name = data[offset:offset+8].rstrip(b'\x00')
    if name in [b"UPX0", b"UPX1", b"UPX2"]:
        continue  # Already correct
    # Check for common modifications

…
अक्सर पूछे जाने वाले सवाल

किसी प्रोग्राम को 'pack' करने का क्या मतलब है?

यह ऐसा है जैसे किसी प्रोग्राम को एक खास डिब्बे में बंद कर देना, ताकि वह छोटा हो जाए या उसे समझना मुश्किल हो। UPX इसके लिए एक आम टूल है।

खतरनाक सॉफ़्टवेयर को unpack क्यों करें?

ताकि सुरक्षा विशेषज्ञ उसका असली कोड देख सकें, समझ सकें कि वह कैसे काम करता है, कितना नुकसान कर सकता है और उससे कैसे बचा जाए।

modified 'magic bytes' क्या होते हैं?

ये फ़ाइल की शुरुआत में लिखे खास कोड होते हैं जिनसे पता चलता है कि किस 'packer' का इस्तेमाल हुआ है। अगर ये बदल दिए जाएं, तो सामान्य टूल फ़ाइल को UPX से pack हुआ नहीं पहचान पाते।

जानकारी

लेखक का मूल विवरण

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. '

repo: mukul975/Anthropic-Cybersecurity-Skills

लोकप्रियता

GitHub स्टार
35k
रैंकिंग में स्थान
#7642
लाइसेंस
Apache-2.0
अपडेट की गई
31/8/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills