Posts

Buffer Overflow Part 1 (64 bit machine)

Code: hello.c #include <stdio.h> #include <string.h> int main(int argc, char** argv) { char buf[80]; strcpy(buf, argv[1]; printf ("Hello you passed in parameter %s\n", argv[1]; printf ("Address is at: %p\n", (void*)buf); return 0; } For the following code, we compile with gcc hello.c -fno-stack-protector -z execstack -g3 -fno-stack-protector - no stack protection (NX) -z execstack - allows execution of instructions on the stack We also need to disable ASLR by running the following command as root: echo 0 > /proc/sys/kernel/randomize_va_space After which when we run the following we get [roland@localhost ~]$ ./a.out HelloWorld Hello you passed in parameter HelloWorld Address is at: 0x7fffffffe530 When we run a.out using gdb we can break at the main and take a look at the buf address by using p &buf $1 = (char (*)[80]) 0x7fffffffe4b0 Notice that for gdb, the address is different from that when runni...