Skip to content

Instantly share code, notes, and snippets.

@1nnOc3nt
Created January 26, 2019 11:43
Show Gist options
  • Save 1nnOc3nt/774f45c6d639416f6f8e8479ad9f77de to your computer and use it in GitHub Desktop.
Save 1nnOc3nt/774f45c6d639416f6f8e8479ad9f77de to your computer and use it in GitHub Desktop.
from pwn import *
data = open('ch30.bin', 'rb').read()
with open('asm.txt', 'w') as f:
f.write(disasm(data[0xad1:0x3ec2b5])) #Disasm from begin to end of check()
f.close()
from base64 import *
byte = []
key = []
status = True #Because some of conditions just compare with input, so I use a flag here
with open('asm.txt', 'r') as f:
for line in f.readlines():
if (line.find('mov DWORD PTR [ebp-0x8]') != -1):
if (status):
key.append(0x0)
pos = line.find(',')
item = line[pos+1:-1]
byte.append(int(item,16))
status = True
elif (line.find('xor') != -1):
pos = line.find(',')
item = line[pos+1:-1]
key.append(int(item,16))
status = False
flag = ''
for i in range(len(byte)):
flag += chr(key[i+1]^byte[i])
with open('flag.exe', 'wb') as f: #I decoded base64 and found it was PE file
f.write(b64decode(flag))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment