Skip to content

Instantly share code, notes, and snippets.

@taida957789
Created January 8, 2018 04:55
Show Gist options
  • Save taida957789/c49a80e4c2186e0bd4e4ed11ae097d9f to your computer and use it in GitHub Desktop.
Save taida957789/c49a80e4c2186e0bd4e4ed11ae097d9f to your computer and use it in GitHub Desktop.
getOpcodes.py
import idautils
from idaapi import *
import re
sc = idautils.Strings()
packets = {}
for s in sc:
value = str(s)
if re.match("eTr[a-zA-Z0-9]+Ack", value):
xrefs = idautils.XrefsTo(s.ea)
for xref in xrefs:
opcode = GetMnem(xref.frm)
if opcode == 'lea':
opcod2 = GetMnem(xref.frm-0x4C)
if opcod2 == 'mov':
packets[value.replace('eTr', '')] = hex(GetOperandValue(xref.frm-0x4C, 1)).replace('L', '')
with open('G:\\packets.txt', 'wb') as f:
for opcode in packets:
f.write(opcode + '=' + packets[opcode] + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment