I have found the following assembly lines presented in a tutorial which I do not understand:
xor eax, eax => clear, I know that, it makes eax = 0
push eax => push 0 on the stack
push 0x68732f2f => push "//sh" to the stack (the numbers are opcodes I guess, output of hexdump)
push 0x6e69622f => push "/bin" to the stack (again opcodes, representing "/bin" )
mov ebx, esp => put address of "/bin//sh\0" into ebx, via esp
....
My question: Why we put address of "/bin//sh" into ebx, via esp using the line mov ebx, esp for that ?
I draw a sketch:
| |
|------------------------|<-----ESP (I know that ESP always points to the top)
(a) | 0x6e69622f ("//sh") |
|------------------------|
(b) | 0x68732f2f ("/bin") |
|------------------------|
(c) | 0 |
|------------------------|
How I try to explain it to myself(I am not sure if it is correct, but I thought to think about a little bit before I ask in that forum here):
ESP is a 32-bit register such that it is large enough to comprise the addresses at (a), (b) and (c) (which I marked above).
Is that right? I hope somebody can help me?
best regards,