title: Exploiting Printf Vulnerability in C
body: <p>As part of an assignment, I am expected to exploit the printf() vulnerability in the C code shared below. It should be in a way that when I run the code with a string (eg. ./format "foo"), I should change the "1" in "X equals to 1" with something else. I believe I need to change the value of X variable but if you have a different idea, please do not hesitate to share. Here is the code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int main (int argc, char **argv)
  {
      int *p;
      int x = 1;
      p=&amp;x;
      printf("x=%d, sizeof(x): %zu, %x = %p, sizeof((p):%zu,&amp;p = %p, \n", x, sizeof(x), &amp;x, sizeof(p),&amp;p);
      printf(argv[1]);
      printf("\nX equals: %d \n", x);
      return 0;
  }
  </code></pre>