Microsoft micros
Making Macros in MS Word
Microsoft Office applications like Word and Excel allow users to embed macros, which are a series of commands and instructions grouped to accomplish a task programmatically.
You need to open a Word file and save it in .docm file type.

To make macros, Goto View tab > macros.


Let's enter MyMacro as the name in the Macro Name section, then select the mymacro document from the Macros in drop-down menu. This document is where the macro will be saved. Finally, click Create to insert a simple macro framework into the document.

We will be presented with the below windows.

General structute of micro is presented to us.
Since Office macros are not executed automatically, we must use the predefined AutoOpen macro and Document_Open event. These procedures can call a custom procedure to run code when a Word document is opened. They differ slightly depending on how Microsoft Word or the document is opened. Each covers specific cases that the other does not, which is why both are used.
Above code Macro automatically executes powershell.exe after opening the Document.
Reverse shell
We can get the reverse shell from a macro using powershell and Powercat.ps1.
Encode the above command to base64 using the below method.

In many scripting or macro environments—especially VBA macros—there are limits on how long a single string literal can be or how many characters are allowed per line. Splitting a large base64-encoded command into smaller chunks ensures that you can work around those line-length or character-count restrictions, making the code valid and easier to handle within the macro environment. Additionally, splitting it into chunks can sometimes improve readability and maintainability of the script. So, We will split it using python code below.

Final macro for a reverse shell.
CreateObject("Wscript.Shell").Run Str: This opens powershell and runs content stored in str variable.
Save this macro and start the listener.
Last updated