Dump all the PE header information into a dictionary.
(self)
| 6480 | return dump.get_text() |
| 6481 | |
| 6482 | def dump_dict(self): |
| 6483 | """Dump all the PE header information into a dictionary.""" |
| 6484 | |
| 6485 | dump_dict = {} |
| 6486 | |
| 6487 | warnings = self.get_warnings() |
| 6488 | if warnings: |
| 6489 | dump_dict["Parsing Warnings"] = warnings |
| 6490 | |
| 6491 | dump_dict["DOS_HEADER"] = self.DOS_HEADER.dump_dict() |
| 6492 | dump_dict["NT_HEADERS"] = self.NT_HEADERS.dump_dict() |
| 6493 | dump_dict["FILE_HEADER"] = self.FILE_HEADER.dump_dict() |
| 6494 | |
| 6495 | image_flags = retrieve_flags(IMAGE_CHARACTERISTICS, "IMAGE_FILE_") |
| 6496 | |
| 6497 | dump_dict["Flags"] = [] |
| 6498 | for flag in image_flags: |
| 6499 | if getattr(self.FILE_HEADER, flag[0]): |
| 6500 | dump_dict["Flags"].append(flag[0]) |
| 6501 | |
| 6502 | if hasattr(self, "OPTIONAL_HEADER") and self.OPTIONAL_HEADER is not None: |
| 6503 | dump_dict["OPTIONAL_HEADER"] = self.OPTIONAL_HEADER.dump_dict() |
| 6504 | |
| 6505 | dll_characteristics_flags = retrieve_flags( |
| 6506 | DLL_CHARACTERISTICS, "IMAGE_DLLCHARACTERISTICS_" |
| 6507 | ) |
| 6508 | |
| 6509 | dump_dict["DllCharacteristics"] = [] |
| 6510 | for flag in dll_characteristics_flags: |
| 6511 | if getattr(self.OPTIONAL_HEADER, flag[0]): |
| 6512 | dump_dict["DllCharacteristics"].append(flag[0]) |
| 6513 | |
| 6514 | dump_dict["PE Sections"] = [] |
| 6515 | |
| 6516 | section_flags = retrieve_flags(SECTION_CHARACTERISTICS, "IMAGE_SCN_") |
| 6517 | for section in self.sections: |
| 6518 | section_dict = section.dump_dict() |
| 6519 | dump_dict["PE Sections"].append(section_dict) |
| 6520 | section_dict["Flags"] = [] |
| 6521 | for flag in section_flags: |
| 6522 | if getattr(section, flag[0]): |
| 6523 | section_dict["Flags"].append(flag[0]) |
| 6524 | |
| 6525 | section_dict["Entropy"] = section.get_entropy() |
| 6526 | if md5 is not None: |
| 6527 | section_dict["MD5"] = section.get_hash_md5() |
| 6528 | if sha1 is not None: |
| 6529 | section_dict["SHA1"] = section.get_hash_sha1() |
| 6530 | if sha256 is not None: |
| 6531 | section_dict["SHA256"] = section.get_hash_sha256() |
| 6532 | if sha512 is not None: |
| 6533 | section_dict["SHA512"] = section.get_hash_sha512() |
| 6534 | |
| 6535 | if hasattr(self, "OPTIONAL_HEADER") and hasattr( |
| 6536 | self.OPTIONAL_HEADER, "DATA_DIRECTORY" |
| 6537 | ): |
| 6538 | |
| 6539 | dump_dict["Directories"] = [] |
no test coverage detected