1---2name: analyzing-malicious-pdf-with-peepdf3description: Perform static analysis of malicious PDF documents using peepdf, pdfid, and pdf-parser to extract embedded JavaScript, shellcode, and suspicious objects.4domain: cybersecurity5subdomain: malware-analysis6tags: [malware-analysis, pdf, peepdf, pdfid, pdf-parser, static-analysis, reverse-engineering, dfir]7version: "1.0"8author: mahipal9license: Apache-2.010metadata:11 source: https://skillmd.com/skills/micsapp/analyzing-malicious-pdf-with-peepdf12---1314# Analyzing Malicious PDF with peepdf1516## When to Use1718- When triaging suspicious PDF attachments from phishing emails19- During malware analysis of PDF-based exploit documents20- When extracting embedded JavaScript, shellcode, or executables from PDFs21- For forensic examination of weaponized document artifacts22- When building detection signatures for PDF-based threats2324## Prerequisites2526- Python 3.8+ with peepdf-3 installed (pip install peepdf-3)27- pdfid.py and pdf-parser.py from Didier Stevens suite28- Isolated analysis environment (VM or sandbox)29- Optional: PyV8 for JavaScript emulation within peepdf30- Optional: Pylibemu for shellcode analysis3132## Workflow33341. **Triage with pdfid**: Scan PDF for suspicious keywords (/JS, /JavaScript, /OpenAction, /Launch, /EmbeddedFile).352. **Interactive Analysis**: Open PDF in peepdf interactive mode to explore object structure.363. **Identify Suspicious Objects**: Locate objects containing JavaScript, streams, or encoded data.374. **Extract Content**: Dump suspicious streams and decode filters (FlateDecode, ASCIIHexDecode).385. **Deobfuscate JavaScript**: Analyze extracted JS for shellcode, heap sprays, or exploit code.396. **Check VirusTotal**: Use peepdf vtcheck to cross-reference file hash with AV detections.407. **Generate IOCs**: Extract URLs, domains, hashes, and shellcode signatures.4142## Key Concepts4344| Concept | Description |45|---------|-------------|46| /OpenAction | Automatic action executed when PDF is opened |47| /JavaScript /JS | Embedded JavaScript code in PDF objects |48| /Launch | Action that launches external applications |49| /EmbeddedFile | File embedded within the PDF structure |50| FlateDecode | zlib compression filter used to hide content |51| Object Streams | PDF objects stored in compressed streams |5253## Tools & Systems5455| Tool | Purpose |56|------|---------|57| peepdf / peepdf-3 | Interactive PDF analysis with JS emulation |58| pdfid.py | Quick triage scanning for suspicious keywords |59| pdf-parser.py | Deep object-level PDF parsing |60| VirusTotal | Hash lookup and AV detection cross-reference |61| CyberChef | Decode and transform extracted payloads |6263## Output Format6465```66Analysis Report: PDF-MAL-[DATE]-[SEQ]67File: [filename.pdf]68SHA-256: [hash]69Suspicious Keywords: [/JS, /OpenAction, etc.]70Objects with JavaScript: [Object IDs]71Extracted URLs: [List]72Shellcode Detected: [Yes/No]73Embedded Files: [Count and types]74VirusTotal Detections: [X/Y engines]75Risk Level: [Critical/High/Medium/Low]76```