{"id":15297423,"url":"https://github.com/doronz88/simpleelf","last_synced_at":"2025-04-13T22:51:09.621Z","repository":{"id":57467390,"uuid":"252306611","full_name":"doronz88/simpleelf","owner":"doronz88","description":"Parse and build simple ELFs (useful for mapping memory to load into IDA and other disassemblers)","archived":false,"fork":false,"pushed_at":"2023-09-19T09:55:46.000Z","size":45,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T18:57:56.663Z","etag":null,"topics":["elf","parser","pypi-package","python","python-3","python2","python3","reverse-engineering"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doronz88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-01T23:10:42.000Z","updated_at":"2024-07-25T11:02:22.000Z","dependencies_parsed_at":"2024-10-15T03:21:55.170Z","dependency_job_id":"1c5b4b51-6198-4804-b4e5-5abdce2270e1","html_url":"https://github.com/doronz88/simpleelf","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"a937e2824d7aafd6c39b951524b7054af86c0279"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doronz88%2Fsimpleelf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doronz88%2Fsimpleelf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doronz88%2Fsimpleelf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doronz88%2Fsimpleelf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doronz88","download_url":"https://codeload.github.com/doronz88/simpleelf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794561,"owners_count":21162614,"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","parser","pypi-package","python","python-3","python2","python3","reverse-engineering"],"created_at":"2024-09-30T19:17:25.446Z","updated_at":"2025-04-13T22:51:09.602Z","avatar_url":"https://github.com/doronz88.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Python package](https://github.com/doronz88/simpleelf/workflows/Python%20package/badge.svg)\r\n\r\n# Introduction\r\nELF file is not only an executable, but a very convenient way to describe \r\na program's layout in memory. The original intention of this project is to \r\nallow an individual to create an ELF file which describes the memory mapping\r\nused for an embedded program. Especially useful for using together with other \r\nanalysis tools, such as:\r\nIDA/Ghidra/etc... They can have all its desired information without the need to\r\nopen just an ordinary `.bin` file and running several IDAPython scripts\r\n(I'm sick of `Load additional binary file...` option).\r\n\r\nPull Requests are of course more than welcome :smirk:.\r\n\r\n# Installation\r\n\r\nUse `pip`:\r\n\r\n```bash\r\npython3 -m pip install simpleelf\r\n```\r\n\r\nOr clone yourself and build:\r\n\r\n```bash\r\ngit clone git@github.com:doronz88/simpleelf.git\r\ncd simpleelf\r\npython -m pip install -e . -U\r\n```\r\n\r\n# Running\r\n\r\nNow you can just import simpleelf and start playing with it.\r\n\r\n## Parsing\r\n\r\nParsing is easy using `ElfStruct`.\r\nTry it out:\r\n\r\n```python\r\nfrom simpleelf.elf_structs import ElfStructs\r\n\r\nElfStructs('\u003c').Elf32.parse(elf32_buffer) # outputs a constucts' container\r\nElfStructs('\u003c').Elf64.parse(elf64_buffer) # outputs a constucts' container\r\n```\r\n\r\n## Building from scratch\r\n\r\nBuilding is easy using `ElfBuilder`.\r\nTry it out:\r\n\r\n```python\r\nfrom simpleelf.elf_builder import ElfBuilder\r\nfrom simpleelf import elf_consts\r\n\r\n# can also be used with ELFCLASS64 to create 64bit layouts\r\ne = ElfBuilder(elf_consts.ELFCLASS32)\r\ne.set_endianity('\u003c')\r\ne.set_machine(elf_consts.EM_ARM)\r\n\r\ncode = b'CODECODE'\r\n\r\n# add a segment\r\ntext_address = 0x1234\r\ntext_buffer = b'cybercyberbitimbitim' + code\r\ne.add_segment(text_address, text_buffer, \r\n    elf_consts.PF_R | elf_consts.PF_W | elf_consts.PF_X)\r\n\r\n# add a second segment\r\ne.add_segment(0x88771122, b'data in 0x88771122', \r\n    elf_consts.PF_R | elf_consts.PF_W | elf_consts.PF_X)\r\n\r\n# add a code section inside the first segment\r\ncode_address = text_address + text_buffer.find(code)  # point at CODECODE\r\ncode_size = len(code)\r\ne.add_code_section(code_address, code_size, name='.text')\r\n\r\n# set entry point\r\ne.set_entry(code_address)\r\n\r\n# add .bss section. not requiring a loaded segment from\r\n# file\r\nbss_address = 0x5678\r\nbss_size = 0x200\r\ne.add_empty_data_section(bss_address, bss_size, name='.bss')\r\n\r\n# get raw elf\r\ne.build()\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoronz88%2Fsimpleelf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoronz88%2Fsimpleelf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoronz88%2Fsimpleelf/lists"}