Skip to main content

Python package to create shellcdoes from elfs supported arch (mips, arm (32bit), i386 32bit, i386 64bit, aarch64)

Project description

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'

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-2.1.6.tar.gz (28.0 kB view hashes)

Uploaded Source

Supported by

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