0

I 'm trying to execute program with shell code injected into stack (program getting from securityTube.net tutorial , Megaprimer buffer overflow ) very good site (http://www.securitytube.net/)

Our shellcode.c is :

#include <stdio.h>
char shellcode[]="\xb0\x01\x31\xdb\xcd\x80";
main()
{
  int *p;
  p=(int *)&p+2;
  (*p)=(int)shellcode;
}

I compiled with fno-stack-protector and -z execstack to disable stack protection, even with these parameters I get segmentation fault, our shellcode is simply syscall for exit() function, with gdb I noticed that segmentation fault was raised when hiting command int $x80 inside shellcode. perhaps there is another security param blocking our shellcode

any suggestions pls

S.Spieker
  • 7,005
  • 8
  • 44
  • 50
  • Same question in https://stackoverflow.com/questions/48847149/unanticipated-segmentation-fault-in-c/ – sinkmanu Feb 20 '18 at 08:20

1 Answers1

0

Maybe you could try this example: http://shell-storm.org/shellcode/files/shellcode-827.php

Because your shellcode has some problems.

It doesn't clear $edx to null.

You could use gdb to check this.

Set the breadpoint before int $80.

Or use strace to trace system call parameter.

Below is the result I use strace to run your code.

execve("/bin//sh", ["/bin//sh"], [/* 3 vars */]) = -1 EFAULT (Bad address)
Weibo Chen
  • 369
  • 1
  • 10