c++算术溢出_二进制安全之堆溢出(系列)——CTF环境配置

本文详细介绍CTF环境中堆溢出攻击的相关配置步骤,包括pwntools、pwndbg等工具的安装与设置,以及如何配置GDB进行调试。通过本教程,读者能够掌握基本的二进制安全知识及实践技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

e7008125a3909dfe4260b4aa3dcd2ce8.png

【重要通知】知了堂禁卫实验室全新上线!!
这里有安全体系的学习资源、
最前沿的原创文章、最新的漏洞挖掘原创!!

f04d3153af8112c2d35d22ea9126c795.png

本期是“二进制安全之堆溢出”系列第一期,主要介绍CTF环境配置安装pwntools

  • sudo apt install python-pip python3-pip
  • sudo pip install pwntools
    • 提示安装python-dev可以使用aptitude安装
    • 这一步建议挂代理
  • python

>>> import pwn >>> pwn.asm("xor eax,eax") '1xc0' #安装成功安装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
以上就是本期全部内容啦!!【下期预告】二进制安全之堆溢出——堆基础 & 结构

f699e76e3ca19cf6eea723b55f0e330d.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值