Exemplo n.º 1
0
def t_INT(t):
	r'\d+'
	try:
		t.value = int(t.value)
	except ValueError:
		pyc_log.log('integer value invalid: %s' % t.value)
		t.value = 0

	return t
Exemplo n.º 2
0
def extract_dbg_map(elf):
    dbg_sec = elf.get_section_by_name(b".pyc_dbg")
    if not dbg_sec:
        raise ElfError("pyc debug symbol section not found")

    if dbg_sec.is_null():
        raise ElfError("pyc debug symbol section is null")

    log("pyc_dbg sec header: %s" % repr(dbg_sec.header))
    return pickle.loads(dbg_sec.data())
Exemplo n.º 3
0
def map_blocs(elf, dbg_map):
    bmap = {}

    if len(dbg_map["blocs"]) < 1:
        raise ArgumentError("no blocs defined in dbg_map")

    sec = elf.get_section_by_name(b".symtab")
    if not sec or not isinstance(sec, SymbolTableSection):
        raise ElfError("invalid symbol table")

    for sym in sec.iter_symbols():
        if sym.name in dbg_map["blocs"].keys():
            log("map bloc %s" % sym.name)
            # log(cont_pp(StringIO(), sym).getvalue())

            bmap[sym.name] = {"addr": sym.entry.st_value, "size": sym.entry.st_size}

    if len(bmap) != len(dbg_map["blocs"]):
        raise ElfError("could not map blocs: %r" % (set(dbg_map["blocs"].keys()) - set(bmap.keys())))

    return bmap
Exemplo n.º 4
0
def t_error(t):
	pyc_log.log("illegal character '%s'" % t.value[0])