Reputation: 772
I dont know why but when I use the hex of below code as shell code it works:
Section .text
global _start
_start:
mov ebx,0
mov eax,1
int 0x80
but when I use the hex of the below code instead, it does not work and segmentation fault occurres:
Section .text
global _start
_start:
xor ebx,ebx
mov al,1
int 0x80
I know that is because of using 'al'. I don`t know why does using of 'eax' works correctly but using 'al' get error?
Thanks a lot.
Ya Ali.
Upvotes: 0
Views: 87
Reputation: 9272
Because int 0x80 expects 32-bit param. When you pass low 8 bits only (AL), high parts of eax may contain anything (undefined value), so instead of passing 1 you end up passing 0x??????01
Upvotes: 1