title: Why is this the structure of the exploit
body: <p>So I tried following a tutorial: <a href="https://sploitfun.wordpress.com/2015/05/08/classic-stack-based-buffer-overflow/" rel="nofollow noreferrer">https://sploitfun.wordpress.com/2015/05/08/classic-stack-based-buffer-overflow/</a> </p>
  
  <p>I was struggling with figuring out the order of the exploit code, atleast in someway.</p>
  
  <p>I don't get the reason for first putting NOPS and then only the Shell-code, and I couldn't figure out the reason not to first put the shellcode in the buf and then junk + ret address.
  I assumed it's to save the memory address calculations, but is it really the reason?
  isn't it simpler just to work with the stack you've already got (like not going 'beyond' the return-address)?
  Why not make the malicious buffer to be:
  Shellcode + Junk + ret-address(to the shellcode beginning) ? is it because of the somewhat complex memory addresses calculations ...? Hopefully I made myself clear.</p>
  
  <p>Thank you in advance.</p>
  
  <p>Edit:</p>
  
  <p>An identical example (identical to the code I ran):</p>
  
  <p><a href="https://github.com/jivoi/junk/blob/master/pwnerrank/binary-exploitation/stack-based-buffer-overflow-code-execution.c" rel="nofollow noreferrer">https://github.com/jivoi/junk/blob/master/pwnerrank/binary-exploitation/stack-based-buffer-overflow-code-execution.c</a></p>