Skip to content

Instantly share code, notes, and snippets.

@notdodo
Created May 9, 2021 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notdodo/39e5acfa9cd992e94f68dc015a7c9702 to your computer and use it in GitHub Desktop.
Save notdodo/39e5acfa9cd992e94f68dc015a7c9702 to your computer and use it in GitHub Desktop.
Generate a VBA list of GUIDS to copy-paste into a Macro
#!/usr/bin/env python3
import sys
import uuid
def read_shellcode(filename):
shellcode = ""
ctr = 1
maxlen = 16
for b in open(sys.argv[1], "rb").read():
shellcode += "\\x{:02X}".format(b)
if ctr == maxlen:
shellcode += '" +\n"'
ctr = 0
ctr += 1
if __name__ == "__main__":
if len(sys.argv) < 2:
print(
"usage: {} file.bin\n".format(
sys.argv[0],
)
)
sys.exit(0)
dataIndex = 1
fileIndex = 1
uuids = ""
with open(sys.argv[1], "rb") as shellcode:
while True:
chunk = shellcode.read(16)
if chunk:
chunk = chunk.ljust(16, b"\00")
u = uuid.UUID(bytes_le=chunk[:16])
uuids += 'Data({}) = "{{{}}}"\n'.format(dataIndex, str(u))
dataIndex += 1
if dataIndex > 5000:
# Flush buffer
with open("GUID_{}.txt".format(fileIndex), "w") as fuuid:
fuuid.write(
"Dim Data({}) As String\n{}".format(dataIndex - 1, uuids)
)
fileIndex += 1
uuids = ""
dataIndex = 1
else:
with open("GUID_{}.txt".format(fileIndex), "w") as fuuid:
fuuid.write(
"Dim Data({}) As String\n{}".format(dataIndex - 1, uuids)
)
fileIndex += 1
uuids = ""
dataIndex = 1
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment