Runs in gdb but not out of gdb

烂漫一生 提交于 2019-12-25 02:41:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!