示例#1
0
文件: binary.py 项目: jokerNi/reverse
    def __init__(self,
                 filename,
                 raw_type=None,
                 raw_base=None,
                 raw_big_endian=None):
        self.__binary = None
        self.reverse_symbols = {}
        self.symbols = {}
        self.type = None

        if raw_type != None:
            import lib.fileformat.raw as LIB_RAW
            self.__binary = LIB_RAW.Raw(filename, raw_type, raw_base,
                                        raw_big_endian)
            self.type = T_BIN_RAW
            return

        start = time.clock()
        self.load_magic(filename)

        if self.type == T_BIN_ELF:
            import lib.fileformat.elf as LIB_ELF
            self.__binary = LIB_ELF.ELF(self, filename)
        elif self.type == T_BIN_PE:
            import lib.fileformat.pe as LIB_PE
            self.__binary = LIB_PE.PE(self, filename)
        else:
            raise ExcFileFormat()

        elapsed = time.clock()
        elapsed = elapsed - start
        debug__("Binary loaded in %fs" % elapsed)
示例#2
0
    def __init__(self, mem, filename, raw_type=None, raw_base=None, raw_big_endian=None):
        self.__binary = None
        self.reverse_symbols = {} # ad -> name
        self.symbols = {} # name -> ad
        self.section_names = {}
        self.type = None

        self._abs_sections = {} # start section -> SectionAbs
        self._sorted_sections = [] # bisect list, contains section start address

        if raw_type != None:
            import lib.fileformat.raw as LIB_RAW
            self.__binary = LIB_RAW.Raw(self, filename, raw_type,
                                        raw_base, raw_big_endian)
            self.type = T_BIN_RAW
            return

        start = time()
        self.load_magic(filename)

        if self.type == T_BIN_ELF:
            import lib.fileformat.elf as LIB_ELF
            self.__binary = LIB_ELF.ELF(mem, self, filename)
        elif self.type == T_BIN_PE:
            import lib.fileformat.pe as LIB_PE
            self.__binary = LIB_PE.PE(mem, self, filename)
        else:
            raise ExcFileFormat()

        elapsed = time()
        elapsed = elapsed - start
        debug__("Binary loaded in %fs" % elapsed)
示例#3
0
    def __init__(self, filename, raw_type=None):
        self.__binary = None
        self.reverse_symbols = {}
        self.symbols = {}
        self.type = None

        if raw_type != None:
            import lib.fileformat.raw as LIB_RAW
            self.__binary = LIB_RAW.Raw(filename, raw_type)
            self.type = T_BIN_RAW
            return

        start = time.clock()
        self.load_magic(filename)

        if self.type == T_BIN_ELF:
            import lib.fileformat.elf as LIB_ELF
            self.__binary = LIB_ELF.ELF(self, filename)
        elif self.type == T_BIN_PE:
            import lib.fileformat.pe as LIB_PE
            self.__binary = LIB_PE.PE(self, filename)
        else:
            raise ExcFileFormat()

        elapsed = time.clock()
        elapsed = elapsed - start
        debug__("Binary loaded in %fs" % elapsed)

        start = time.clock()

        self.__binary.load_static_sym()
        self.__binary.load_dyn_sym()
        self.__binary.load_data_sections()

        elapsed = time.clock()
        elapsed = elapsed - start
        debug__("Found %d symbols in %fs" % (len(self.symbols), elapsed))