Exemple #1
0
 def as_dictionary(self):
     name = self.get_filename()
     result = {}
     result['name'] = name[:-5] if name.endswith('.iexe') else name[:-4]
     result['peheader'] = {}
     localetable = UF.get_locale_tables(categories=["PE"])
     coffheader = self.get_coff_header()
     optionalheader = self.get_optional_header()
     for p in coff_header_attributes:
         propertyvalue = coffheader.get(p)
         if p in valuedescriptor:
             propertyvalue = valuedescriptor[p](propertyvalue)
         result['peheader'][p] = resultp = {}
         resultp['value'] = propertyvalue
         resultp['heading'] = localetable['peheader'][p]
     for p in optional_header_attributes:
         propertyvalue = optionalheader.get(p)
         if p in valuedescriptor:
             propertyvalue = valuedescriptor[p](propertyvalue)
         result['peheader'][p] = resultp = {}
         resultp['value'] = propertyvalue
         resultp['heading'] = localetable['peheader'][p]
     result['peheader']['file-characteristics'] = resultfc = {}
     resultfc['value'] = ','.join(self.str_file_characteristics())
     resultfc['heading'] = 'File characteristics'
     result['import_tables'] = {}
     for table in self.get_import_tables():
         result['import_tables'][table.dllname] = table.as_dictionary()
     result['section_headers'] = {}
     for header in self.get_section_headers():
         result['section_headers'][header.name] = header.as_dictionary()
     return result
 def as_dictionary(self):
     ## note: update for multiple string tables
     ##       add relocation tables
     try:
         result = {}
         result['name'] = self.app.filename
         result['fileheader'] = {}
         result['programheaders'] = []
         result['sectionheaders'] = []
         fileheader = self.get_file_header()
         localetable = UF.get_locale_tables(categories=["ELF"])
         for p in fileheader_attributes:
             propertyvalue = fileheader.get(p)
             if p in valuedescriptor:
                 propertyvalue = valuedescriptor[p](propertyvalue)
             result['fileheader'][p] = {}
             result['fileheader'][p]['value'] = propertyvalue
             result['fileheader'][p]['heading'] = localetable['elfheader'][p]
         for p in self.programheaders:
             result['programheaders'].append(p.as_dictionary())
         for s in self.sectionheaders:
             result['sectionheaders'].append(s.as_dictionary())
         if  self.has_string_table():
             result['stringtables'] = {}
             for s in self.get_string_tables():
                 result['stringtables'][s.get_name()] = s.as_dictionary()
         if self.has_symbol_table():
             result['symboltable'] = self.get_symbol_table().as_dictionary()
         if self.has_dynamic_symbol_table():
             result['dynamicsymboltable'] = self.get_dynamic_symbol_table().as_dictionary()
         if self.has_dynamic_table():
             result['dynamictable'] = self.get_dynamic_table().as_dictionary()
         return result
     except KeyError as e:
         raise UF.KTKeyError(str(e))
 def as_dictionary(self) -> Dict[str, Any]:
     name = self.filename
     result: Dict[str, Any] = {}
     result['name'] = name[:-5] if name.endswith('.iexe') else name[:-4]
     result['peheader'] = {}
     localetable = UF.get_locale_tables(categories=["PE"])
     coffheader = self.coff_header
     optionalheader = self.optional_header
     for p in coff_header_attributes:
         propertyvalue = coffheader.get(p)
         if p in valuedescriptor:
             propertyvalue = valuedescriptor[p](propertyvalue)
         result['peheader'][p] = resultp = {}
         resultp['value'] = propertyvalue
         resultp['heading'] = localetable['peheader'][p]
     for p in optional_header_attributes:
         propertyvalue = optionalheader.get(p)
         if p in valuedescriptor:
             propertyvalue = valuedescriptor[p](propertyvalue)
         result['peheader'][p] = resultp = {}
         resultp['value'] = propertyvalue
         resultp['heading'] = localetable['peheader'][p]
     result['peheader']['file-characteristics'] = resultfc = {}
     resultfc['value'] = ','.join(self.file_characteristics_text)
     resultfc['heading'] = 'File characteristics'
     result['import_tables'] = {}
     for tablename in self.import_tables:
         table = self.import_tables[tablename]
         result['import_tables'][table.dllname] = table.as_dictionary()
     result['section_headers'] = {}
     for h in self.section_headers:
         header = self.section_headers[h]
         result['section_headers'][header.name] = header.as_dictionary()
     return result
Exemple #4
0
 def disassembly_as_dictionary(self) -> Dict[str, Any]:
     localetable = UF.get_locale_tables(categories=["ResultMetrics"])
     result: Dict[str, Any] = {}
     result['instrcount'] = self.instruction_count
     result['unknown'] = self.unknown_instructions
     result['functioncount'] = self.function_count
     result['coverage'] = self.pcoverage
     return result
Exemple #5
0
 def as_dictionary(self):
     result = {}
     result['name'] = self.name
     localetable = UF.get_locale_tables(tables=[("PE", "pesectionheader")])
     for p in section_header_attributes:
         propertyvalue = self.xnode.get(p, '0x0')
         result[p] = {}
         result[p]['value'] = propertyvalue
         result[p]['heading'] = localetable['pesectionheader'][p]
     result['section-characterists'] = sectionxs = {}
     sectionxs['value'] = ','.join(self.str_characteristics())
     sectionxs['heading'] = 'Section characteristics'
     return result
 def as_dictionary(self) -> Dict[str, Any]:
     result: Dict[str, Any] = {}
     result["name"] = self.name
     localetable = UF.get_locale_tables(tables=[("PE", "pesectionheader")])
     for p in section_header_attributes:
         propertyvalue = self.xnode.get(p, "0x0")
         result[p] = {}
         result[p]["value"] = propertyvalue
         result[p]["heading"] = localetable["pesectionheader"][p]
     result["section-characterists"] = sectionxs = {}
     sectionxs["value"] = ",".join(self.characteristics_text)
     sectionxs["heading"] = "Section characteristics"
     return result
Exemple #7
0
 def analysis_as_dictionary(self) -> Dict[str, Any]:
     localetable = UF.get_locale_tables(categories=["ResultMetrics"])
     result: Dict[str, Any] = {}
     result['datetime'] = self.date_time
     result['espp'] = self.esp_precision
     result['readsp'] = self.reads_precision
     result['writesp'] = self.writes_precision
     result['unrjumps'] = self.unresolved_jumps
     result['calls'] = self.calls_count
     result['unrcalls'] = self.unresolved_calls
     result['nosummaries'] = self.no_summary
     result['dllcalls'] = self.dll_calls
     result['inlinedcalls'] = self.inlined_calls
     result['analysistime'] = self.analysis_time
     result['iterations'] = self.run_count
     return result
 def as_dictionary(self) -> Dict[str, Any]:
     result: Dict[str, Any] = {}
     result["index"] = self.index
     localetable = UF.get_locale_tables(tables=[("ELF",
                                                 "elfprogramheader")])
     for p in programheader_attributes:
         propertyvalue = self.get_default_property_value(p, "0x0")
         if p == "p_type":
             propertyvalue = get_program_header_type(int(propertyvalue, 16))
         if p == "p_flags":
             propertyvalue += " (" + get_program_header_flags(
                 propertyvalue) + ")"
         result[p] = {}
         result[p]["value"] = propertyvalue
         result[p]["heading"] = localetable["elfprogramheader"][p]
     return result
Exemple #9
0
 def as_dictionary(self):
     result = {}
     result['index'] = int(self.xnode.get('index'))
     localetable = UF.get_locale_tables(tables=[("ELF",
                                                 "elfprogramheader")])
     for p in programheader_attributes:
         propertyvalue = self.xnode.get(p, '0x0')
         if p == 'p_type':
             propertyvalue = get_program_header_type(int(propertyvalue, 16))
         if p == 'p_flags':
             propertyvalue += ' (' + get_program_header_flags(
                 propertyvalue) + ')'
         result[p] = {}
         result[p]['value'] = propertyvalue
         result[p]['heading'] = localetable['elfprogramheader'][p]
     return result
 def as_dictionary(self) -> Dict[str, Any]:
     # note: update for multiple string tables
     #       add relocation tables
     try:
         result: Dict[str, Any] = {}
         result["name"] = self.filename
         result["fileheader"] = {}
         result["programheaders"] = []
         result["sectionheaders"] = []
         fileheader = self.xfile_header
         localetable = UF.get_locale_tables(categories=["ELF"])
         attributes = fileheader_attributes
         if self.is_object_file():
             attributes = objectfileheader_attributes
         for p in attributes:
             propertyvalue = fileheader.get(p)
             if propertyvalue is None:
                 raise UF.CHBError("Property " + p +
                                   " not found in file-header")
             if p in valuedescriptor:
                 propertyvalue = valuedescriptor[p](propertyvalue)
             result["fileheader"][p] = {}
             result["fileheader"][p]["value"] = propertyvalue
             result["fileheader"][p]["heading"] = localetable["elfheader"][
                 p]
         if not self.is_object_file():
             for ph in self.programheaders:
                 result["programheaders"].append(ph.as_dictionary())
         for s in self.sectionheaders:
             result["sectionheaders"].append(s.as_dictionary())
         if self.has_string_table():
             result["stringtables"] = {}
             for ss in self.get_string_tables():
                 result["stringtables"][ss.name] = s.as_dictionary()
         if self.has_symbol_table():
             result["symboltable"] = self.get_symbol_table().as_dictionary()
         if self.has_dynamic_symbol_table():
             dynsymtable = self.get_dynamic_symbol_table()
             result["dynamicsymboltable"] = dynsymtable.as_dictionary()
         if self.has_dynamic_table():
             result["dynamictable"] = self.get_dynamic_table(
             ).as_dictionary()
         return result
     except KeyError as e:
         raise UF.CHBError("KeyError in ELFHeader: " + str(e))
 def as_dictionary(self) -> Dict[str, Any]:
     result: Dict[str, Any] = {}
     result["index"] = self.index
     result["name"] = self.name
     localetable = UF.get_locale_tables(tables=[("ELF",
                                                 "elfsectionheader")])
     for p in sectionheader_attributes:
         propertyvalue = self.get_default_attribute_value(p, "0x0")
         if p == "sh_type":
             propertyvalue = get_section_header_type(propertyvalue)
         if p == "sh_flags":
             flags = get_section_header_flags(propertyvalue)
             if len(flags) > 0:
                 propertyvalue += " (" + str(flags) + ")"
         result[p] = {}
         result[p]["value"] = propertyvalue
         result[p]["heading"] = localetable["elfsectionheader"][p]
     return result
 def as_dictionary(self):
     result = {}
     result['index'] = int(self.xnode.get('index'))
     result['name'] = self.xnode.get('name')
     localetable = UF.get_locale_tables(tables=[("ELF",
                                                 "elfsectionheader")])
     for p in sectionheader_attributes:
         propertyvalue = self.xnode.get(p, '0x0')
         if p == 'sh_type':
             propertyvalue = get_section_header_type(propertyvalue)
         if p == 'sh_flags':
             flags = get_section_header_flags(propertyvalue)
             if len(flags) > 0:
                 propertyvalue += ' (' + str(flags) + ')'
         result[p] = {}
         result[p]['value'] = propertyvalue
         result[p]['heading'] = localetable['elfsectionheader'][p]
     return result