meltedinhex/analyst-ai-pack / skills/analyzing-malicious-office-macros
analyzing-malicious-office-macros
VerifiedAnalyzes malicious Office documents by extracting and reviewing VBA macros and OLE/OOXML structure: auto-exec triggers, obfuscation, dropped payloads, and shell/PowerShell invocation. Activates for requests to analyze a malicious Word/Excel document, VBA macro, or maldoc.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 340 B |
| SKILL.md | skill md | 3.3 KB |
| references/api-reference.md | markdown | 1.3 KB |
| scripts/analyst.py | script | 3.1 KB |
scripts/analyst.py
View on GitHub#!/usr/bin/env python3
"""Extract and triage VBA macros from Office documents.
Prefers ``oletools`` (olevba) for robust extraction; falls back to locating ``vbaProject.bin``
inside OOXML (ZIP) containers and flagging suspicious indicators in the raw bytes. Never opens
the document in Office and never executes anything.
"""
from __future__ import annotations
import argparse
import json
import re
import sys
import zipfile
from pathlib import Path
AUTOEXEC = ["AutoOpen", "Document_Open", "AutoClose", "Document_Close",
"Workbook_Open", "Auto_Open", "Auto_Close"]
SUSPICIOUS = ["Shell", "WScript.Shell", "CreateObject", "powershell", "cmd",
"URLDownloadToFile", "XMLHTTP", "ADODB.Stream", "Environ",
"winmgmts", "Base64", "Chr(", "GetObject"]
def _scan_text(text: str) -> dict:
found_auto = [k for k in AUTOEXEC if k.lower() in text.lower()]
found_sus = [k for k in SUSPICIOUS if k.lower() in text.lower()]
urls = sorted(set(re.findall(r"https?://[^\s\"'<>)]+", text)))
return {"auto_exec": found_auto, "suspicious": found_sus, "urls": urls}
def extract_with_olevba(path: str) -> dict:
from oletools.olevba import VBA_Parser # type: ignore
vp = VBA_Parser(path)
macros = []
if vp.detect_vba_macros():
for _, _, name, code in vp.extract_macros():
macros.append({"name": name, **_scan_text(code),
"lines": code.count("\n") + 1})
vp.close()
return {"engine": "olevba", "has_macros": bool(macros), "macros": macros}
def extract_minimal(path: str) -> dict:
p = Path(path)
data = p.read_bytes()
indicators = {}
if zipfile.is_zipfile(path):
with zipfile.ZipFile(path) as zf:
vba = [n for n in zf.namelist() if n.lower().endswith("vbaproject.bin")]
if not vba:
return {"engine": "minimal", "has_macros": False,
"note": "no vbaProject.bin in OOXML container"}
blob = zf.read(vba[0])
# vbaProject.bin is OLE/compressed; scan recoverable ASCII for indicators
text = blob.decode("latin-1", "replace")
indicators = _scan_text(text)
return {"engine": "minimal", "has_macros": True,
"stream": vba[0], "indicators": indicators,
"note": "install oletools for full VBA source extraction"}
# legacy OLE2: scan whole file bytes for indicator strings
text = data.decode("latin-1", "replace")
return {"engine": "minimal", "has_macros": b"Attribut" in data,
"indicators": _scan_text(text),
"note": "legacy OLE2; install oletools for reliable extraction"}
def analyze(path: str) -> dict:
try:
return extract_with_olevba(path)
except ImportError:
return extract_minimal(path)
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Analyze Office macros")
sub = parser.add_subparsers(dest="cmd", required=True)
p = sub.add_parser("extract")
p.add_argument("file")
args = parser.parse_args(argv)
print(json.dumps(analyze(args.file), indent=2))
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |