Code Monkey home page Code Monkey logo

makeelf's Introduction

MakeELF

ELF reader-writer library for Python3

Overview

MakeELF is a Python library to parse, modify and create ELF binaries. It provides following features:

  • easy to use, standard Python interface
  • reading existing ELF files to Python representation
  • modification of every aspect of ELF format structures
  • ability to skip any validation to test other parsers for potential errors
  • creating new valid ELF files with just one step
  • easy serialization of every structure present in ELF file

Installation

MakeELF could be installed either using PyPI and pip3 tool or manually with help of setup.py script.

Install from PyPI

It is as simple as typing:

pip3 install makeelf

Manual installation

Clone the Github repository and in root of the project execute:

python3 setup.py install

API

Creating new object

from makeelf.elf import *
elf = ELF(e_machine=EM.EM_LKV373A)
print(elf)

Parsing ELF file

Either using helper function:

elf = ELF.from_file('some.elf')
print(elf)

Then if you'd like to have full control on headers, low-level object can be extracted:

elf = elf.Elf

Or create low-level object manually:

fd = os.open('some.elf', os.O_RDONLY)
b = os.read(fd, 0xffff)
os.close(fd)

elf, b = Elf32.from_bytes(b)
print(elf)

Saving ELF to file

fd = os.open('other.elf', os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
os.write(fd, bytes(elf))
os.close(fd)

Adding a section

data_id = elf.append_section('.data', b'\0\0\0\0', 0xfadd)

Adding a symbol

elf.append_symbol('NULL', data_id, 0, 4)

Modifying attributes

elf.Elf.Shdr_table[data_id].sh_flags = int(SHF.SHF_ALLOC)

License

All the software here is licensed under GNU General Public License 3.0, available in LICENSE file.

makeelf's People

Contributors

v3l0c1r4pt0r avatar lynerc avatar leithouse avatar minexew avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.