Skip to main content

b'# Elf to shellcode\nConvert standard elf files to standalone shellcodes.\nPlease read the following documentation and view the examples for this project to work properly\n\n#### Project links\nGithub\n\nPypi\n\n#### Supported architectures\n* mips\n* i386 (32bit)\n* i386 (64bit)\n* arm (32bit)\n* aarch64 (arm 64 bit)\n\n#### Installation:\nbash\npip install elf_to_shellcode\n\n###### Python version support\n* python3\n* python2\n\n## How does this work ?\nThe python library parses the elf and create a simple relocatable file format\nThen the mini loader is inserted as the entry point of the elf the mini loader\nwill load the relocatable format and execute it.\nThere are no special requirements, the library contain the compiled\nmini loaders.\n\nmermaid\n classDiagram\n ShellcodeEntryPoint --|> MiniLoader\n ShellcodeEntryPoint: Shellcode to jump into the mini loader\n MiniLoader --|> Relocation table\n MiniLoader: Contain all the logic for parsing the relocation table\n MiniLoader: fully os independent\n Relocation table --|> SHELF\n Relocation table : Contain table required for shellcode runtime relocation\n SHELF: Shellcode elf - This is the compiled binary we convert into shellcode\n SHELF: This binary is stripped into only opcodes\n SHELF: fully relocatable using the relocation table\n\n\nThis project is intended to convert elf to os independent shellcodes.\nTherefor the loader never allocate memory and the shellcode format is not packed.\nYou can just execute it, eg ...\nc\n((void (*)()) shellcode)();\n\nnote that __libc_start_main perform syscalls\ntherefor if you want your shellcode to be fully os independent you must compile with -nostartfiles\nfollow the examples below\n\n## Creating a shellcode\n\nSome compilation flags are required for this to work properly.\nYou must compile the binary with -fPIE and -static take a look at the provided examples below\n(makefile).\n\nshellcode is a stripped binary with no symbols and no elf information only opcodes, in order \nto make the shellcode this library require a binary with elf information.\nso make sure you are not stripping the binary before using this library\n\nsimplified make command for mips big endian\n\nc\ngcc example.c -fno-stack-protector -fPIE -fpic -static -nostartfiles --entry=main -o binary.out\npython -m elf_to_shellcode --input binary.out --arch mips --endain big \n\n\n### Examples:\n\nMakefile\n\nExample.c\n\n\n\n### Testing your shellcode\nYou can use the provided shellcode\nLoader\nto test you shellcodes\n\nbash\nqemu-mips ./shellcode_loader ./myshellcode.out\n\n\n### Output example\nbash\nShellcode size = 66620\nAllocating shellcode buffer, size = 69632\nMapping new memory, size = 69632\nJumping to shellcode, address = 0x7f7ee000\nHello from shellcode !\n\n\n## Specific architecture limitations\n\n### AARCH64\n\narm in 64 bit mode generate adrl instruction.\nThese instructions are (2 ** 12) aligned (page) therfore the shellcode should be\npage aligned to overcome this limitation the shellcode is padded\n\n## Advanced conceptes and features\n\nfor following links only work on the github page\n\n* Compiling with libc\n* Dynamic shellcode\n* Optimizations\n* Output formats\n* Development\n'

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-2.1.5.tar.gz (27.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: elf_to_shellcode-2.1.5.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for elf_to_shellcode-2.1.5.tar.gz
Algorithm Hash digest
SHA256 27bc345ba3c7b1fda3a475710f9456c2a5b907b9a6a2601ecd07eacea9521452
MD5 85c2e30feca1e7cf0ae726c3b814333b
BLAKE2b-256 ee338dd20c8992d2c5699b61de9a335d4a2be8cd947596cbe36b8d08c2955f79

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 Sentry Error logging StatusPage Status page