pdfid

Outil de triage rapide de PDF signé Didier Stevens : scanne un PDF à la recherche de mots-clés et objets suspects (JavaScript, OpenAction, fichiers embarqués) sans en parser la structure. Didier Stevens' quick PDF triage tool — scans a PDF for suspicious keywords and objects (JavaScript, OpenAction, embedded files) without parsing its structure.

↗ https://blog.didierstevens.com/programs/pdf-tools/

Overview

pdfid is a lightweight, fast triage script for suspicious PDF files. Rather than fully parsing the PDF’s object structure, it simply counts occurrences of keywords known to be associated with malicious behavior — /JavaScript, /OpenAction, /AA (automatic actions), /EmbeddedFile, /Launch — giving an analyst a quick first read on whether a PDF is worth deeper investigation. It’s typically the very first step before reaching for pdf-parser or a sandbox.

Common Usage

Basic scan — prints keyword counts for the PDF

pdfid.py suspicious.pdf

Scan every PDF in a directory

pdfid.py -s /path/to/pdfs/

Only show PDFs where interesting keywords were found (filters clean files)

pdfid.py -f suspicious.pdf

Include extra keyword statistics beyond the default set

pdfid.py -e suspicious.pdf

Output in CSV for triaging many files at once

pdfid.py -c -s /path/to/pdfs/ > results.csv

Interpreting Output

PDF Header: %PDF-1.7
obj                 42
endobj               42
stream               10
endstream            10
xref                  1
trailer               1
startxref              1
/Page                 1
/Encrypt               0
/ObjStm                0
/JS                     1   <- JavaScript present, investigate
/JavaScript             1
/AA                      1   <- automatic action, common in exploits
/OpenAction              1   <- executes automatically on open
/AcroForm                0
/JBIG2Decode             0
/RichMedia               0
/Launch                  0
/EmbeddedFile            0
/XFA                     0

Tips

  • A non-zero /JavaScript//JS, /OpenAction, or /AA count doesn’t automatically mean malicious (legitimate PDFs use JS for forms), but it flags the file for follow-up with pdf-parser.py to inspect the actual object content.
  • Always analyze suspicious PDFs in an isolated VM/sandbox — pdfid itself is safe (it doesn’t render or execute anything) but don’t open the PDF in a viewer afterward without care.
  • Chain with pdf-parser.py -o <objnum> to dump the specific object once pdfid flags something interesting.
Help / Man page
Usage: pdfid.py [options] pdf-file|zip-file|url ...

pdfid.py, use it to test a PDF file

Options:
  -h, --help          show this help message and exit
  -s, --scan          scan the given directory
  -a, --all           display all the objects in the PDF file
  -e, --extra         display extra data, like dates
  -f, --force         force ID attempt, even without proper %PDF header
  -d, --disarm        disarm the PDF file (dangerous keywords defanged)
  -p PLUGINDIR        plugin directory
  -c, --csv           output csv
  -m, --minimumscore  minimum score for plugin results to be reported
  -v, --verbose       verbose (will also raise exceptions on errors)
  -n, --nozero        do not print items with a value of zero

Vue d’ensemble

pdfid est un script de triage léger et rapide pour les fichiers PDF suspects. Plutôt que de parser entièrement la structure d’objets du PDF, il se contente de compter les occurrences de mots-clés connus pour être associés à un comportement malveillant : /JavaScript, /OpenAction, /AA (actions automatiques), /EmbeddedFile, /Launch. Cela donne à l’analyste une première lecture rapide pour savoir si un PDF mérite une investigation plus poussée. C’est généralement la toute première étape avant de passer à pdf-parser ou à un sandbox.

Utilisation courante

# Scan basique, affiche le nombre d'occurrences des mots-clés du PDF
pdfid.py suspicious.pdf

# Scanner tous les PDF d'un répertoire
pdfid.py -s /path/to/pdfs/

# N'afficher que les PDF où des mots-clés intéressants ont été trouvés (filtre les fichiers propres)
pdfid.py -f suspicious.pdf

# Inclure des statistiques de mots-clés supplémentaires au-delà du jeu par défaut
pdfid.py -e suspicious.pdf

# Sortie au format CSV pour trier de nombreux fichiers en une fois
pdfid.py -c -s /path/to/pdfs/ > results.csv

Interpréter la sortie

PDF Header: %PDF-1.7
obj                 42
endobj               42
stream               10
endstream            10
xref                  1
trailer               1
startxref              1
/Page                 1
/Encrypt               0
/ObjStm                0
/JS                     1   <- JavaScript présent, à examiner
/JavaScript             1
/AA                      1   <- action automatique, courante dans les exploits
/OpenAction              1   <- s'exécute automatiquement à l'ouverture
/AcroForm                0
/JBIG2Decode             0
/RichMedia               0
/Launch                  0
/EmbeddedFile            0
/XFA                     0

Astuces

  • Un compte non nul de /JavaScript//JS, /OpenAction ou /AA ne signifie pas automatiquement que le fichier est malveillant (les PDF légitimes utilisent du JS pour les formulaires), mais cela signale le fichier pour un suivi avec pdf-parser.py afin d’inspecter le contenu réel de l’objet.
  • Toujours analyser les PDF suspects dans une VM/un sandbox isolé, pdfid en lui-même est sûr (il ne rend ni n’exécute rien), mais ne pas ouvrir le PDF dans un lecteur ensuite sans précaution.
  • Enchaîner avec pdf-parser.py -o <objnum> pour extraire l’objet spécifique une fois que pdfid a signalé quelque chose d’intéressant.
Aide / Page de manuel
Usage: pdfid.py [options] pdf-file|zip-file|url ...

pdfid.py, use it to test a PDF file

Options:
  -h, --help          show this help message and exit
  -s, --scan          scan the given directory
  -a, --all           display all the objects in the PDF file
  -e, --extra         display extra data, like dates
  -f, --force         force ID attempt, even without proper %PDF header
  -d, --disarm        disarm the PDF file (dangerous keywords defanged)
  -p PLUGINDIR        plugin directory
  -c, --csv           output csv
  -m, --minimumscore  minimum score for plugin results to be reported
  -v, --verbose       verbose (will also raise exceptions on errors)
  -n, --nozero        do not print items with a value of zero