Created
December 13, 2019 21:54
-
-
Save byt3bl33d3r/1e3cbe24ea7cfd407617ff8e2adc1fe8 to your computer and use it in GitHub Desktop.
Convert raw shellcode to a VBA hex string (for Macro payloads)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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