在汇编程序中查找环境变量
我正在尝试利用缓冲区溢出进行分配,并且必须访问环境变量(读取其中之一),但我不知道在哪里寻找它们。我正在使用 gdb 来检查内存,但我找不到环境变量。
I'm trying to exploit a buffer overflow for an assignment, and I have to access the environment variables (read one of them), but I have no clue where to look for them. I'm using gdb to inspect memory, but I just can't find the environment variables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果使用
-g
选项编译的话,运行的可执行文件的符号表中应该存在一个全局变量 (char **environ
)。There's a global variable (
char **environ
) which should exist in the running executable's symbol table, if that was compiled with the-g
option.我希望你从那时起就已经找到了。
环境变量存储在 esp 寄存器中,以我当前的练习为例,我可以使用此命令显示环境变量(starti 用于在第一条指令处中断):
I hope that you have found since time.
Environment varialbes are stocked on the esp register, by example on my current exercice, I can show the environment variables with this command (starti is for break at the first instruction):