Skip to content

Instantly share code, notes, and snippets.

@quend
Last active September 10, 2015 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quend/0d651e9c254514ddbdb8 to your computer and use it in GitHub Desktop.
Save quend/0d651e9c254514ddbdb8 to your computer and use it in GitHub Desktop.
import os
import sys
import time
import shutil
import tempfile
import subprocess
def log(msg):
sys.stdout.write("[+] %s\n" % msg)
def startInst(baseAddr, val):
fd = tempfile.NamedTemporaryFile(delete=False)
fd.write('bp 0x%08x ".printf \\"Loop counter in 0x1170: %%08x\\\\n\\", eax; gc"\n' % (baseAddr + 0x11c3))
fd.write('bp 0x%08x ".printf \\"Changing output to %02x\\\\n\\"; r eax=0x%02x; gc"\n' % (baseAddr + 0x1db4, val, val))
fd.write('bp 0x%08x ".printf \\" Loop counter=%%08x\\\\n\\", eax; .if (@eax = 0x10) { r eax=0x20; }; gc"\n' % (baseAddr + 0x18c0))
fd.write('g\n')
fd.close()
argv = [
r'c:\Program Files (x86)\Windows Kits\8.1\Debuggers\x86\cdb.exe',
'-G',
'-cf', fd.name,
'11.exe', '205']
p = subprocess.Popen(argv)
try:
log("cdb is running...")
while p.poll() is None:
pass
finally:
while p.poll() is None:
log("cdb still running. Terminating process...")
p.terminate()
os.unlink(fd.name)
for i in range(0, 16):
startInst(0x400000, i)
shutil.copyfile('secret.jpg', 'secret_%i.jpg' % i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment