def print_macho_header(header, oid, opts, embedded=False): src = api.source(oid) file_size = api.get_field("file_meta", oid, "size") names = api.get_names_from_oid(oid) indent = False tab = "" if embedded: indent = True tab = "\t" if embedded: print "%s Embedded Macho-O Header for %s %s" % (tab, name(oid), oid) else: print " Macho-O Header for %s %s" % (name(oid), oid) if not header: print " <EMPTY>" print " --------------------------" return entry_string = "" for e in header.get_entries(): entry_string += "%s (%s) " % (hex(e), (e)) print "%s - File Size: %s" % (tab, file_size) # FIXME get embedded file size print "%s - Addr Size: %s" % (tab, header.insn_mode) print "%s - Magic: %s" % (tab, header.magic) print "%s - Big Endian: %s" % (tab, header.big_endian) print "%s - Machine: %s" % (tab, header.machine) print "%s - UUID: %s" % (tab, header.uuid) print "%s - Entry points: %s" % (tab, entry_string) print_sections(header, opts, indent) macho_import_table(header, opts)
def elf_header(oid, opts): header = api.get_field("object_header", [oid], "header") src = api.source(oid) file_size = api.get_field("file_meta", oid, "size") names = api.get_names_from_oid(oid) print " ELF Header for %s %s" % (name(oid), oid) if not header: print " <EMPTY>" print " --------------------------" return addr_size = "32 bit" if header.is_64bit(): addr_size = "64 bit" entry_string = "" for e in header.get_entries(): entry_string += "%s (%s) " % (hex(e), (e)) print " - File Size: %s" % (file_size) print " - Addr Size: %s" % (addr_size) print " - Image Base: %s (%s)" % (hex(header.image_base), header.image_base) print " - Image Size: %s " % (header.image_size) print " - Code Size: %s " % (header.code_size) print " - Code Base: %s (%s)" % (hex(header.code_base), header.code_base) print " - Machine: %s" % (header.machine) print " - OS Version: %s" % (header.os_version) print " - Entry points: %s" % (entry_string) print_sections(header, opts) elf_import_table(header, opts)
def print_membership(membership_cids): print " --- Membership: ---" if not membership_cids: print " <EMPTY>" return for cid in membership_cids: name = api.get_colname_from_oid(cid) print " - %s: " % name for oid in membership_cids[cid]: names = ", ".join(list(api.get_names_from_oid(oid))) print " - %s : %s" % (oid, names)
def on_collection_select(self, event): try: index = int(self.collection_box.curselection()[0]) self.current_collection = self.collection_box.get(index) self.file_name_box.delete(first=0, last=tk.END) collection_id = api.get_cid_from_name(self.current_collection) collection_features = api.retrieve('collections', collection_id) self.oids = collection_features['oid_list'] for oid in self.oids: file_names = list(api.get_names_from_oid(oid)) file_name = ', '.join(file_names) self.file_name_box.insert(tk.END, file_name) except IndexError: print "Index Error..."
def launch_oid_browser(self): ''' brings up a new gui frame allowing the user to set the oid. sets self.oid using the return value of the dialog. ''' dialog = OidSelectDialog(self) self.oid = dialog.result if self.oid: self.clear_displays() self.create_display_strings(self.oid) self.display_file_data(self.oid) file_names = list(api.get_names_from_oid(self.oid)) file_name = ', '.join(file_names) self.master.title(file_name)
def osx_header(oid, opts): header = api.get_field("object_header", [oid], "header") src = api.source(oid) file_size = api.get_field("file_meta", oid, "size") names = api.get_names_from_oid(oid) print " OSX Universal Header for %s %s" % (name(oid), oid) if not header: print " <EMPTY>" print " --------------------------" return print " - File Size: %s" % (file_size) print " - Magic: %s" % (header.magic) print " - Big Endian: %s" % (header.big_endian) print " - Embedded Files: %s" % (header.num_embedded) for header in header.embedded: print " -------------------------------------" print_macho_header(header, oid, opts, embedded=True) print " -------------------------------------" print
def display_filenames(self, oid): file_names = list(api.get_names_from_oid(oid)) file_name = ', '.join(file_names) self.file_name_box.insert(tk.END, file_name) if self.file_count.get(): self.file_count.set(int(self.file_count.get())+1)