{"id":18318475,"url":"https://github.com/sashs/filebytes","last_synced_at":"2025-04-30T03:49:47.198Z","repository":{"id":84256510,"uuid":"52561042","full_name":"sashs/filebytes","owner":"sashs","description":"Library to read and edit files in the following formats: Executable and Linking Format (ELF), Portable Executable (PE), MachO and OAT (Android Runtime)","archived":false,"fork":false,"pushed_at":"2024-09-04T11:45:40.000Z","size":4724,"stargazers_count":131,"open_issues_count":7,"forks_count":25,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-30T03:49:41.159Z","etag":null,"topics":["elf","mach-o","oat","pe","pe32","python"],"latest_commit_sha":null,"homepage":"https://scoding.de/filebytes-introduction","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sashs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-25T22:21:17.000Z","updated_at":"2025-03-30T21:20:37.000Z","dependencies_parsed_at":"2023-05-24T03:45:25.744Z","dependency_job_id":null,"html_url":"https://github.com/sashs/filebytes","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashs%2Ffilebytes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashs%2Ffilebytes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashs%2Ffilebytes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashs%2Ffilebytes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sashs","download_url":"https://codeload.github.com/sashs/filebytes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251638760,"owners_count":21619663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elf","mach-o","oat","pe","pe32","python"],"created_at":"2024-11-05T18:09:43.858Z","updated_at":"2025-04-30T03:49:47.171Z","avatar_url":"https://github.com/sashs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"FileBytes\n================\n\nClasses/Types to read and edit the following file formats:\n- Executable and Linking Format (ELF),\n- Portable Executable (PE) and\n- MachO\n- OAT (Android Runtime)\n\nInstall\n-------\n\nInstall FileBytes\n\n    $ python setup.py install\n\nOr install with PyPi\n\n    $ pip install filebytes\n\nSamples\n-------\n\nParsing ELF file\n```python\nfrom filebytes.elf import *\nelf_file = ELF('test-binaries/ls-x86')\n\nelf_header = elf_file.elfHeader\nsections = elf_file.sections\nsegments = elf_file.segments # elf_file.programHeaders does the same\n```\n\nParsing PE file\n```python\nfrom filebytes.pe import *\npe_file = PE('test-binaries/cmd-x86.exe')\n\nimage_dos_header = pe_file.imageDosHeader\nimage_nt_headers = pe_file.imageNtHeaders\nsections = pe_file.sections\ndata_directory = pe_file.dataDirectory\n\nimport_directory = data_directory[ImageDirectoryEntry.IMPORT]\nexport_directory = data_directory[ImageDirectoryEntry.EXPORT]\n```\n\nParsing MachO file\n```python\nfrom filebytes.mach_o import *\nmacho_file = MachO('test-binaries/ls-macho-x86_64')\n\nmach_header = macho_file.machHeader\nload_commands = macho_file.loadCommands\n```\n\nParsing OAT file, read DEX files and save them\n```python\nfrom filebytes.oat import *\n\noat = OAT('test-binaries/boot.oat')\n\nfor odh in oat.oatDexHeader:\n    name = odh.name.split('/')[-1]\n    with open(name, 'wb') as dex:\n        dex.write(odh.dexBytes)\n```\n\nFor further samples look at the sample folder.\n\nContributions\n----------------------\nIf you would like contribute, here some ideas:\n- Implementation of parsing of missing LoadCommand types for MachO files\n- Implementation of parsing of the missing section types for ELF files\n- Implementation of parsing of the missing data directory fields for PE files\n\nBut any kind of contribution is welcome. :)\n\n\nProject page \u0026 Examples\n------------------------------------\n- https://scoding.de/filebytes-introduction\n- https://scoding.de/filebytes-edit-files\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashs%2Ffilebytes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsashs%2Ffilebytes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashs%2Ffilebytes/lists"}