idc parser works

This commit is contained in:
George Hotz 2014-09-06 14:07:12 -04:00
parent a55694ba63
commit 4dc84fbe3a
3 changed files with 56 additions and 19 deletions

View File

@ -0,0 +1,24 @@
import sys
from hexdump import hexdump
# name.id0 - contains contents of B-tree style database
# name.id1 - contains flags that describe each program byte
# name.nam - contains index information related to named program locations
# name.til - contains information about local type definitions
BTREE_PAGE_SIZE = 8192
#dat = open(sys.argv[1]).read()
#id0 = dat[0x104:]
dat = open("/Users/geohot/tmp/test.id0").read()
print hex(len(dat)), len(dat)/BTREE_PAGE_SIZE
for i in range(0, len(dat), BTREE_PAGE_SIZE):
hexdump(dat[i:i+0xC0])
print ""

View File

@ -0,0 +1,32 @@
import sys
import collections
def ghex(a):
if a == None:
return None
return hex(a).strip("L")
tags = collections.defaultdict(dict)
for ln in open(sys.argv[1]).read().split("\n"):
ln = ln.strip(" \n\t")
if ln.startswith("MakeName"):
(addr,name) = ln.split("(")[1].split(")")[0].split(",")
addr = addr.strip(" \t")
name = name.strip(" \t\"")
addr = ghex(int(addr, 16))
tags[addr]['name'] = name
tags = dict(tags)
print tags
# upload the tags
from socketIO_client import SocketIO, BaseNamespace
class QiraNamespace(BaseNamespace):
pass
sio = SocketIO('localhost', 3002)
qira = sio.define(QiraNamespace, '/qira')
qira.emit("settags", dict(tags))

View File

@ -1,19 +0,0 @@
import sys
from hexdump import hexdump
BTREE_PAGE_SIZE = 8192
#dat = open(sys.argv[1]).read()
#id0 = dat[0x104:]
dat = open("/Users/geohot/tmp/test.id0").read()
print hex(len(dat)), len(dat)/BTREE_PAGE_SIZE
for i in range(0, len(dat), BTREE_PAGE_SIZE):
hexdump(dat[i:i+0x20])
print ""