An ELF format manipulation library in python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Python-ELF is a python library targeting ELF binary format manipulation. 
It is OS and machine independant, or tends to be. It has nothing new nor 
nothing better than existing libraries and currently is suffers from lacks 
which makes it much more a draft than anything else. So for a real usage, 
consider using something else.

Its goal it to make, anyway, static ELF binary manipulation easy. The Q&D is an example on how current ease of use level is. 

Contributions are welcome!


It can read and interpret "allmost" any ELF-specific part in an ELF binary. 
E.g.: it cannot intepret DWARF2 specific sections. 


- no writing capabilities... coming soon
- doet not yet interpret machine specific data, though necessary values interpreters 
  are already present.
- No version part interpretation.
- Only basic relocation interpretation
- Prone to error while binary owns anti-re tricks. (could be easily fixed, some case
  are already handled)


Everything in python-elf is thought and handled as a "chunk". An ELF file is a chunk
made of multiple other chunks.

Headers in ELF are chunks. Due to the fact that all section and program part possess a
header, there is a class representing a chunk with a header: the page.

Here is a quick overview on the basic design:

   --> Chunk <--
  |             |
  |             |
Header - - - - Page

Section, Program and Note classes are sub-classes of Page so they embed their respective
headers. This simplify then the relationshid within this two chunk (e.g. a section and its 

Using python-elf

(through python interpreter)
>>> from elf.elf_binary import Elf
>>> bin = Elf("/some/path/some_file_name")

Some printer helper functions can be found in from elf.printers import printHeader
It prints out only headers of course, in a human readable way.

Important note

As any other ELF manipulation library, you MUST know how ELF format is made to use 


For any further information, help, ideas, contributions, critics: contact 
the author: