Exploiting Microsoft Office
Leveraging Microsoft Word Macros for Reverse Shells
Overview
Microsoft Word macros, written in Visual Basic for Applications (VBA), can automate tasks and serve as a powerful client-side attack vector when maliciously crafted. This guide outlines the creation of a macro to launch a reverse shell using PowerShell.
Key Points
1. Macro Basics
What are Macros?
Macros are written in VBA, offering full access to ActiveX objects and the Windows Script Host.
.doc
or.docm
formats are required to embed macros. Macros in.docx
are not persistent.
2. Macro Setup
Steps:
Save a Word document as
.doc
.Access the macro menu via View > Macros > Create.
Develop the macro in the Visual Basic for Applications editor.
Default Macro Skeleton:
3. Executing Commands with ActiveX
Example Macro to Open PowerShell:
4. Auto-Execution
Use AutoOpen
and Document_Open
to ensure macros execute when the document opens:
5. Creating a Reverse Shell
PowerShell Download Cradle:
Base64-encode the command to avoid issues with special characters.
6. Embedding Encoded Commands
Split the base64-encoded string into chunks to bypass VBA's 255-character limit:
7. Testing
Start a Python web server to host
powercat.ps1
.Use a Netcat listener to catch the reverse shell.
Open the Word document and enable macros.
Summary
Objective: Exploit Word macros for initial footholds in enterprise networks.
Outcome: A reverse shell is achieved using a malicious macro that downloads and executes PowerCat via PowerShell.
Challenges:
Victim must enable macros.
Increased awareness and security controls make delivery harder.
Macros remain effective but increasingly challenging to deliver, necessitating alternative or supplementary attack vectors.
Last updated
Was this helpful?