Linux pwn环境搭建

1.安装pwntools

sudo apt-get update
sudo apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential
python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pwntools
echo export PATH="/home/`whoami`/.local/bin:\$PATH" >> ~/.zshrc

2.安装pwngdb

cd ~/.local
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh

3.安装splitmind(可选)

cd ~/.local
git clone https://github.com/jerdna-regeiz/splitmind
echo "source $PWD/splitmind/gdbinit.py" >> ~/.gdbinit
echo "setw -g mouse on" >> ~/.tmux.conf # enable tmux mouse support
cat << EOF >> ~/.gdbinit
python
import splitmind
(splitmind.Mind()
.tell_splitter(show_titles=True)
.above(display="stack")
.right(display="regs")
.right(of="main", display="disasm")
.below(display="backtrace", size="30%")
.show("legend", on="disasm")
).build(nobanner=True)
end
EOF

还有一些别的插件和设置,不细说了,可以参考我的~/.gdbinit

source ~/.local/pwndbg/gdbinit.py
#source ~/.local/peda/peda.py
#source ~/.gdbinit-gef.py
source ~/.local/Pwngdb/pwngdb.py
source ~/.local/Pwngdb/angelheap/gdbinit.py
source /home/zero/.local/splitmind/gdbinit.py

set debuginfod enabled on
set ida-enabled off
set follow-fork-mode parent
set follow-exec-mode same
set listsize 20
set context-source-code-lines 30

define hook-run
python
import angelheap
angelheap.init_angelheap()
end
end

python
import splitmind
(splitmind.Mind()
.tell_splitter(show_titles=True)
.above(display="stack")
.right(display="regs")
.right(of="main", display="disasm")
.below(display="backtrace", size="30%")
.show("legend", on="disasm")
).build(nobanner=True)
end

最终效果:

image-20230319155118769