upx -d <packed_file> # Decompress/unpack
upx -d -o <output> <packed_file> # Unpack to new file
upx -t <file> # Test if packed
upx -l <file> # List compression info
upx --version # Version info
Output Format
File size Ratio Format Name
-------------------- ------ ----------- -----------
184320 <- 98304 53.33% win32/pe malware.exe
pefile - Python PE Analysis
Usage
import pefile
pe = pefile.PE("sample.exe")
# Section analysis
for section in pe.sections:
name = section.Name.rstrip(b"\x00").decode()
entropy = section.get_entropy()
print(f"{name}: entropy={entropy:.2f}")
# Import analysis
for entry in pe.DIRECTORY_ENTRY_IMPORT:
dll = entry.dll.decode()
for imp in entry.imports:
print(f"{dll}: {imp.name}")
pe.close()
1. Set breakpoint on VirtualAlloc / VirtualProtect
2. Run until breakpoint
3. Check memory map for new RWX regions
4. Step until original entry point (OEP) reached
5. Dump memory at OEP using Scylla plugin
6. Fix import table with Scylla