Last active
September 10, 2015 08:02
-
-
Save quend/0d651e9c254514ddbdb8 to your computer and use it in GitHub Desktop.
This file contains 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 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