콘텐츠로 이동

readpe (pev)

readpe (part of the pev toolkit) is a comprehensive portable executable (PE) file analyzer that runs on Linux, macOS, and Windows. It provides detailed inspection of Windows binary files including headers, sections, imports, exports, resources, and digital signatures. Essential for malware analysis, reverse engineering, and vulnerability assessment.

sudo apt-get update
sudo apt-get install pev
brew install pev
git clone https://github.com/merces/pev.git
cd pev
make
sudo make install
readpe --version
pev --version
readpe -h
readpe [options] <file>
readpe -h          # Help
readpe -v          # Version
readpe --all <file> # All information
CommandPurpose
readpe file.exeDisplay basic PE information
readpe --all file.exeShow all available information
readpe -H file.exeDisplay PE headers only
readpe -S file.exeList all sections
readpe -i file.exeShow imported functions
readpe -e file.exeShow exported functions
readpe -r file.exeDisplay resources section
readpe -d file.exeShow data directories
readpe --resources file.exeExtract and analyze resources
readpe --version file.exeDisplay version information
readpe -H file.exe | head -20
readpe file.exe | grep -i "signature\|subsystem\|machine"
readpe -H file.exe | grep -A 30 "Optional Header"
readpe file.exe | grep -i "machine type"
# Output: i386 (x86), x86-64, ARM, etc.
readpe -S file.exe
readpe file.exe | grep -A 100 "Sections"
readpe -S file.exe | grep -E "\.reloc|\.rsrc|\.text"
readpe file.exe | grep -i "entropy"
readpe -i file.exe
readpe file.exe | grep "DLL"
readpe -i file.exe | head -50
readpe -i file.exe | grep -i "createprocess\|shellexecute\|winexec"
readpe -e file.exe
readpe -e file.exe | wc -l
readpe file.exe | grep -A 50 "Export Table"
readpe -r file.exe
readpe --resources file.exe
strings file.exe | head -50
readpe -r file.exe | grep -i "string\|icon\|dialog"
readpe file.exe | grep -A 20 "Resources"
readpe file.exe | grep -i "signature\|cert\|sign"
readpe --version file.exe
readpe file.exe | grep -i "version info"
readpe file.exe | grep -E "Company|Product|File Version|Legal"
for file in *.exe; do echo "=== $file ==="; readpe "$file"; done
find . -type f \( -name "*.exe" -o -name "*.dll" -o -name "*.sys" \)
for file in *.exe; do readpe -H "$file" | head -5; done
for file in *.exe; do 
  echo "File: $file" >> report.txt
  readpe --all "$file" >> report.txt
  echo "---" >> report.txt
done
readpe file.exe | grep -E "Machine|Subsystem|Entry Point|Size"
readpe -i file.exe | grep -iE "createprocess|shellexecute|winexec|loadlibrary"
readpe -S file.exe | grep -E "\.text|\.data|\.reloc|entropy"
readpe -i malware.exe | grep -iE "createremotethread|virtualalloc|writeprocessmemory|createprocess|createservice|regsetvalue"
# High entropy (.text < 7.0, .data < 7.5 normal; > 7.8 suspicious)
readpe file.exe | grep -i "entropy"
readpe -r file.exe | grep -iE "dropped|embedded|payload"
strings file.exe | grep -iE "cmd.exe|powershell|regsvcs|rundll32"
readpe file1.exe > analysis1.txt
readpe file2.exe > analysis2.txt
diff analysis1.txt analysis2.txt
readpe --all file.exe | grep -E "^Section:|^Machine|^SubSystem"
readpe --json file.exe > output.json
#!/bin/bash
for file in *.exe; do
  echo "$file:"
  readpe "$file" | grep -i "entropy" || echo "No entropy data"
done
# Packed files often have high entropy, small .text, large .data
readpe file.exe | grep -E "entropy|Section:" | head -20
# Look for sections with unusual characteristics
readpe -S file.exe | awk '{print $1, $5, $6}'
readpe --version file.exe | grep -i "product\|company\|file version"
strings file.exe | grep -iE "microsoft|borland|watcom|visual"
readpe file.exe | grep -i "machine type"
# i386 = 32-bit, x86-64 = 64-bit
  • e_lfanew: Offset to PE header (typically 0x40 or 0x80)
  • Magic: 0x5A4D (MZ in ASCII) indicates valid DOS header
  • Machine: Processor architecture (i386, x86-64, ARM)
  • NumberOfSections: Count of sections in binary
  • TimeDateStamp: Compilation timestamp (may be spoofed)
  • EntryPoint: Where execution begins
  • .text: Executable code section
  • .data: Initialized data
  • .rsrc: Resources (icons, dialogs, strings)
  • .reloc: Base relocations (for ASLR)
readpe --all file.exe > malware_analysis.txt
readpe file.exe | grep "Imported DLL" > imports.txt
readpe file.exe | grep "Exported Function" > exports.txt
readpe file.exe | head -50
strings file.exe | tail -50
file file.exe
file file.exe
# Check if actually a PE file
readpe file.exe
# readpe will report header errors
readpe file.exe 2>&1 | grep -i "error\|invalid"
# Ensure pev is properly installed
which readpe
readpe --version
  1. Always verify file type before analysis - Use file command first
  2. Cross-reference with multiple tools - Compare readpe output with objdump, strings
  3. Document suspicious patterns - Note high entropy, unusual imports, resource anomalies
  4. Check digital signatures - Validate authenticode certificates for legitimacy
  5. Baseline normal binaries - Compare malware against clean system DLLs
  6. Monitor import patterns - Focus on process injection, registry modification APIs
  7. Automate recurring tasks - Script batch analysis for threat hunting
  8. Preserve evidence - Keep original file copies during analysis
readpe ransomware.exe | grep -iE "company|product|file version"
readpe -i ransomware.exe | grep -iE "cryptencrypt|crypthash|regsetvalue"
readpe malware.exe | grep -iE "regcreatekeyex|regsetvalueex|createservice"
readpe legitimate_signed.exe | grep -i "signature\|version\|company"
readpe -i legitimate_signed.exe | wc -l  # Compare import count