Skip to main content

Python package to create shellcdoes from elfs

Project description

Elf to shellcode

Convert standard elf files to standalone shellcodes

Who does this work ?

The python library parses the elf and create a simple relocatable file format Then the mini loader is inserted as the entry point of the elf the mini loader will load the relocatable format and execute it. There are no special requirements, the library contain the compiled mini loaders

Supported architectures

  • mips

Creating a shellcode

Some compilation flags are required for this to work properly.

Examples:

Makefile

Main.c

How to make a shellcode from an elf:

from elf_to_shellcode.relocate import make_shellcode

shellcode = make_shellcode(
    binary_path="/tmp/binary.out",
    arch="mips",
    endian="big"
)

with open("myshellcode.out", 'wb') as fp:
    fp.write(shellcode)

Testing your shellcode

You can use the provided shellcode Loader to test you shellcodes

qemu-mips ./shellcode_loader ./myshellcode.out

Output example

Shellcode size = 66620
Allocating shellcode buffer, size = 69632
Mapping new memory, size = 69632
Jumping to shellcode, address = 0x7f7ee000
Hello from shellcode !

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elf_to_shellcode-1.0.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file elf_to_shellcode-1.0.tar.gz.

File metadata

  • Download URL: elf_to_shellcode-1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.2 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/2.7.18

File hashes

Hashes for elf_to_shellcode-1.0.tar.gz
Algorithm Hash digest
SHA256 98e0ecdb55adfd744b4997127e8ea72bc572e352f11bc300576c0475ea2dbaf1
MD5 fea13aadf6c846d73e9463b9d3a6dd75
BLAKE2b-256 7f23503a7476ce0de8487742e9dc8b1c1dbf769a110462fc4981c126affdfc06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page