Reputation: 303
I am running FedoraCore6 as instructed by the prof. I am trying to simply run this shellcode that is provided by the lab instructions and I keep on getting a Segmentation fault..We are told we can either compile with the stack gaurd turned off by using the command gcc-fno-stack-protector call_shellcode.c either way wether I just compile the code ussing gcc -o shell call_callshellcode.c or use the -fno-stack-protector command I get a segmentation fault when launching the code isntead of a shell being invoked..Any help? So I am provided with code for this lab as follows:
#include <stdlib.h>
#include <stdio.h>
const char code[] =
"\x31\xc0"
"\x50"
"\x68""//sh"
"\x68""\bin"
"\x89\xe3"
"\x50"
"\x53"
"\x89\xe1"
"\x99"
"\xb0\x0b"
"\xcd\x80"
;
int main(int argc, char **argv)
{
char buf[sizeof(code)];
strcpy(buf, code);
((void(*) ( ))buf)();
}
Upvotes: 1
Views: 2791
Reputation: 8411
dmesg| tail
. The last line in this output would be show where the Instruction Pointer was when the SEGFAULT occurred.-ggdb
flag set. ulimit -c unlimited
on your shell to ensure a core dump is generated when the program SEGFAULTs.Segmentation Fault (core dumped)
. In your local directory, you should see a new file called core
. gdb -c core
to analyze the core dump.gdb
, type bt
or backtrace
to see exactly where the SEGFAULT occurred. info registers
, info locals
, info args
in order to analyze the values you have. Use x/x $esp
(or any other register name) to check what the individual registers contain.
Upvotes: 4