Working through the Modern Binary Exploitation course from RPI here. I'm having trouble with an example on exploiting ASLR which is supposed to use a memory leak to gain information about the stack to then calculate the offset for a system call. Here's the code:
#include <stdio.h>
#include <string.h>
/* gcc -pie -fPIE -fno-stack-protector -o aslr_leak2 ./aslr_leak2.c */
int main(int argc, char * argv[])
{
char leaky[16];
if(argc < 2)
{
printf("Please provide two arguments.\n");
return 1;
}
memcpy(leaky, argv[1], 16);
printf("Leaky buffer: %s\n", leaky);
printf("another round? : ");
fgets(leaky, 64, stdin);
return 0;
}
Doesn't look like a format string exploit to get the memory leak, so I'm not sure how it's supposed to work. If I'm understanding correctly, I should get some information from the first print which helps me to overwrite the return pointer to create a ROP gadget from. Yes, I can run this inside of GDB if I wanted to, but I want to be able to not do that.