Skip to content

Instantly share code, notes, and snippets.

@hhc0null
Created May 18, 2015 01:56
Show Gist options
  • Save hhc0null/8106cdbfb1ddc0af7b35 to your computer and use it in GitHub Desktop.
Save hhc0null/8106cdbfb1ddc0af7b35 to your computer and use it in GitHub Desktop.
[DEFCON_23_Quals-misc-patcher-3pts]
#!/usr/bin/env python2
import binascii
import re
import struct
import sys
uh = lambda x: binascii.unhexlify(x)
hx = lambda x: binascii.hexlify(x)
p = lambda x: struct.pack("<I", x)
u = lambda x: struct.unpack("<I", x)
data = ""
with open("./cybergrandsandbox_e722a7ec2ad46b9fb8472db37cb95713", "rb") as f:
data = f.read()
hexstr = hx(data)
hexstr = hexstr.replace(hx(p(0x1388)), hx(p(0x1388+(0x2000*100))))
hexstr = hexstr.replace(hx(p(0x138c)), hx(p(0x138c+(0x2000*100))))
hexstr = hexstr.replace(hx(p(0x1390)), hx(p(0x1390+(0x2000*100))))
hexstr = hexstr.replace(hx(p(0x1394)), hx(p(0x1394+(0x2000*100))))
with open("./patched", "wb") as f:
f.write(uh(hexstr))
@hhc0null
Copy link
Author

I know this is a bonus problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment