问题
I am trying to spawn a shell with some shellcode. The payload is in the program itself, however, when I run then program individually I get a segmentation fault, but when running in gdb, my shell opens. Can someone point out what the problem might be?
MrMox@ubuntu:~/folder$ ./a.out h h
Segmentation fault (core dumped)
MrMox@ubuntu:~/folder$ gdb -q a.out
Reading symbols from /home/folder/a.out...done.
(gdb) run h h
Starting program: /home/folder/a.out h h
process 22119 is executing new program: /bin/dash
$
$
回答1:
what the problem might be
First, since you do get a core
, you could just look in it to understand the crash.
Second, GDB disables address randomization (ASLR) by default (to make it easier for you to debug, so everything stays in one place), whereas running a.out
outside of GDB likely has full ASLR, which possibly explains the different behavior of a.out
with and without GDB.
You can disable ASLR globally:
sudo -c "echo 0 > /proc/sys/kernel/randomize_va_space"
Or you can enable randomization within GDB:
(gdb) set disable-randomization off
来源:https://stackoverflow.com/questions/21893891/runs-in-gdb-but-not-out-of-gdb