Take a look at radare2. It can parse file formats (see here for an example of parsing the ELF header).

Radare2 supports multiple architectures and is being actively developed. On top of that it has bindings for a lot of languages, including Python of course. Read through the bindings source code to see it is pretty straightforward to script it.

HTH!

Answer from Carlos Garcia on Stack Exchange
🌐
GitHub
github.com › eliben › pyelftools
GitHub - eliben/pyelftools: Parsing ELF and DWARF in Python · GitHub
pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information.
Starred by 2.3K users
Forked by 543 users
Languages   Python 97.7% | C 1.5% | Assembly 0.5% | Linker Script 0.1% | Makefile 0.1% | Nix 0.1%
🌐
GitHub
github.com › v3l0c1r4pt0r › makeelf
GitHub - v3l0c1r4pt0r/makeelf: ELF reader-writer library for Python3 · GitHub
MakeELF is a Python library to parse, modify and create ELF binaries.
Starred by 67 users
Forked by 29 users
Languages   Python
🌐
Medium
medium.com › analytics-vidhya › exploring-elf-files-using-pyelftools-93bb7665cce3
Exploring ELF files using pyelftools | by Roman Storozhenko | Analytics Vidhya | Medium
October 27, 2020 - hedin@home:~/projects/elf$ python3 segments_sections.py /bin/ps Mapping between segments and sections in the file /bin/ps Segment: Type: PT_PHDR Offset: 0x40 Virtual address: 0x40 Physical address: 64 Size in file: 0x2d8 Size in memory: 0x2d8 Segment contains no sections ---------------------------------------------------------------- Segment: Type: PT_INTERP Offset: 0x318 Virtual address: 0x318 Physical address: 792 Size in file: 0x1c Size in memory: 0x1c Segment's sections: [('.interp', '0x318')] ---------------------------------------------------------------- Segment: Type: PT_LOAD Offset:
🌐
Eli Bendersky
eli.thegreenplace.net › 2012 › 01 › 06 › pyelftools-python-library-for-parsing-elf-and-dwarf
pyelftools - Python library for parsing ELF and DWARF - Eli Bendersky's website
January 6, 2012 - I'm happy and proud to announce the release of a new open-source Python package to the world. pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information. It provides both low-level and high-level APIs for querying ELF and DWARF, and is mostly ...
🌐
GitHub
github.com › burtonwilliamt › ElfParser
GitHub - burtonwilliamt/ElfParser: Python parsing of the elf header
This project is a project to try and understand how the Executable and Linkable Format works for binaries. In it's current state, the tool parses the elf header and reads the section header table. I am building this tool with the information available on the wikipedia page. This project is written in python, and needs the following packages:
Starred by 2 users
Forked by 2 users
Languages   Python 99.6% | C 0.4% | Python 99.6% | C 0.4%
🌐
DEV Community
dev.to › icyphox › python-for-reverse-engineering-1-elf-binaries-1fo4
Python for Reverse Engineering #1: ELF Binaries - DEV Community
March 14, 2019 - As the title suggests, you’re going to need a Python 3 interpreter before anything else. Once you’ve confirmed beyond reasonable doubt that you do, in fact, have a Python 3 interpreter installed on your system, run ... where capstone is the disassembly engine we’ll be scripting with and pyelftools to help parse ELF files.
Find elsewhere
🌐
Lief
lief.re › doc › latest › formats › elf › python.html
Python — LIEF Documentation - ELF
2 weeks ago - lief.ELF.parse(obj: str | io.IOBase | os.PathLike | bytes | list[int], config: lief.ELF.ParserConfig) → lief.ELF.Binary | None¶ · Parse the ELF binary from the given Python object and return a lief.ELF.Binary object
🌐
GitHub
github.com › Appdome › p1000
GitHub - Appdome/p1000: A Python parser for ELF (Executable Linkable Format) · GitHub
p1000 is a library for parsing ELF files utilizing Python's strengths.
Author   Appdome
🌐
GitHub
github.com › jenca-adam › python-readelf
GitHub - jenca-adam/python-readelf: Python ELF parser
>>> elf_file.find_at_offset(elf_file.entry) <Section .text @ 0x1020> >>>
Author   jenca-adam
🌐
Linux Security Expert
linuxsecurity.expert › linux security expert › tools › pyelftools
Pyelftools review (ELF parsing toolkit) - Linux Security Expert
September 10, 2024 - Pyelftools is a Python library to parse ELF files and DWARF debugging information. It can be useful to perform dynamic binary analysis on files.
🌐
GitHub
github.com › dactylroot › Elf-Parser
GitHub - dactylroot/Elf-Parser: Executable-Linking-File Parser in python. Returns addresses required to access ELF sections. Used for identifying dynamically linked libraries of the ELF file.
Executable-Linking-File Parser in python. Returns addresses required to access ELF sections. Used for identifying dynamically linked libraries of the ELF file. - dactylroot/Elf-Parser
Starred by 8 users
Forked by 3 users
Languages   Python 100.0% | Python 100.0%
🌐
Eklitzke
eklitzke.org › parse-elf
Parsing ELF symbol tables - eklitzke.org
I wrote a program that can actually decode $(which python) and give the same output. In particular, I see: $ ./parse_elf $(which python) ...
🌐
GitHub
github.com › burtonwilliamt › ElfParser › blob › master › elf_parser.py
ElfParser/elf_parser.py at master · burtonwilliamt/ElfParser
Python parsing of the elf header. Contribute to burtonwilliamt/ElfParser development by creating an account on GitHub.
Author   burtonwilliamt
🌐
GitHub
github.com › topics › elf-parser
elf-parser · GitHub Topics · GitHub
android windows linux static-analysis ...verse-engineering exe-parser linux-reverse-engineering ... A Python script for analyzing ELF (Executable and Linkable Format) files....
🌐
GitHub
github.com › kokjo › pyelf
GitHub - kokjo/pyelf: A ELF parser for python
A ELF parser for python. Contribute to kokjo/pyelf development by creating an account on GitHub.
Author   kokjo
🌐
PyPI
pypi.org › project › elffile
elffile · PyPI
A pure python library for reading and writing ELF format object filex.
      » pip install elffile
    
Published   Feb 07, 2011
Version   0.005
🌐
GitHub
github.com › detailyang › readelf
GitHub - detailyang/readelf: One Python File To Parse ELF For Learning ELF
One Python File To Parse ELF For Learning ELF. Contribute to detailyang/readelf development by creating an account on GitHub.
Starred by 22 users
Forked by 13 users
Languages   Python 100.0% | Python 100.0%