Beispiel #1
0
 def guess_filepath(self):
     filepath = self.current_config.binary_filepath
     if os.path.isfile(filepath):
         return filepath
     filepath = ConfigHelpers.guess_filepath()
     if os.path.isfile(filepath):
         return filepath
     # give up
     return None
Beispiel #2
0
                return None

        idaapi.base2file(f.get_fp(), 0, 0, max_addr)
        f.close()
        return [("dump", 0, max_addr, 0, max_addr)]

    else:
        sections = []
        current_offset = 0
        with open(path, 'wb+') as f:
            # over all segments
            for n in range(idaapi.get_segm_qty()):
                seg = idaapi.getnseg(n)
                start_ea = seg.start_ea if hasattr(seg,
                                                   "start_ea") else seg.startEA
                end_ea = seg.end_ea if hasattr(seg, "end_ea") else seg.endEA
                size = end_ea - start_ea
                # print "Start: %x, end: %x, size: %x" % (start, end, end-start)
                # Only works with fixed IDAPython.
                f.write(idaapi.get_many_bytes_ex(start_ea, size)[0])
                sections.append((idaapi.get_segm_name(seg), start_ea, size,
                                 current_offset, size))
                current_offset += size
        dump_log.debug(repr(sections))
        return sections


if __name__ == '__main__':
    fname = ConfigHelpers.askfile("*.*", "Save to binary")
    dump_binary(fname)