How Beginners Can Detect and Analyse PDF Malware Step by Step
To analyse a suspicious PDF safely, work in an isolated virtual machine, never on your everyday computer. First calculate the file's hash and check its reputation on services such as VirusTotal. Then use Didier Stevens' pdfid to count risky keywords like /JavaScript, /OpenAction, /Launch, /EmbeddedFile and /URI, and pdf-parser to inspect and extract the objects that contain them.
Topic: Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Lab / project
Also covers: Incident Response & Digital Forensics
Quick answer: To analyse a suspicious PDF safely, work in an isolated virtual machine, never on your everyday computer. First calculate the file's hash and check its reputation on services such as VirusTotal. Then use Didier Stevens' pdfid to count risky keywords like /JavaScript, /OpenAction, /Launch, /EmbeddedFile and /URI, and pdf-parser to inspect and extract the objects that contain them. Decode compressed streams, pull out links, scripts, embedded files and QR codes, and document what the PDF tries to do. Many malicious PDFs today simply contain phishing links or QR codes rather than exploits.
Key takeaways
- Always analyse in an isolated, disposable environment.
- Hash lookups are safer than uploading confidential documents.
- pdfid gives a quick risk profile; pdf-parser digs into objects.
- Look for auto-run actions, JavaScript, embedded files and external links.
- Many modern PDF threats are phishing links or QR codes, not exploits.
Table of Contents
- How Do You Set Up a Safe Lab?
- What Is Inside a PDF?
- How Do You Triage a Suspicious PDF?
- How Do You Inspect Objects and Streams?
- How Do You Extract Links and QR Codes?
- How Do You Report Findings?
- References
How Do You Set Up a Safe Lab?
- Use a virtual machine (for example REMnux or a Linux VM) with snapshots.
- Disconnect it from your network or use an isolated network.
- Do not open samples in a normal PDF reader; use analysis tools.
- Store samples in password-protected archives (commonly "infected").
What Is Inside a PDF?
A PDF is a set of numbered objects (text, images, fonts, actions) described in the ISO 32000 standard (PDF Association overview). Some features are risky:
| Keyword | Risk |
|---|---|
| /JavaScript, /JS | Scripts that may exploit the reader |
| /OpenAction, /AA | Actions that run automatically when opened |
| /Launch | Attempts to run external programs |
| /EmbeddedFile | Attached files, possibly executables |
| /URI | Links, often to phishing pages |
| /ObjStm | Object streams that can hide content |
How Do You Triage a Suspicious PDF?
# 1. Hash and look up reputation (search the hash on VirusTotal)
sha256sum suspicious.pdf
# 2. Count risky keywords with pdfid
python3 pdfid.py suspicious.pdf
# /JS 1 /JavaScript 1 /OpenAction 1 /EmbeddedFile 0 /URI 3
A PDF with /OpenAction plus /JavaScript deserves close inspection. Tools are available from Didier Stevens' PDF tools page.
How Do You Inspect Objects and Streams?
# Find objects containing JavaScript
python3 pdf-parser.py --search javascript suspicious.pdf
# Show object 12 and decode its stream (filters such as FlateDecode)
python3 pdf-parser.py --object 12 --filter --raw suspicious.pdf
# Normalise the file for easier reading with qpdf
qpdf --qdf --object-streams=disable suspicious.pdf readable.pdf
Extracted JavaScript is often obfuscated; read it in a text editor rather than running it. qpdf helps expand compressed objects.
How Do You Extract Links and QR Codes?
# List URLs found in the PDF
python3 pdf-parser.py --search URI suspicious.pdf | grep -o "http[^)]*"
# Render pages and decode QR codes
pdftoppm -png -r 200 suspicious.pdf page
zbarimg --quiet page-*.png
Check extracted URLs in a sandbox service rather than visiting them. See QR code phishing in PDFs.
How Do You Report Findings?
- File hashes, names and source (email sender, URL).
- Suspicious features found and extracted indicators (URLs, domains, embedded files).
- Assessed behaviour: phishing, exploit attempt, dropper.
- Recommended actions: block indicators, search mailboxes, reset credentials if clicked.
Map findings to MITRE T1204.002. US organisations can submit samples to CISA Malware Next-Gen. Related: SVG malware. WebAsha offers malware analysis training.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0