二進制安全之堆溢出(系列)——CTF環(huán)境配置
【重要通知】知了堂禁衛(wèi)實驗室全新上線??!
這里有安全體系的學(xué)習(xí)資源、
最前沿的原創(chuàng)文章、最新的漏洞挖掘原創(chuàng)??!

本期是“二進制安全之堆溢出”系列第一期,主要介紹CTF環(huán)境配置。
安裝pwntools
sudo apt install python-pip python3-pip
sudo pip install pwntools
提示安裝python-dev可以使用aptitude安裝
這一步建議掛代理
python
>>> import pwn >>> pwn.asm("xor eax,eax") '1\xc0' #安裝成功
安裝pwndgb
git clone?https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh
安裝gef
wget -q?https://github.com/hugsy/gef/raw/master/gef.py
echo "source ~/gef/gef.py" >> ~/.gdbinit
安裝peda
git clone?https://github.com/longld/peda.git?~/peda
echo "source ~/peda/peda.py" >> ~/.gdbinitfile
安裝ROPgadget
用來構(gòu)建rop鏈
git clone?https://github.com/JonathanSalwan/ROPgadget.git
pip install capstone
cd ROPgadget
python setup.py install
ROPgadget
安裝one_gadget
尋找libc文件中的一些shell地址
gem install one_gadget
gdb切換腳本
#!/bin/bash function Mode_change { name=$1 gdbinitfile=/root/.gdbinit #這個路徑按照你的實際情況修改 peda="source ~/peda/peda.py" #這個路徑按照你的實際情況修改 gef="source ~/gef/gef.py" #這個路徑按照你的實際情況修改 pwndbg="source /root/pwndbg/gdbinit.py" #這個路徑按照你的實際情況修改 sign=$(cat $gdbinitfile | grep -n "#this place is controled by user's shell") #此處上面的查找內(nèi)容要和你自己的保持一致 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
安裝zsh
apt-get install zsh
git clone?https://github.com/robbyrussell/oh-my-zsh.git
cd oh-my-zsh/tools
./install.sh
下載安裝 zsh-autosuggestions (自動補全可能路徑)
git clone git://http://github.com/zsh-users/zsh-autosuggestions?$ZSH_CUSTOM/plugins/zsh-autosuggestions
下載 autojump (快速跳轉(zhuǎn))
git clone?https://github.com/joelthelion/autojump.git
cd autojump
./install.py
將[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh添加到zshrc文件尾 下載安裝 zsh-syntax-highlighting (終端輸入高亮 正確路徑下劃線)
git clone?https://github.com/zsh-users/zsh-syntax-highlighting.git?${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
vi ~/.zshrc
plugins=(git autojump zsh-autosuggestions zsh-syntax-highlighting)
source .zshrc
改變默認shell
chsh -s /bin/zsh
輔助命令
查看libc版本
find / -name libc.so.6
ll /lib/x86_64-linux-gnu/libc.so.6?
lrwxrwxrwx 1 root root 12 4月 15 06:11 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.23.so
sudo ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27 Copyright (C) 2018 自由軟件基金會。
開啟ssh
apt-get install openssh-server
vi /etc/ssh/sshd_config
vi /etc/ssh/ssh_config
添加:PermitRootLogin yes
以上就是本期全部內(nèi)容啦??!
【下期預(yù)告】二進制安全之堆溢出——堆基礎(chǔ) & 結(jié)構(gòu)
