pwn环境docker化

拉取镜像

1
2
3
4
5
6
7
8
9
# docker pull ubuntu:18.04
18.04: Pulling from library/ubuntu
23884877105a: Pull complete
bc38caa0f5b9: Pull complete
2910811b6c42: Pull complete
36505266dcc6: Pull complete
Digest: sha256:3235326357dfb65f1781dbc4df3b834546d8bf914e82cce58e6e6b676e23ce8f
Status: Downloaded newer image for ubuntu:18.04
docker.io/library/ubuntu:18.04

可以看到我们刚拉取的镜像

1
2
3
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 c3c304cb4f22 3 weeks ago 64.2MB

然后启动镜像,这里–name参数起了个花名

1
2
# docker run -i -t --name pwn_2.27 ubuntu:18.04 bash
root@e987b131fa26:/#

环境搭建

一个新的docker环境里面是啥也没有的,连vim都没有,所以先update一下然后装一手vim,之后换源

1
2
3
4
5
6
7
8
9
10
11
12
13
# vim /etc/apt/sources.list
ggdG清空sources.list后改为阿里源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

保存后update一下

接下来安装相应的环境

这里直接拿了知世师傅的脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# auto install the pwn environment
# @author:知世
# @category:environment build

if [ `whoami` = "root" ];then
dpkg --add-architecture i386
apt-get update -y
apt-get install python -y
apt-get install python-pip -y
apt-get install gcc -y
apt-get install gdb -y
apt-get install git -y
apt-get install wget -y
apt-get install gem -y
apt-get install ruby -y
apt-get install tmux -y
apt-get install libc6-dev-i386 -y
apt-get install libc6-dbg -y
apt-get install libc6-dbg:i386 -y
apt-get install python-setuptools -y
apt-get install make -y
apt-get -y install netcat-traditional
apt-get install ruby-dev -y
gem install seccomp-tools //这里安装失败,需要ruby>=2.4才能安装seccomp-tools
gem install one_gadget
pip install pwntools -i https://pypi.tuna.tsinghua.edu.cn/simple/
cd
git clone https://github.com/nightRainy/pwndbg.git
cd pwndbg
./setup.sh
cd
git clone https://github.com/inaz2/roputils.git
cd
git clone https://github.com/lieanu/LibcSearcher.git
cd LibcSearcher
python setup.py develop
else
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install python -y
sudo apt-get install python-pip -y
sudo apt-get install gcc -y
sudo apt-get install gdb -y
sudo apt-get install git -y
sudo apt-get install wget -y
sudo apt-get install gem -y
sudo apt-get install ruby -y
sudo apt-get install tmux -y
sudo apt-get -y install netcat-traditional
sudo apt-get install libc6-dev-i386 -y
apt-get install libc6-dbg -y
apt-get install libc6-dbg:i386 -y
sudo apt-get install ruby-dev -y
sudo apt-get install python-setuptools -y
sudo apt-get install make -y
sudo gem install seccomp-tools
sudo gem install one_gadget
pip install pwntools
cd
git clone https://github.com/nightRainy/pwndbg.git
cd pwndbg
./setup.sh
cd
git clone https://github.com/inaz2/roputils.git
cd
git clone https://github.com/lieanu/LibcSearcher.git
cd LibcSearcher
python setup.py develop
fi

这里需要注意安装seccomp-tools时如果是ubuntu16的话,默认安装的ruby版本是2.23,但是安装seccomp-tools要求ruby版本2.4以上,所以这里需要先升级一下ruby

1
2
3
4
5
6
7
8
apt-get install software-properties-common
#添加PPA源:
add-apt-repository ppa:brightbox/ruby-ng
apt-get update
#先删除旧版本:
apt-get purge --auto-remove ruby
#安装新版本
apt-get install ruby2.6 ruby2.6-dev

设置tmux的鼠标切换

1
2
~# touch .tmux.conf
~# echo 'set -g mouse on' > .tmux.conf

打包为镜像上传

首先docker ps -a查看我们docker 的实例号:

再打包为镜像

1
docker commit -m "pwn 19.04 2.29" a403d2342bb4 r4bbit/dockerpwn:2.29

上传

1
docker push r4bbit/dockerpwn:2.29

如果出现:

1
denied: requested access to the resource is denied

docker login登录一下就行了

0%