- 对于一个学萌新pwn,gdb插件开始会弄得晕头转向的
补充 :工具使用前提(大牛勿笑)
1.先链接将我们的工具,下载到本地
2.写入环境变量,让系统知道我们用的是哪个插件
新手查看一下自己的.gdbinit
文件里面写了什么(自己安装过一次gdb插件)
1.一般我们将工具会放在/home/ubuntu目录下面 (ubuntu是自己的用户名)
2.vim .gdbinit
打开后里面会有许多命令 只关注source ~
这个后面都是自己在安装插件的时候,写入的环境变量
3.我们将他们全部注释掉(自己调试一下 只有裸奔的gdb
)
安装插件(我都安装到了/home/ubuntu下)
- peda
git clone https://github.com/longld/peda.git ~/peda
echo "source ~/peda/peda.py" >> ~/.gdbinit
- gef
#要是没有安装wget的自行安装 sudo apt install wget
wget -q -O- https://github.com/hugsy/gef/raw/master/gef.sh | sh
wget -q -O ~/.gdbinit-gef.py https://github.com/hugsy/gef/raw/master/gef.py
echo source ~/.gdbinit-gef.py >> ~/.gdbinit
- pwngdb
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh
现在打开.gdbinit
你会发现我们的三个环境变量写进脚本里面了 我们再次将他注释(大牛就不用第一次注释了,第一次只是为了引入环境变量这个概念)
- 在本地新建
gdb.sh
脚本
#!/bin/bash
function Mode_change {
name=$1
gdbinitfile=~/.gdbinit #这地方改为自己文件的位置
# gdbinitfile=/root/Desktop/mode
peda="source /home/ubuntu/peda/peda.py" #同理
gef="source /home/ubuntu/.gdbinit-gef.py" #同理 这个需要ls -a 查看
pwndbg="source /home/ubuntu/pwndbg/gdbinit.py" #同理 其他的地方就不用更改
sign=$(cat $gdbinitfile | grep -n "#this place is controled by user's shell")
pattern=":#this place is controled by user's shell"
number=${sign%$pattern}
location=$[number+2]
parameter_add=${location}i
parameter_del=${location}d
message="TEST"
if [ $name -eq "1" ];then
sed -i "$parameter_del" $gdbinitfile
sed -i "$parameter_add $peda" $gdbinitfile
echo -e "Please enjoy the peda!\n"
elif [ $name -eq "2" ];then
sed -i "$parameter_del" $gdbinitfile
sed -i "$parameter_add $gef" $gdbinitfile
echo -e "Please enjoy the gef!\n"
else
sed -i "$parameter_del" $gdbinitfile
sed -i "$parameter_add $pwndbg" $gdbinitfile
echo -e "Please enjoy the pwndbg!\n"
fi
}
echo -e "Please choose one mode of GDB?\n1.peda 2.gef 3.pwndbg"
read -p "Input your choice:" num
if [ $num -eq "1" ];then
Mode_change $num
elif [ $num -eq "2" ];then
Mode_change $num
elif [ $num -eq "3" ];then
Mode_change $num
else
echo -e "Error!\nPleasse input right number!"
fi
gdb $1 $2 $3 $4 $5 $6 $7 $8 $9
别忘了给权限 chomd 777 gdb.sh
要是运行不了 查看当前路径下的环境变量`echo $PATH` 将文件拷贝到任意一个路径下去(一定要给权限)
注:只能用在当前路径下 所以讲这个文件拷贝到和自己的可执行文件一个目录下调试
注:能否将这个脚本添加进系统的全局环境变量里面,随时随地方便使用(知道的大牛可以留言)