Idealist17 / pwnDockerAll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pwnDockerAll

Language: English | 中文简体

只用几个命令建立PWN环境,只需要Docker!

Docker镜像包含

安装

需要先安装 docker.io,并且确保你的容器能够连上网络。

cd ~/
git clone https://github.com/PIG-007/pwnDockerAll.git 
#git clone https://gitee.com/Piggy007/pwnDockerAll.git
cd pwnDockerAll
chmod a+x setup.sh
sudo ./setup.sh [libc_version]
#such as this:
#sudo ./setup.sh 2.33

使用方法

终端改变路径到需要的PWN题处

dockerPwnRun [pwnfileDir] [docker_images_name]
dockerPwnRun [pwnfileDir] [docker_images_name] -g [port]

映射的PWN文件目录在/ctf/下

Snipaste_2021-08-27_21-58-42

由于PWN文件目录是从宿主机映射到容器中的,所以你可以在宿主机中修改文件exp.py

除此之外,当从容器中退出时,容器会自动删除,不会占用空间,即开即用。

可以用以下命令查看Docker镜像:

docker images

其他功能

获取其他版本Libc环境

理论上,只要提供了该Libc版本对应ubuntu的sources.list ,并且Docker hub也有该版本的ubuntu就可以创建。但是需要修改以下配置文件:

#the configuration is in setup.sh

dic=([2.23]="16.04"  [2.24]="17.04" [2.26]="17.10"
    [2.27]="18.04"  [2.28]="18.10" [2.29]="19.04"
    [2.30]="19.10"  [2.31]="20.04" [2.32]="20.10"
    [2.33]="21.04" [2.34]="22.04")

添加对应Libc版本的ubuntu,如下:

#the configuration is in setup.sh

dic=([2.19]="14.04" [2.23]="16.04"  [2.24]="17.04" [2.26]="17.10"
    [2.27]="18.04"  [2.28]="18.10" [2.29]="19.04"
    [2.30]="19.10"  [2.31]="20.04" [2.32]="20.10"
    [2.33]="21.04" [2.34]="22.04")

比如这里新建 [2.19]="14.04"

支持GDB attach功能

使用时加入-g参数,并指定端口即可使用类似 gdb.attach(p) 的功能,这个功能需要安装socat

apt-get install socat

然后就类似如下启动语句:

dockerPwnRun [pwnfileDir] [docker_images_name] -g 30001

exp.py中设置如下:

#In exp.py

def dockerDbg():
	myGdb = remote("127.0.0.1",30001)
	myGdb.close()
	pause()

这个功能是基于Docker的host网络的

其他终端添加

默认的终端是gnome-terminal。但是可以自己设置自己的终端,在terminalConfig文件下设置,默认支持的终端如下:

  • gnome-terminal
  • xterm
  • xfce4-terminal

同样可以添加其他终端,在文件dockerTerm中设置,添加对应语句,比如添加terminator :

terminalList=(gnome-terminal xterm xfce4-terminal terminator)

if [ "${terminal}" == "terminator" ];then
	#echo "gnome-terminal"
	sudo terminator -x bash -c "~/pwnDockerAll/dockerGDBOut;exec bash" bash"
	exit 1;
fi

用Glibc源码来调试

在安装对应版本的Docker镜像之前可以去掉在文件 setup.sh 中以下语句的注释来获得源码调试功能。

##gdb sources----------------------------------------

wget -P ./glibcFile/$version_images/ http://ftp.gnu.org/gnu/glibc/glibc-$version_images.tar.gz
tar -zxvf ./glibcFile/$version_images/glibc-$version_images.tar.gz -C ./glibcFile/$version_images/
docker cp ./glibcFile/$version_images/glibc-$version_images/ $conName:/root/glibc-src/
##add your own thing here----------------------------

docker exec $conName /bin/bash -c "sed -i 'N;6 i dir ~/glibc-src/malloc' ~/.gdbinit"

添加自己的东西

创建镜像之前可以在文件 setup.sh下列语句中添加自己的东西

##add your own thing here----------------------------
docker cp file $version_images:/root/

安装其他软件

可以在文件install.sh安装其他软件来实现其他功能

About


Languages

Language:Shell 100.0%