Created
May 3, 2024 12:26
-
-
Save knez/4d80ae99313a454db7de134d4d521348 to your computer and use it in GitHub Desktop.
Dump dotnet resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import dnfile | |
| """ | |
| Dump all raw byte .NET resources | |
| """ | |
| def dump(res_name, res_data): | |
| print(f"[+] Dumping resource '{res_name}'") | |
| with open(res_name, 'wb') as f: | |
| f.write(res_data) | |
| def main(): | |
| pe = dnfile.dnPE(sys.argv[1]) | |
| for r in pe.net.resources: | |
| if isinstance(r.data, bytes): | |
| dump(r.name, r.data) | |
| elif isinstance(r.data, dnfile.resource.ResourceSet): | |
| if not r.data.entries: | |
| continue | |
| for entry in r.data.entries: | |
| if entry.data: | |
| dump(entry.name, entry.data) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment