Skip to content

Instantly share code, notes, and snippets.

@1nnOc3nt
Created January 26, 2019 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1nnOc3nt/ed8e96acf01c42f9672e5e213fae66fe to your computer and use it in GitHub Desktop.
Save 1nnOc3nt/ed8e96acf01c42f9672e5e213fae66fe to your computer and use it in GitHub Desktop.
from capstone import *
data = open('flag.exe', 'rb').read()
md = Cs(CS_ARCH_X86, CS_MODE_64)
with open('asm.txt', 'w') as f:
for i in md.disasm(data[0x914:0x85fd], 0x00401514): #Capstone read from data address, not the virtual address
f.write("0x%x:\t%s\t%s\n" %(i.address, i.mnemonic, i.op_str))
f.close()
byte = []
key = []
status = True
with open('asm.txt', 'r') as f:
for line in f.readlines():
if (line.find('mov dword ptr [rbp - 0x10]') != -1):
if (status):
key.append(0x0)
pos = line.find(',')
item = line[pos+2:-1]
byte.append(int(item,16))
status = True
elif (line.find('xor') != -1):
pos = line.find(',')
item = line[pos+2:-1]
key.append(int(item,16))
status = False
flag = ''
for i in range(len(byte)):
flag += chr(key[i+1]^byte[i])
print flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment