二进制安全之堆溢出(系列)——CTF环境配置
【重要通知】知了堂禁卫实验室全新上线!!
这里有安全体系的学习资源、
最前沿的原创文章、最新的漏洞挖掘原创!!

本期是“二进制安全之堆溢出”系列第一期,主要介绍CTF环境配置。
安装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
用来构建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") #此处上面的查找内容要和你自己的保持一致 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 (快速跳转)
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
以上就是本期全部内容啦!!
【下期预告】二进制安全之堆溢出——堆基础 & 结构
