In order to compile and execute these buffer overflow attacks you will need to turn off ASLR
echo "0" > /proc/sys/kernel/randomize_va_space
then turn off the other protection tools used by modern operating systems by doing the following:
gcc example1.c -o example1 -zexecstack -fno-stack-protector -g
for vuln.c
gcc vuln.c -o vuln -fno-stack-protector -no-pie -m32
this also makes it run on a '32 bit addressing scheme' regardless of the processor architecture
Further instructions will follow when i can be bothered
C files and general theory shamelessly ripped from:
http://phrack.org/issues/49/14.html
and
https://dhavalkapil.com/blogs/Buffer-Overflow-Exploit/
amongst others