I am working through an exercise in the shellcoders handbook.
Section .text
global _start
_start:
jmp short GotoCall
shellcode:
pop esi
xor eax, eax
mov byte [esi + 7], al
lea ebx, [esi]
mov long [esi + 8], ebx
mov long [esi + 12], eax
mov byte al, 0x0b
mov ebx, esi
lea ecx, [esi + 8]
lea edx, [esi + 12]
int 0x80
GotoCall:
Call shellcode
db ‘/bin/shJAAAAKKKK’
This code works fine, but I'm not understanding the lines lea ebx, [esi]
and mov ebx, esi
, they both store the same value into ebx. In fact if I run it through gdb I can see that the register values do not change.
I understand that mov accesses the value at the address and lea accesses just the address. If the mov instruction in this scenario had brackets around the esi as in mov ebx, [esi] - Then I can see the difference, but that's not the case, what am I missing?