Hi everyone.
I've read a lot of the basic tutorials and documentation about shellcoding and buffer overflows. However there are some things that I just cant' picture. First, I will mention what I do understand.
I do understand how to spawn /bin/sh using some C code.
I do understand how to represent that C code in asm.
I do understand how to extract op-codes from that asm code.
I do understand that those op-codes will be the actual shell code.
I do understand that those op-codes will be in a string which we use to overflow vulnerable buffers with.
I do understand that 1 on the method's used is to pad the beginning of our string with nop's, place shell code in a middle and the rest will be the address of our "attack" string.
What I don't understand is how that "attack" string is going to end up in the vulnerable buffer in case if that program's vulnerable buffer is not the one to which we copy argv[ ] (Like in case of those examples in different tutorials). Say if a vulnreable buffer is somewhere in some function and the program just prompts the user for some data. How is it possible to overflow the buffer in that case?. As far as I understand in that case we can't deliver our shellcode via enviorement variable nor via `perl -e 'print "A"x(say 512 for instance)'``printf '\addr2shellcode'`. If i understand correctly this only works for passing stuff to main() before we run it.
And another thing that i can't understand is: say i have guessed or somehow obtained the address of my shellcode somewhere in memory. It is still not in a memory layout of the vulnerable program. Can the vulnreable program access memory which is not in its layout. Or is there something that i missed here?
So these are the basic but i think important things that i can't visualize at the moment. I would appriciate if some one could enlighten me on this.
Thanks in advance.
I've read a lot of the basic tutorials and documentation about shellcoding and buffer overflows. However there are some things that I just cant' picture. First, I will mention what I do understand.
I do understand how to spawn /bin/sh using some C code.
I do understand how to represent that C code in asm.
I do understand how to extract op-codes from that asm code.
I do understand that those op-codes will be the actual shell code.
I do understand that those op-codes will be in a string which we use to overflow vulnerable buffers with.
I do understand that 1 on the method's used is to pad the beginning of our string with nop's, place shell code in a middle and the rest will be the address of our "attack" string.
What I don't understand is how that "attack" string is going to end up in the vulnerable buffer in case if that program's vulnerable buffer is not the one to which we copy argv[ ] (Like in case of those examples in different tutorials). Say if a vulnreable buffer is somewhere in some function and the program just prompts the user for some data. How is it possible to overflow the buffer in that case?. As far as I understand in that case we can't deliver our shellcode via enviorement variable nor via `perl -e 'print "A"x(say 512 for instance)'``printf '\addr2shellcode'`. If i understand correctly this only works for passing stuff to main() before we run it.
And another thing that i can't understand is: say i have guessed or somehow obtained the address of my shellcode somewhere in memory. It is still not in a memory layout of the vulnerable program. Can the vulnreable program access memory which is not in its layout. Or is there something that i missed here?
So these are the basic but i think important things that i can't visualize at the moment. I would appriciate if some one could enlighten me on this.
Thanks in advance.
Comment