Construct all pwn enviroment for just a few commands,only need docker!
pwndbg
:pwndbg/pwndbg: Exploit Development and Reverse Engineering with GDB Made Easy (github.com)Pwngdb
:scwuaptx/Pwngdb: gdb for pwn (github.com)peda
:longld/peda: PEDA - Python Exploit Development Assistance for GDB (github.com)pwntools
:Gallopsled/pwntools: CTF framework and exploit development library (github.com)other essential
:ROPgadget..and so on
Before that,you have to download docker.io
!And make sure your container could connect to network!
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
Change path to the pwn topic
dockerPwnRun [pwnfileDir] [docker_images_name]
dockerPwnRun [pwnfileDir] [docker_images_name] -g [port]
And the pwnfileDir is on /ctf/
The pwnfileDir is mapped to the docker from host machine.So,you could change it just under the host machine.
Besides,when you exit from the docker,the container will be removed,it won't occupy the space.
You could check the images:
docker images
Copy the ld.so and libc.so to dockerLibc
after finishing the docker image.
In theory,if you could provide the corresponding version sources.list and the docker hub has corresponding version ubuntu.Any glibc version could be created!But before that,you should change some configuration:
#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")
Add some corresponding version,such as follow:
#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")
Add the [2.19]="14.04"
just for that!
Add the following statements could realize gdb.attach(p)
function!
dockerPwnRun [pwnfileDir] [docker_images_name] -g 30001
The port could be set up as for yourself!
#In exp.py
def dockerDbg():
myGdb = remote("127.0.0.1",30001)
myGdb.close()
pause()
This function is base on docker host network.
The default terminal is gnome-terminal.But you could reset it by your own terminal.The configuration of terminal is in the file terminalConfig
.You could change it to other terminal.
And the supported terminal are:
gnome-terminal
xterm
xfce4-terminal
You could also add some other terminal.And chang the terminalConfig.Such as the 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
You could uncomment the follow statement in the file setup.sh
before creating docker image.
##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"
Under the statment,you could add your own thing to the image!In file setup.sh
##add your own thing here----------------------------
docker cp file $version_images:/root/
You could install other software to the image!In the end of the file install.sh