17 lines
527 B
Text
17 lines
527 B
Text
|
#!/bin/bash
|
||
|
|
||
|
# assemble shellcode
|
||
|
nasm -felf32 shellcode.asm -o x.o && ld -m elf_i386 x.o -o shellcode &> /dev/null
|
||
|
|
||
|
# remove object file
|
||
|
rm x.o
|
||
|
|
||
|
# extract shellcode and remove binary
|
||
|
shellcode=$(for byte in $(objdump -d ./shellcode | grep "^ " | cut -f2); do echo -n '\x'$byte; done)
|
||
|
rm shellcode
|
||
|
|
||
|
# TODO place shellcode into test_shellcode.c and shellcode.asm
|
||
|
|
||
|
# compile test_shellcode.c and execute it afterwards
|
||
|
gcc -o test_shellcode -m32 -fno-stack-protector -fno-pie -z execstack -O0 test_shellcode.c && ./test_shellcode
|