介绍
pwndbg是GitHub上的一个项目,用于GDB的辅助增强。
安装
在kali里安装可谓一波三折,折腾了一下午总算解决了。
官方的安装方法很简单,直接安全会报错,问题就出在setup.sh。
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
sudo ./setup.sh
问题1:报错信息提示psutil 安装出错
Building wheels for collected packages: psutil
Building wheel for psutil (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pwtsdaf5/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pwtsdaf5/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-995jbn2i
cwd: /tmp/pip-install-pwtsdaf5/psutil/
通过错误信息能看出命令调用的是/usr/bin/python3.8 ,通过百度排第一的答案,能判断出是python版本的问题导致psutil无法安装
通过apt-get install gdb
和apt-get install python3
安装的最近版的程序对应的是GNU gdb (Debian 9.1-2) 9.1
和Python 3.7.7
,
而gdb 9.1 的编译环境是python 3.8,这就造成矛盾了,导致后面的程序都装不上,根据作者的说法。
修改安装文件 setup.sh,注意下面代码 - 号注释掉添加 + 号内容,这样一来安装脚本是可以跑通了。
# Find the Python version used by GDB.
-PYVER=$(gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))')
+PYVER=3.7
PYTHON+=$(gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)')
PYTHON+="${PYVER}"
# Find the Python site-packages that we need to use so that
# GDB can find the files once we've installed them.
if linux && [ -z "$INSTALLFLAGS" ]; then
-SITE_PACKAGES=$(gdb -batch -q --nx -ex 'pi import site; print(site.getsitepackages()[0])')
+SITE_PACKAGES=/usr/local/lib/python3.7/dist-packages
INSTALLFLAGS="--target ${SITE_PACKAGES}"
fi
作者:pu1p
链接:https://www.jianshu.com/p/47883d16fa30
问题2:运行GDB显示psutil 模块错误
...
For help, type "help".
Type "apropos word" to search for commands related to "word".
Traceback (most recent call last):
File "/root/pwndbg/gdbinit.py", line 36, in <module>
import pwndbg # isort:skip
File "/root/pwndbg/pwndbg/__init__.py", line 12, in <module>
import pwndbg.android
File "/root/pwndbg/pwndbg/android.py", line 12, in <module>
import pwndbg.file
File "/root/pwndbg/pwndbg/file.py", line 19, in <module>
import pwndbg.qemu
File "/root/pwndbg/pwndbg/qemu.py", line 14, in <module>
import psutil
File "/usr/local/lib/python3.8/dist-packages/psutil/__init__.py", line 101, in <module>
from . import _pslinux as _psplatform
File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 26, in <module>
from . import _psutil_linux as cext
ImportError: cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) (/usr/local/lib/python3.8/dist-packages/psutil/__init__.py)
(gdb)
...
For help, type "help".
Type "apropos word" to search for commands related to "word".
Traceback (most recent call last):
File "/root/pwndbg/gdbinit.py", line 36, in <module>
import pwndbg # isort:skip
File "/root/pwndbg/pwndbg/__init__.py", line 12, in <module>
import pwndbg.android
File "/root/pwndbg/pwndbg/android.py", line 12, in <module>
import pwndbg.file
File "/root/pwndbg/pwndbg/file.py", line 19, in <module>
import pwndbg.qemu
File "/root/pwndbg/pwndbg/qemu.py", line 14, in <module>
import psutil
ModuleNotFoundError: No module named 'psutil'
(gdb)
遇到两种报错,都指向同一个问题,新版GDB使用的是python3.8 但是通过脚本部署的psutil,可能是因为改成3.7版本安装的所以不能启动,下面这个方式不行
python3.8 -m pip install psutil
下面方法可行
#python3.8 安装 psutil
sudo apt-get install python3.8-dev
sudo -H pip install psutil
最后,久违的界面啊~~
root@unic0rn:~/pwndbg# gdb
GNU gdb (Debian 9.1-2) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
pwndbg: loaded 190 commands. Type pwndbg [filter] for a list.
pwndbg: created $rebase, $ida gdb functions (can be used with print/break)
pwndbg>
网友评论