analyzing-macro-malware-in-office-documents
What it does
This tool analyzes Office documents (Word, Excel, PowerPoint) containing malicious macros. It looks for code that tries to download other programs, execute commands, hide on the system, or trick analysis.
When to use it
- βWhen you receive a suspicious Office document via email.
- βWhen investigating attacks that use malicious documents.
- βTo understand how a malicious macro works and what it does.
Skill link
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-macro-malware-in-office-documents/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βAnalyze this Word document to see if it has dangerous macros.β
5 new skills a week. 1 minute to read.
analyzing-macro-malware-in-office-documents: full guide
When a suspicious Word or Excel file lands in your inbox, the real question is what it would do if someone clicked "Enable Content". The macro code inside is often scrambled on purpose, split into pieces, encoded as numbers, or hidden in places most tools do not check. Reading it by hand takes hours and is risky.
This skill gives your agent a fixed method for that job. It checks whether a file has macros, pulls out the code, unscrambles it, and looks for other tricks such as DDE fields, remote templates and Excel 4.0 macros. It ends with a report listing the download address, how the code runs, and indicators you can block. It suits security staff, IT admins and incident responders who triage phishing attachments. It is not meant for casual curiosity: you need an isolated machine.
Use cases
Triage a flagged invoice attachment
Your email filter quarantines an invoice_q3.docm. Instead of opening it, you ask the agent to check for macros, find the AutoOpen trigger, and report in plain words what the code tries to download and where from.
Decode a scrambled macro
A macro looks like a wall of Chr() numbers and joined text fragments. The agent resolves those pieces step by step until the hidden PowerShell command and the payload URL become readable, so you can see the real intent.
Check an Excel file with no visible VBA
A spreadsheet shows no VBA code, yet users reported strange behaviour. You ask the agent to look for hidden Excel 4.0 macros, DDE commands and remote template links, which standard VBA checks can miss.
Step by step
- 1Install the skill by placing its folder in ~/.claude/skills/ (or your project's .claude/skills/), and work inside an isolated virtual machine that does not have Microsoft Office installed.
- 2Install the tools the skill relies on: oletools with pip install oletools, oledump.py from Didier Stevens, and xlmdeobfuscator if you expect Excel files.
- 3Copy the suspect file into the VM and ask the agent to run the first triage, which shows whether VBA macros, XLM macros, external links or embedded objects are present.
- 4Ask the agent to extract and deobfuscate the code, then to trace the path from the auto-run trigger (such as AutoOpen) to the command that runs.
- 5Request the final report with the download URLs, domains, execution method and file hashes, and hand the indicators to your blocking or detection team.
Example
What to ask
βI have a file called invoice_q3.docm from a phishing email. Do not open it in Office. Check for macros, decode anything hidden, and tell me what URL it contacts and how it runs the payload.β
What you get
The agent reports one VBA macro starting at AutoOpen(), which builds a PowerShell command from Chr() pieces. The decoded command downloads a script from a listed address. You also get the file hash, the lure text, and the domain and IP to block.
Tips
- βNever open the sample in Microsoft Office. The skill depends on command-line extraction precisely so that nothing runs by accident.
- βDo not stop after the main macro. Code can also hide in UserForms, and some files use both VBA and Excel 4.0 macros, so ask the agent to check both.
- βThe built-in deobfuscation covers common patterns only. Heavily layered code may need manual review, and the skill does not run the macro to watch what it does.
Alternatives
- multimodal-evidence
Pick it when your goal is to extract and verify facts from PDFs, spreadsheets or images, not to investigate whether a document is malicious.
- jupyter-notebook
Pick it when you want to build a notebook that documents an analysis step by step, for example to write up your findings for a team.
Questions and answers
Does it work on files with the extensions .docx or .xlsx?
Those formats normally cannot hold macros, but the skill still checks them for DDE commands and remote template links. Macro-enabled files such as .docm and .xlsm get the full VBA extraction.
Can it tell me which malware family a document belongs to?
The skill extracts the attack chain, indicators and a YARA rule for the document pattern. It does not name a malware family, so you would match the indicators yourself against threat reports.
Is it safe to analyse a live sample with this skill?
It uses static tools that read the file without running it, and it advises an isolated VM without Office. Even so, handle samples with care and keep them away from your normal work computer.
How it works
The tool uses specific programs to extract the macro code. Then, it tries to 'unscramble' this code to make it readable and identify dangerous actions.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Analyzing Macro Malware in Office Documents
When to Use
- A suspicious Office document (.doc, .docm, .xls, .xlsm, .ppt) has been flagged by email security
- Investigating phishing campaigns that deliver weaponized Office documents
- Extracting VBA macro code to identify the payload download URL and execution method
- Analyzing obfuscated VBA code to understand the full attack chain
- Determining if a document uses DDE, ActiveX, or remote template injection instead of macros
Do not use for analyzing non-macro Office threats (DDE, remote template injection); while this skill covers detection of these, specialized analysis may be needed.
Prerequisites
- Python 3.8+ with oletools installed (
pip install oletools) - oledump.py from Didier Stevens (https://blog.didierstevens.com/programs/oledump-py/)
- Isolated analysis VM without Microsoft Office installed (prevents accidental execution)
- XLMDeobfuscator for Excel 4.0 macro analysis (pip install xlmdeobfuscator)
- LibreOffice for safe document rendering (does not execute VBA macros by default)
Workflow
Step 1: Initial Document Triage
Determine if the document contains macros or other active content:
# Quick triage with olevba
olevba suspect.docm
# Check for OLE streams and macros
oleid suspect.docm
# Output indicators:
# VBA Macros: True/False
# XLM Macros: True/False
# External Relationships: True/False (remote template)
# ObjectPool: True/False (embedded objects)
# Flash: True/False (SWF objects)
# Comprehensive OLE analysis
oledump.py suspect.docm
# List all OLE streams with macro indicators
# Streams marked with 'M' contain VBA macros
# Streams marked with 'm' contain macro attributes
Step 2: Extract and Analyze VBA Code
Pull out the complete VBA macro source:
# Extract VBA with full deobfuscation
olevba --decode --deobf suspect.docm
# Extract just the VBA source code
olevba --code suspect.docm > extracted_vba.txt
# Detailed extraction with oledump
oledump.py -s 8 -v suspect.docm # Stream 8 (adjust based on stream listing)
# Extract all macro streams
oledump.py -p plugin_vba_dco suspect.docm
Key VBA Elements to Identify:
βββββββββββββββββββββββββββ
Auto-Execution Triggers:
- Auto_Open / AutoOpen (Word)
- Auto_Close / AutoClose
- Document_Open / Document_Close
- Workbook_Open (Excel)
- AutoExec
Suspicious Functions:
- Shell() / Shell.Application
- WScript.Shell.Run / Exec
- CreateObject("WScript.Shell")
- PowerShell execution
- URLDownloadToFile
- MSXML2.XMLHTTP (HTTP requests)
- ADODB.Stream (file writing)
- Environ() (environment variables)
- CallByName (indirect method calls)
Step 3: Deobfuscate VBA Code
Remove obfuscation layers to reveal the payload:
# VBA deobfuscation techniques
import re
def deobfuscate_vba(code):
# 1. Resolve Chr() calls: Chr(104) & Chr(116) -> "ht"
def resolve_chr(match):
try:
return chr(int(match.group(1)))
except:
return match.group(0)
code = re.sub(r'Chr\$?\((\d+)\)', resolve_chr, code)
# 2. Remove string concatenation: "htt" & "p://" -> "http://"
code = re.sub(r'"\s*&\s*"', '', code)
# 3. Resolve ChrW calls: ChrW(104)
code = re.sub(r'ChrW\$?\((\d+)\)', resolve_chr, code)
# 4. Resolve StrReverse: StrReverse("exe.daolnwod") -> "download.exe"
def resolve_reverse(match):
return '"' + match.group(1)[::-1] + '"'
code = re.sub(r'StrReverse\("([^"]+)"\)', resolve_reverse, code)
# 5. Remove Mid$/Left$/Right$ obfuscation (complex, mark for manual review)
# 6. Resolve Replace(): Replace("Powxershxell", "x", "")
def resolve_replace(match):
original = match.group(1)
find = match.group(2)
replace_with = match.group(3)
return '"' + original.replace(find, replace_with) + '"'
code = re.sub(r'Replace\("([^"]+)",\s*"([^"]+)",\s*"([^"]*)"\)', resolve_replace, code)
return code
with open("extracted_vba.txt") as f:
vba_code = f.read()
deobfuscated = deobfuscate_vba(vba_code)
print(deobfuscated)
Step 4: Analyze Excel 4.0 (XLM) Macros
Handle legacy Excel macros that bypass VBA detection:
# Detect XLM macros
olevba --xlm suspect.xlsm
# Deobfuscate XLM macros
xlmdeobfuscator -f suspect.xlsm
# Manual XLM analysis with oledump
oledump.py suspect.xlsm -p plugin_biff.py
# XLM (Excel 4.0) macro functions to watch for:
β¦
FAQ
What are macros?
Macros are small sequences of commands that can be added to documents to automate tasks. Unfortunately, they can also be used to run malicious code.
What is 'obfuscation'?
It's a technique used to make code difficult to read and understand, as if it were scrambled. The tool tries to undo this confusion.
Do I need to install anything to use it?
Yes, the tool requires the installation of specific programs (like oletools) and a safe analysis environment to prevent the malware from running accidentally.
Details
Original description by the author
Analyzes malicious VBA macros embedded in Microsoft Office documents (Word, Excel, PowerPoint) to identify download cradles, payload execution, persistence mechanisms, and anti-analysis techniques. Uses olevba, oledump, and VBA deobfuscation to extract the attack chain. Activates for requests involving Office macro analysis, VBA malware investigation, maldoc analysis, or document-based threat exam
Popularity
- GitHub stars
- 35k
- Ranking position
- #7624
- License
- Apache-2.0
- Updated
- 8/31/2026
Comments
- β¦
More skills from this repository
abusing-dpapi-for-credential-access
35kGives your AI agent ready-made instructions for a specific task, so it does it better and faster.
abusing-shadow-credentials-for-privesc
35kTeaches your AI agent to write clear, well-structured text.
achieving-cmmc-level-2-compliance
35kHelps your agent prepare an environment for CMMC Level 2 compliance. It implements security requirements and manages necessary documentation.
acquiring-disk-image-with-dd-and-dcfldd
35kHelps your agent create exact copies of hard drives. This is useful for ensuring no information is lost or altered during investigations.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.