Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suggest reading the excellent (if a bit dated) article/tutorial on exploiting buffer overflow vulnerabilities <strong><a href="http://insecure.org/stf/smashstack.html" rel="nofollow noreferrer">Smashing The Stack For Fun And Profit</a></strong>.</p> <p>Here's a brief excerpt:</p> <blockquote> <p>The problem is that we don't know where in the memory space of the program we are trying to exploit the code (and the string that follows it) will be placed. One way around it is to use a JMP, and a CALL instruction. The JMP and CALL instructions can use IP relative addressing, which means we can jump to an offset from the current IP without needing to know the exact address of where in memory we want to jump to. </p> </blockquote> <hr> <p>You can retrieve the current value of the stack pointer with a bit of inline assembly. All the examples in <strong><a href="http://insecure.org/stf/smashstack.html" rel="nofollow noreferrer">Smashing The Stack For Fun And Profit</a></strong> overflow a buffer in <code>main</code>, but you can just as easily use the same techniques to overflow a buffer in a function called from a pthread. The code below is built on an example from the article (<em>overflow1.c</em>) to show that the same techniques will work using pthreads. The actual technique you will use will depend on the target program you are trying to exploit.</p> <pre><code> /* get value of sp off the stack - not essential to example */ unsigned long get_sp() { __asm__("movl %esp,%eax"); /* equiv. of 'return esp;' in C */ } int foo() { char buffer[96]; /* overflow buffer to overwrite return address */ /* and place code to be executed into buffer. */ ... return 0; } void *thread(void *arg) { printf("thread stack 0x%x\n", get_sp()); foo(); return NULL; } int main(int argc, char **argv) { printf("main stack 0x%x\n", get_sp()); pthread_t t; pthread_create(&t, NULL, thread, NULL); pthread_join(t, NULL); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload