Analyzing Malicious Documents Cheat Sheet

This cheat sheet outlines tips and tools for reverse-engineering malicious documents, such as Microsoft Office (DOC, XLS, PPT) and Adobe Acrobat (PDF) files. To print, use the one-sheet PDF version; you can also edit the Word version for you own needs. If you like this, take a look at my other IT cheat sheets.

General Approach

  1. Locate potentially malicious embedded code, such as shellcode, VBA macros, or JavaScript.
  2. Extract suspicious code segments from the file.
  3. If relevant, disassemble and/or debug shellcode.
  4. If relevant, deobfuscate and examine JavaScript, ActionScript, or VB macro code.
  5. Understand next steps in the infection chain.

Microsoft Office Binary File Format Notes

  • Structured Storage (OLE SS) defines a file system inside the binary Microsoft Office file.
  • Data can be “storage” (folder) and “stream” (file).
  • Excel stores data inside the “workbook” stream.
  • PowerPoint stores data inside the “PowerPoint Document” stream.
  • Word stores data inside various streams.

Tools for Analyzing Microsoft Office Files

  • OfficeMalScanner locates shellcode and VBA macros from MS Office (DOC, XLS, and PPT) files.
  • MalHost-Setup extracts shellcode from a given offset in an MS Office file and embeds it an EXE file for further analysis. (Part of OfficeMalScanner)
  • Offvis shows raw contents and structure of an MS Office file, and identifies some common exploits.
  • Hachoir-urwid can navigate through the structure of binary Office files and view stream contents.
  • Office Binary Translator converts DOC, PPT, and XLS files into Open XML files (includes BiffView tool).
  • can examine and decode some aspects of malicious binary Office files.
  • FileHex (not free) and FileInsight hex editors can parse and edit OLE structures.

Useful MS Office Analysis Commands

OfficeMalScanner file.doc scan bruteLocate shellcode, OLE data, PE files in file.doc
OfficeMalScanner file.doc infoLocate VB macro code in file.doc (no XML files)
OfficeMalScanner file.docx inflateDecompress file.docx to locate VB code (XML files)
MalHost-Setup file.doc out.exe 0x4500Extract shellcode from file.doc’s offset 0x4500 and create it as out.exe

Adobe PDF File Format Notes

  • A PDF File is comprised of header, objects, cross-reference table (to locate objects), and trailer.
  • “/OpenAction” and “/AA” (Additional Action) specifies the script or action to run automatically.
  •  “/Names”, “/AcroForm”, “/Action” can also specify and launch scripts or actions.
  • “/JavaScript” specifies JavaScript to run.
  •  “/GoTo*” changes the view to a specified destination within the PDF or in another PDF file.
  •  “/Launch” launches a program or opens a document.
  • “/URI” accesses a resource by its URL.
  • “/SubmitForm” and “/GoToR” can send data to URL.
  • “/RichMedia” can be used to embed Flash in PDF.
  • “/ObjStm” can hide objects inside an Object Stream.
  • Be mindful of obfuscation with hex codes, such as “/JavaScript” vs. “/J#61vaScript”. (See examples)

Tools for Analyzing Adobe PDF Files

  • PDFiD identifies PDFs that contain strings associated with scripts and actions.
  • PDF-parser and Origami’s pdfwalker examines the structure of PDF files.
  • Origami’s pdfextract and Jsunpack-n’s extract JavaScript from PDF files.
  • PDF Stream Dumper combines many PDF analysis tools under a single graphical user interface.
  • Peepdf and Origami’s pdfsh offer an interactive command-line shell for examining PDF files.
  • PDF X-RAY Lite creates an HTML report containing decoded PDF file structure and contents.
  • SWF mastah extracts SWF objects from PDF files.
  • Pyew includes commands for examining and decoding structure and content of PDF files.

Useful PDF Analysis Commands file.pdfLocate script and action-related strings in file.pdf file.pdfShow file.pdf’s structure to identify suspect elements –object id file.pdfDisplay contents of object id in file.pdf. Add “–filter –raw” to decode the object’s stream.
pdfextract file.pdfExtract JavaScript embedded in file.pdf and save it to file.dump. file.pdfExtract JavaScript embedded in file.pdf and save it to file.pdf.out. -f file.pdf –o outExtract PDF objects from file.pdf into the out directory.

Additional PDF Analysis Tools



Special thanks for contributions and feedback to Pedro Bueno, Frank Boldewin and Didier Stevens. If you have suggestions for improving this cheat sheet, please let me know. This cheat sheet is distributed according to the Creative Commons v3 “Attribution” License. File version 2. Take a look at my other security cheat sheets.


About the Author

Lenny Zeltser is a seasoned business and technology leader with extensive information security experience. He builds innovative endpoint defense solutions as VP of Products at Minerva. He also trains incident response and digital forensics professionals at SANS Institute. Lenny frequently speaks at industry events, writes articles and has co-authored books. He has earned the prestigious GIAC Security Expert designation, has an MBA from MIT Sloan and a Computer Science degree from the University of Pennsylvania.

Learn more