Does this Office document contain a harmful macro?
Malicious Word and Excel files often hide a small program called a macro. This workflow shows how to look inside a suspect Office file without opening it in Office: find the macro, read what starts it, pull out the links and commands, and write down indicators. Safety comes first, because the file may be live malware.
This workflow was written from the tools' documentation and published references. It has not yet been checked step by step on the practice data. If a step does not match what you see, please report it.
What you will be able to answer
- Whether the file contains macros, embedded objects or DDE fields
- Which code starts automatically when the file is opened
- Which links, file names and commands appear in the code
- Whether the code is obfuscated and how it was decoded
- Which indicators to report
What you need
- A virtual machine used only for analysis, with the network off, snapshot taken, and shared folders and clipboard sharing disabled
- Python with oletools installed (pip install -U oletools). REMnux has these tools ready
- CyberChef, offline copy or in a browser inside the VM
- Do not install or start Microsoft Office in the VM for this workflow
Steps
- 1
Handle it safely first
Treat the file as live malware. Keep the original read-only and work on a copy inside an isolated analysis VM: network off, snapshot taken, no shared folders, no clipboard sharing. Never double-click the file. Write down its SHA-256 hash before anything else. Search reputation services by hash only. Do not upload files from a real case without permission.
sha256sum suspicious.doc
Get-FileHash .\suspicious.doc -Algorithm SHA256
- 2
Find out what the file really is
The extension can be wrong. Old Office files (.doc, .xls) are OLE files. Newer files (.docx, .docm, .xlsx, .xlsm) are ZIP archives that hold XML. A .docx or .xlsx file does not contain VBA macros, but a .docm or .xlsm file can. Run oleid for a first overview: file type, macros, embedded objects and encryption. If the file came from an NTFS drive, check its Zone.Identifier stream, because Office blocks macros by default in files marked as coming from the internet.
oleid suspicious.doc
notepad suspicious.doc:Zone.Identifier
- 3
Look for macros with olevba
olevba extracts the macro source from both old and new Office files and scans it. Read the summary table. AutoExec lists code that runs when the file opens, such as AutoOpen or Workbook_Open. Suspicious lists keywords such as Shell, Environ or URLDownloadToFileA. IOC lists URLs, IP addresses and file names. The tool reads the file as data. It does not run the macro.
olevba suspicious.doc
olevba -a suspicious.doc
Toolsoletools - 4
Get a quick second opinion with mraptor
mraptor looks for three kinds of keywords: auto-run (A), writing to disk or memory (W) and running something outside VBA (X). It calls a macro suspicious when A appears together with W or X. The exit code 20 means suspicious and 0 means no macro found. It is a heuristic. A clean result is not proof that the file is safe, and a hit needs reading.
mraptor suspicious.doc
Toolsoletools - 5
Read and decode the code
Start at the auto-run procedure and follow the calls. Use the --decode option to see hex, Base64 and similar strings in decoded form, and --reveal to see the source with those strings swapped for the decoded text. For text that is still unreadable, paste it into CyberChef: From Base64, then Decode text (UTF-16LE) is a common pair for encoded PowerShell. Use Extract URLs and Defang URL for the indicators. Never run the decoded commands.
olevba --decode suspicious.doc
olevba --reveal suspicious.doc
- 6
Check the other hiding places
Not every harmful document uses VBA. msodde finds DDE and DDEAUTO fields. rtfobj lists and saves objects inside RTF files. For old files, oledump.py from the Didier Stevens suite lists the streams and marks macro streams with M. Open XML files are ZIP archives: list the contents and look for vbaProject.bin and for links in the .rels files. Recent oletools versions also give a basic view of Excel 4 (XLM) macros.
msodde suspicious.doc
rtfobj suspicious.rtf
unzip -l suspicious.docm
Toolsoletools - 7
Match with YARA and look at embedded programs
Scan the file with rules you trust, or write a small rule of your own for a string you found. Use -s to print which strings matched. If the macro or an object carries an embedded program, extract it only as data, hash it and look at it with FLOSS, which lists readable and decoded strings. Do not start it. If the macro downloads a program from a link, do not fetch the link from your lab.
yara -s rules.yar suspicious.doc
floss extracted_program.bin
- 8
Record indicators and limits
Write down the file hash, the tool names and versions, the auto-run entry point, defanged URLs and file names, and what you could not decode. State that static analysis shows what the code is built to do, not what it did on the user's computer. Hand the indicators to the security team.
Where the evidence is stored
VBA macro sourcevbaProject.bin inside the file (OLE streams in .doc and .xls)The code, its auto-run entry points, and strings such as URLs and commands
DDE and DDEAUTO fieldsWord document fields or Excel cellsCommands that Office can be told to run without a macro
Embedded objectsOLE objects inside the file, or RTF objectsFiles carried inside the document, with their original names
Zone.Identifier streamNTFS alternate data stream of the file on the user's computerWhether the file was marked as coming from the internet, and the zone value
External links in .rels filesInside Open XML files (ZIP archive)Addresses that the document loads from when opened
Office trust recordsUser registry hive NTUSER.DAT, under the Office Security, Trusted Documents keyWhether the user clicked to enable editing or content for a document (check the exact key for your Office version)
Document metadataOLE properties or docProps in Open XML filesAuthor name, creation and save times, and template. These values can be edited by anyone.
Check your result
- Compare the macro source from olevba with the streams shown by oledump.py. The auto-run entry point should be the same.
- Decode the same string in CyberChef and in olevba --decode. The results should agree.
- Check that URLs from olevba also appear when you extract URLs from the raw file or from the unzipped XML.
- Hash the file again at the end. It must still match the first hash.
Common mistakes
- Opening the file in Word or Excel and clicking Enable content to see what happens.
- Trusting the file extension. Check the real type first.
- Treating a clean mraptor or olevba result as proof of safety. Read the code, and check DDE and other objects too.
- Running a decoded PowerShell command or opening a decoded link to confirm it.
- Copying the hash, URLs and notes out of the VM with clipboard sharing left on, which also opens a path from the VM to the host.
Write it up
A short, careful way to state this kind of finding in a report. Change the details to match your own results.
The file [name] (SHA-256 [hash]) is an [OLE or Open XML] document with a VBA macro that starts automatically through [entry point]. The code contains the defanged address [URL] and the command [text]. These findings come from olevba [version] and mraptor [version] and were checked with [second tool]. The file was not opened in Office, and its effect on the computer was not examined.
What this does not prove
- Static analysis shows what the code can do. It does not show that it ran on a computer or what it downloaded.
- Heavy obfuscation, password-protected files and unusual formats can defeat the tools. Ask for a second review.
- The macro source and the stored compiled form can differ in some files, so a harmless-looking source is not proof.
- Metadata such as author and dates can be changed or forged.
- Tools such as olevba and mraptor are leads. Their keyword lists will not cover every technique.
- The file may be live malware. Procedures and reporting duties differ by country and agency, so follow your own rules.
Practise on public data
Your own harmless test document (no safe public set verified)
We could not verify a public set of safe, labelled macro documents with an answer key. Public sources of real samples, such as MalwareBazaar and the zip files on malware-traffic-analysis.net, are live malware and need an isolated lab. For learning, build your own file and run the tools on it.
Your task. In a lab VM with Office or LibreOffice, create a document with a macro named AutoOpen (Word) or Workbook_Open (Excel) that only shows a message box. Save it as .doc and as .docm. Run oleid, olevba and mraptor on both. Check that the entry point appears under AutoExec and compare what the tools say.
The macro must do nothing except show text. Do not copy code from real samples.
Where to go next
- What can I learn about a suspicious program without running it? Look at an extracted program without running it
- Is this suspicious email a phishing attempt? Go back to the email that carried the file
- Which programs were run on this Windows computer? Check which programs ran on the user's computer
- How does malware or an intruder stay on this Windows computer? Check for new start-up entries after the file was opened
Sources and further reading
- oletools wiki: olevba
- oletools wiki: mraptor
- oletools wiki: msodde
- Microsoft: Macros from the internet are blocked by default in Office
- Didier Stevens: oledump.py
A study guide written in our own words. It is not a legal or laboratory procedure. Follow your own lab's approved method on real cases. Last reviewed 24 Nov 2026.