analyzing-malicious-pdf-with-peepdf skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Perform static analysis of malicious PDF documents using peepdf, pdfid, Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/analyzing-malicious-pdf-with-peepdf/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-malicious-pdf-with-peepdf, or copy the skill folder into ~/.claude/skills/analyzing-malicious-pdf-with-peepdf/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/analyzing-malicious-pdf-with-peepdf/SKILL.md

SKILL.md (verbatim)

name: analyzing-malicious-pdf-with-peepdf
description: Perform static analysis of malicious PDF documents using peepdf, pdfid,
  and pdf-parser to extract embedded JavaScript, shellcode, and suspicious objects.
  Use when triaging a suspicious PDF attachment from a phishing email, analyzing a
  PDF-based exploit document, or building detection signatures for weaponized PDF
  threats.
domain: cybersecurity
subdomain: malware-analysis
tags:
- malware-analysis
- pdf
- peepdf
- pdfid
- pdf-parser
- static-analysis
- reverse-engineering
- dfir
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- DE.AE-02
- RS.AN-03
- ID.RA-01
- DE.CM-01
mitre_attack:
- T1204.002
- T1059.007
- T1027
- T1106

Analyzing Malicious PDF with peepdf

When to Use

  • When triaging suspicious PDF attachments from phishing emails
  • During malware analysis of PDF-based exploit documents
  • When extracting embedded JavaScript, shellcode, or executables from PDFs
  • For forensic examination of weaponized document artifacts
  • When building detection signatures for PDF-based threats

Prerequisites

  • Python 3.8+ with peepdf-3 installed (pip install peepdf-3)
  • pdfid.py and pdf-parser.py from Didier Stevens suite
  • Isolated analysis environment (VM or sandbox)
  • Optional: PyV8 for JavaScript emulation within peepdf
  • Optional: Pylibemu for shellcode analysis

Workflow

  1. Triage with pdfid: Scan PDF for suspicious keywords (/JS, /JavaScript, /OpenAction, /Launch, /EmbeddedFile).
  2. Interactive Analysis: Open PDF in peepdf interactive mode to explore object structure.
  3. Identify Suspicious Objects: Locate objects containing JavaScript, streams, or encoded data.
  4. Extract Content: Dump suspicious streams and decode filters (FlateDecode, ASCIIHexDecode).
  5. Deobfuscate JavaScript: Analyze extracted JS for shellcode, heap sprays, or exploit code.
  6. Check VirusTotal: Use peepdf vtcheck to cross-reference file hash with AV detections.
  7. Generate IOCs: Extract URLs, domains, hashes, and shellcode signatures.

Key Concepts

Concept Description
/OpenAction Automatic action executed when PDF is opened
/JavaScript /JS Embedded JavaScript code in PDF objects
/Launch Action that launches external applications
/EmbeddedFile File embedded within the PDF structure
FlateDecode zlib compression filter used to hide content
Object Streams PDF objects stored in compressed streams

Tools & Systems

Tool Purpose
peepdf / peepdf-3 Interactive PDF analysis with JS emulation
pdfid.py Quick triage scanning for suspicious keywords
pdf-parser.py Deep object-level PDF parsing
VirusTotal Hash lookup and AV detection cross-reference
CyberChef Decode and transform extracted payloads

Output Format

Analysis Report: PDF-MAL-[DATE]-[SEQ]
File: [filename.pdf]
SHA-256: [hash]
Suspicious Keywords: [/JS, /OpenAction, etc.]
Objects with JavaScript: [Object IDs]
Extracted URLs: [List]
Shellcode Detected: [Yes/No]
Embedded Files: [Count and types]
VirusTotal Detections: [X/Y engines]
Risk Level: [Critical/High/Medium/Low]

Other files in this skill

references/api-reference.md (verbatim)

Malicious PDF Analysis Reference

peepdf Installation

# Python 3 version
pip install peepdf-3

# From source
git clone https://github.com/jesparza/peepdf.git
cd peepdf && pip install -r requirements.txt

peepdf CLI Usage

# Basic analysis (loose mode, force parsing)
peepdf -f -l malicious.pdf

# Interactive mode
peepdf -i malicious.pdf

# Batch script execution
peepdf -s commands.txt malicious.pdf

# JSON output
peepdf -j malicious.pdf

peepdf Interactive Commands

Command Description
info Display document summary and suspicious elements
tree Show object tree structure
object <id> Display raw content of object
stream <id> Decode and display stream content
rawstream <id> Display raw (encoded) stream
js_analyse <id> Analyze JavaScript in object
js_eval <id> Evaluate JavaScript (requires PyV8)
vtcheck Check file hash on VirusTotal
extract uri Extract all URIs from document
search <string> Search for string across objects
offsets <id> Show byte offsets of object in file
metadata Display document metadata

pdfid.py Usage

# Basic scan
pdfid.py malicious.pdf

# Additional disarm indicators
pdfid.py -e malicious.pdf

# Scan directory
pdfid.py -r /samples/

pdfid Suspicious Keywords

Keyword Risk Significance
/JS High JavaScript object reference
/JavaScript High JavaScript action
/OpenAction High Automatic execution on open
/AA High Additional actions trigger
/Launch Critical Launch external application
/EmbeddedFile High Embedded file (dropper)
/XFA High XML Forms Architecture (exploit surface)
/JBIG2Decode Medium Image decoder (CVE-2009-0658)
/AcroForm Medium Interactive form (potential exploit)
/ObjStm Low Object stream (can hide objects)
/URI Low External URL reference

pdf-parser.py Usage

# Document statistics
pdf-parser.py --stats malicious.pdf

# Extract specific object
pdf-parser.py -o 10 malicious.pdf

# Extract and decode filters
pdf-parser.py -o 10 -f malicious.pdf

# Dump decoded stream to file
pdf-parser.py -o 10 -f -d extracted.bin malicious.pdf

# Search for keyword
pdf-parser.py --search "/JavaScript" malicious.pdf

# Search by type
pdf-parser.py --type "/Action" malicious.pdf

Common CVEs in PDF Exploits

CVE Component Description
CVE-2009-0658 JBIG2 Buffer overflow in JBIG2 decoder
CVE-2009-4324 Doc.media Use-after-free via newplayer
CVE-2010-0188 LibTIFF TIFF image handling overflow
CVE-2013-0640 XFA Memory corruption in XFA
CVE-2017-11882 Equation Editor Stack buffer overflow

Shellcode Detection Patterns

Pattern Indicator
%u9090%u9090 NOP sled (Unicode)
\x90\x90\x90 NOP sled (hex)
unescape() Shellcode decoding
String.fromCharCode Character code assembly
eval() Dynamic code execution
new ActiveXObject COM object instantiation
spray variable name Heap spray technique

VirusTotal Check via peepdf

PPDF> vtcheck
MD5: abc123...
Detections: 45/72

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.