Skip to content
Skillpedia
Analysis & spreadsheets35k Β· #7624

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.md

Copy 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

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-macro-malware-in-office-documents/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

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

  1. 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.
  2. 2Install the tools the skill relies on: oletools with pip install oletools, oledump.py from Didier Stevens, and xlmdeobfuscator if you expect Excel files.
  3. 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.
  4. 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.
  5. 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

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#7624
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills