我正在学习Stack Buffer overflow in Return-to-libc.
代码从文件中读取地址(作为字符数组)并将其保存在
中。uint32_t array[5]
并尝试打开"/bin/sh">
我有两个问题,我使用GDB的PWNDBG在Kali linux:
- 当我在4字节的集合中使用像'A'这样的字符引起溢出时(因为uint32-t是4字节),它达到直到"/bin/sh"的地址,甚至显示它,然后给出seg。的错。(可共享pwndbg输出屏幕)
- 当我使用整数(每个4字节)导致溢出时,它启动shell,然后给出
错误:Could not find ELF base!
完整的错误是:
Starting program: /some address/ data.txt
.txt file contains:
1
2
3
4
5
f7f00123
2
f7e00124
1
f2e00100
Sorted list in ascending order:
1
1
2
2
3
4
5
f2e00100
f7e00124
f7f00123
[Attaching after process 11528 vfork to child process 11529]
[New inferior 2 (process 11529)]
[Detaching vfork parent process 11528 after child exec]
[Inferior 1 (process 11528) detached]
process 11529 is executing new program: /usr/bin/dash
ERROR: Could not find ELF base!
[Inferior 2 (process 11529) exited normally]
由于我将文件读取和存储识别为溢出的脆弱过程,我相信排序数据没有后果。
我的地址如下:
f7f00123-"/bin/sh"
f2e00100- system
f7e00124- exit
还要检查地址是否正确
pwndbg> display /s f7f00123
1: x/s 0xf7f00123 0xf7f00123: "/bin/sh"
请帮我找出为什么不能打开shell的问题。
好的,找到解决办法了
上面没有发生堆栈缓冲区溢出。退出函数不会像数据排序时那样工作,它被放置在系统上方因此data。txt中的最终数据将是:
aaaa
bbbb
cccc
dddd
eeee
ffff
ffff
f7f00123
f7e00124
f2e00100
f7f00123
不是
address -> 23456789
which corresponds to exit, changed it to
address -> f7f00123
which corresponds to exit
现在在读取文件之后,生成一个shell,当键入exit时,退出干净。