From 055c31519e74e77c86fab48c3810602c32692d28 Mon Sep 17 00:00:00 2001 From: Sascha Tommasone Date: Sat, 8 Jun 2024 18:13:36 +0200 Subject: [PATCH] [Assignment-5] setup task 3 (shellcode) --- .../shellcode/Makefile | 12 ++++++++++++ .../shellcode/shellcode.asm | 8 ++++++++ .../shellcode/test_shellcode.c | 16 ++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 Assignment 5 - Software Security - Teil 1/shellcode/Makefile create mode 100644 Assignment 5 - Software Security - Teil 1/shellcode/shellcode.asm create mode 100644 Assignment 5 - Software Security - Teil 1/shellcode/test_shellcode.c diff --git a/Assignment 5 - Software Security - Teil 1/shellcode/Makefile b/Assignment 5 - Software Security - Teil 1/shellcode/Makefile new file mode 100644 index 0000000..e328bc3 --- /dev/null +++ b/Assignment 5 - Software Security - Teil 1/shellcode/Makefile @@ -0,0 +1,12 @@ +.DEFAULT_GOAL := all + +shellcode: shellcode.asm + nasm -felf32 shellcode.asm -o shellcode.o + ld -m elf_i386 shellcode.o -o shellcode + rm shellcode.o + +test: test_shellcode.c + gcc -o test_shellcode -m32 -fno-stack-protector -z execstack -fno-pie -O0 test_shellcode.c + + +all: shellcode test diff --git a/Assignment 5 - Software Security - Teil 1/shellcode/shellcode.asm b/Assignment 5 - Software Security - Teil 1/shellcode/shellcode.asm new file mode 100644 index 0000000..310f6cf --- /dev/null +++ b/Assignment 5 - Software Security - Teil 1/shellcode/shellcode.asm @@ -0,0 +1,8 @@ + +; SHELLCODE: "\x90\x90\x90..." + +global _start +_start: + ;---------------------------------- + nop; + ; ------------ End of file ------------ diff --git a/Assignment 5 - Software Security - Teil 1/shellcode/test_shellcode.c b/Assignment 5 - Software Security - Teil 1/shellcode/test_shellcode.c new file mode 100644 index 0000000..193077c --- /dev/null +++ b/Assignment 5 - Software Security - Teil 1/shellcode/test_shellcode.c @@ -0,0 +1,16 @@ +#include +#include + +// gcc -o test_shellcode -m32 -fno-stack-protector -fno-pie -z execstack -O0 test_shellcode.c + +// Your shellcode goes here +char *shellcode = "\x90\x90\x90..."; +// ------------------------ + +int main() +{ + // Print length of shellcode + fprintf(stdout,"Length: %d\n",strlen(shellcode)); + // Execute shellcode + (*(void (*)()) shellcode)(); +}