Ejemplo n.º 1
0
    def req_rln(self, hash):
        raddr, rbase, offset, base = hash['raddr'], hash['rbase'], hash[
            'offset'], hash['base']

        rs_debug("rln: 0x%x -  0x%x - 0x%x - 0x%x" %
                 (raddr, rbase, offset, base))

        addr = self.rebase(rbase, raddr)
        if not addr:
            rs_log("could not rebase this address (0x%x)" % raddr)
            return

        sym = idaapi.get_func_name(addr)
        if sym:
            sym = self.demangle(sym)
            func = idaapi.get_func(addr)
            if not func:
                rs_log("could not find func for 0x%x" % addr)
                return

            lck = idaapi.lock_func(func)

            limits = idaapi.area_t()
            if idaapi.get_func_limits(func, limits):
                if limits.start_ea != addr:
                    if (addr > limits.start_ea):
                        sym = "%s%s0x%x" % (sym, "+", addr - limits.start_ea)
                    else:
                        sym = "%s%s0x%x" % (sym, "-", limits.start_ea - addr)
            lck = None
        else:
            sym = idc.get_name(addr, ida_name.GN_VISIBLE)
            if sym:
                sym = self.demangle(sym)

        if sym:
            self.notice_broker('cmd', "\"cmd\":\"%s\"" % sym)
            rs_debug("resolved symbol: %s" % sym)
        else:
            rs_log("could not resolve symbol for address 0x%x" % addr)
Ejemplo n.º 2
0
    def req_rln(self, hash):
        raddr, rbase, offset, base = hash['raddr'], hash['rbase'], hash[
            'offset'], hash['base']

        print("[*] 0x%x -  0x%x - 0x%x - 0x%x" % (raddr, rbase, offset, base))

        addr = self.rebase(rbase, raddr)
        if not addr:
            print("[*] could not rebase this address (0x%x)" % raddr)
            return

        sym = idaapi.get_func_name(addr)
        if sym:
            sym = self.demangle(sym)
            func = idaapi.get_func(addr)
            if not func:
                print("[*] could not find func for 0x%x" % addr)
                return

            lck = idaapi.lock_func(func)

            limits = idaapi.area_t()
            if idaapi.get_func_limits(func, limits):
                if limits.startEA != addr:
                    if (addr > limits.startEA):
                        sym = "%s%s0x%x" % (sym, "+", addr - limits.startEA)
                    else:
                        sym = "%s%s0x%x" % (sym, "-", limits.startEA - addr)
            lck = None
        else:
            sym = idc.Name(addr)
            if sym:
                sym = self.demangle(sym)

        if sym:
            self.notice_broker("cmd", "\"cmd\":\"%s\"" % sym)
            print("[*] resolved symbol: %s" % sym)
        else:
            print("[*] could not resolve symbol for address 0x%x" % addr)
Ejemplo n.º 3
0
    def req_rln(self, hash):
        raddr, rbase, offset, base = hash["raddr"], hash["rbase"], hash["offset"], hash["base"]

        print ("[*] 0x%x -  0x%x - 0x%x - 0x%x" % (raddr, rbase, offset, base))

        addr = self.rebase(rbase, raddr)
        if not addr:
            print ("[*] could not rebase this address (0x%x)" % raddr)
            return

        sym = idaapi.get_func_name(addr)
        if sym:
            sym = self.demangle(sym)
            func = idaapi.get_func(addr)
            if not func:
                print ("[*] could not find func for 0x%x" % addr)
                return

            lck = idaapi.lock_func(func)

            limits = idaapi.area_t()
            if idaapi.get_func_limits(func, limits):
                if limits.startEA != addr:
                    if addr > limits.startEA:
                        sym = "%s%s0x%x" % (sym, "+", addr - limits.startEA)
                    else:
                        sym = "%s%s0x%x" % (sym, "-", limits.startEA - addr)
            lck = None
        else:
            sym = idc.Name(addr)
            if sym:
                sym = self.demangle(sym)

        if sym:
            self.notice_broker("cmd", '"cmd":"%s"' % sym)
            print ("[*] resolved symbol: %s" % sym)
        else:
            print ("[*] could not resolve symbol for address 0x%x" % addr)
Ejemplo n.º 4
0
from idautils import *

if __name__ == "__main__":
    filename = AskFile(0, "*.osym", "Choose an oSym file to apply")
    if filename != None:
        f = open(filename, "rb")
        i = 0
        #Batch(1)
        while True:
            line = f.readline()
            if len(line) == 0:
                break
            elif i > 0:
                begin, end, func_name = line.split(";", 2)
                begin = int(begin, 16)
                end = int(end, 16)
                func_name = func_name.rstrip()
                index = func_name.find("::~")
                if index != -1:
                    func_name = "%s::%s_dtor" % (func_name[0:index], func_name[index+3:])

                func = idaapi.get_func(begin)
                limits = idaapi.area_t()
                if idaapi.get_func_limits(func, limits):
                    if limits.startEA == begin:
                        print "Renaming 0x%x to %s" % (begin, func_name)
                        MakeName(begin, func_name)
            i += 1
        #Batch(0)