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.

Jul 18, 2025 - 10:34
Updated: 
107.9k

Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Lab / project

Incident Response & Digital Forensics

How Beginners Can Detect and Analyse PDF Malware Step by Step

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?

  • 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:

KeywordRisk
/JavaScript, /JSScripts that may exploit the reader
/OpenAction, /AAActions that run automatically when opened
/LaunchAttempts to run external programs
/EmbeddedFileAttached files, possibly executables
/URILinks, often to phishing pages
/ObjStmObject 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.

# 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

Yes. PDFs can include JavaScript, auto-run actions, embedded files or links to malicious sites.

No. Analyse it in an isolated virtual machine with analysis tools instead of a normal reader.

A tool by Didier Stevens that counts risky PDF keywords such as /JavaScript and /OpenAction.

/JavaScript, /JS, /OpenAction, /AA, /Launch, /EmbeddedFile and many /URI entries.

Use pdf-parser to search for and decode objects containing JavaScript, then read it as text.

Search by hash first; avoid uploading confidential documents because uploads may be shared.

Many today contain phishing links or QR codes rather than reader exploits.

An isolated virtual machine with snapshots, such as REMnux, disconnected from your network.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.