前情提要
起gdb的时候发现自己pwndbg起不来。。。
import问题
1 | /root/.gdbinit:1: Error in sourced command file: Undefind command “import“. |
配置了一下source但是没有用,查了一下,可能是因为同时安装了两个gdb(源码make一个,apt装一个)导致gdbinit定位错误。于是把gdb全卸了连带pwndbg重新装了一遍,依然没有用。
不过安装pwndbg的时候发现python scripting is not supported in the copy of gdb.
于是尝试编译gdb的时候 ./configure –with-python 然后make。这个方法有用。
pip问题
重新安装pwndbg。发现
1 | ensurepip is disabled in Debian/Ubuntu for the system python. |
这个pwndbg用的是python2.7。
那么问题来了,新版本的apt不再支持pip2的安装。
1 | fr3y@ubuntu:~/pwndbg$ sudo apt install python-pip |
我们试试看手动安装。
1 | wget https://bootstrap.pypa.io/pip/2.7/get-pip.py |
使用python2安装pwntools。
1 | sudo python2 -m pip install --upgrade pwntools |
1 | fr3y@ubuntu:~/pwndbg$ python2 |
重新安装pwndbg。sudo ./setup.sh
出现 + grep pwndbg /root/.gdbinit
好像安装成功了。。
然而。。。还是不行
1 | fr3y@ubuntu:~/pwndbg$ gdb -q |
这是python3的语法。。。
我先去编译一个python3的gdb。
python3之路
1 | ./configure --with-python=/usr/bin/python3 |
然后make,让我们检查一下python版本。
1 | fr3y@ubuntu:~/gdb-11.2$ readelf -d $(which gdb) | grep python |
重新安装pwndbg,试试运行一下。
1 | fr3y@ubuntu:~/pwndbg$ gdb -q |
成功(流泪)
以下为rwctf2022 hso-groupie那道题的调试界面(终于可以调了):
1 | ► 0x555555675150 mov rax, qword ptr [rdi + 0x48] |
反思
早点查看官方文档,搞清楚版本,不要盲目debug。。