Created
January 26, 2019 11:43
-
-
Save 1nnOc3nt/774f45c6d639416f6f8e8479ad9f77de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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