title: Using gdb to calculate return address
body: <p>I'm currently doing a school project right now, and I'm lost on using gdb on ubuntu to find a buffer overflow vulnerability.</p>
  
  <p>I've never used gdb before, but did a little bit of research on the internet and when I used the "disas main" command I was quite overwhelmed at what I was looking at.</p>
  
  <p>I was wondering if someone can walk me through on how to debug this program or any other programs and show me how the return address is found.</p>
  
  <p>I have this code here:</p>
  
  <pre><code>/* This program has a buffer overflow vulnerability. */
  /* Our task is to exploit this vulnerability */
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int bof(char *str)
  {
      char buffer[12];
      /* The following statement has a buffer overflow problem */
      strcpy(buffer, str);
      return 1;
  }
  
      int main(int argc, char **argv)
  {
      char str[512];
      FILE *badfile;
      badfile = fopen("badfile", "r");
      fread(str, sizeof(char), 5122, badfile);
      bof(str);
      printf("Returned Properly\n");
      return 1;
  }
  </code></pre>