c - segmentation fault while running shellcode -
i experimenting shellcode before digging deep came across illustration shellcoders handbook. illustration following:
char shellcode[] = "\xeb\x1a\x5e\x31\xc0\x88\x46\x07\x8d\x1e\x89\x5e\x08\x89\x4 \x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\xe8\xe1\xff\xff\xff\x2f\x62\x69 \x6e\x2f\x73\x68"; int main() { int *ret; ret = (int *)&ret + 2; (*ret) = (int)shellcode; }
the shellcode supposed spawn shell. segmentation fault error. compiled programme using gcc
compiler -fno-stack-protector
, -z execstack
options. took quick @ readelf
command , clear stack executable
gnu_stack 0x000000 0x00000000 0x00000000 0x00000 0x00000 rwe 0x4
ret
pointer , not pointing memory location when declare it. later trying assign value adding 2 location pointer pointing to.(which contradictory statement )
ret = (int *)&ret + 2;/* wrong */
c gcc buffer-overflow shellcode
No comments:
Post a Comment