I am trying to exploit the vulnerability in printf
#include <stdio.h>
int main()
{
  int a = 1, b = 2, c = 3, d = 4;
  printf("%d %d %d %d");
}
- a, b, c, d are pushed onto the stack.
- printf arguments are pushed onto stack and then return address
- Now, printf would increment the SP up from "%d%d%d%d"to reach arguments.
- But, as there are no arguments it should reach main local variables a then b ...
But, the output of the above is random large values
-1000081144 - 10000081128 4197428 4197568 -842270912
Q1: What are these values in the output. What is wrong in my understanding?
Q2: How to correct my code above to print the values of local variables in main function from printf? (by exploiting the vulnerabilty of printf)
 
    