Macro creation

Creation of a malicious macro is a dat bit hard so here’s an explanation.

  1. Create a blank .doc or .docm file - “Word 97-2003 Document”. You could also run it in .docx but it’s not persistant and loads the macro from a remote global template (usually on attacker’s server).
  2. In Word go to View -> Macros -> Name it -> Macros in: Document-> Create.
  3. Use a Powershell payload to get a rev shell. I like to use this PowerShell powercat reverse shell and fetch it from my attack python server.
  4. After you adjusted the command, Base64 UTF-16LE encode it for correct Powershell support - make sure no line-breaks are present.
  5. Then, pass the encoded string into the Base64 string splitter so it can be spliced into macro-friendly snippets and later concatenate them back together in the Str variable.
  6. Now, put all of that data into the specified spot in the macro. You can use this simple Microsoft Office macro.
  7. Lastly, run you favorite listener, deliver the payload with like phishing (swaks), SMB or similar and wait for a connection.

References

Used in: JobTwo
Similar techniques: Restore corrupted office files