Skip to content

Instantly share code, notes, and snippets.

@byt3bl33d3r
Created December 13, 2019 21:54
Show Gist options
  • Save byt3bl33d3r/1e3cbe24ea7cfd407617ff8e2adc1fe8 to your computer and use it in GitHub Desktop.
Save byt3bl33d3r/1e3cbe24ea7cfd407617ff8e2adc1fe8 to your computer and use it in GitHub Desktop.
Convert raw shellcode to a VBA hex string (for Macro payloads)
import binascii
import sys
import io
def gen_line(hex_string):
return f"b = b & \"{hex_string}\"\n"
with open(sys.argv[1], "rb") as asm:
asm_hex = io.StringIO(binascii.hexlify(asm.read()).decode())
vba = "Dim b As String\n"
while True:
some_hex = asm_hex.read(300)
if not some_hex:
break
vba += gen_line(some_hex)
print(vba)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment