[Assignment-5] added solution task 3 (shellcode)

This commit is contained in:
Sascha Tommasone 2024-06-08 18:19:10 +02:00
parent 055c31519e
commit 6648789260
Signed by: saschato
GPG key ID: 751068A86FCAA217
2 changed files with 37 additions and 5 deletions

View file

@ -0,0 +1,16 @@
#!/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