本文为看雪论坛优秀文章
看雪论坛作者ID:直木
一、docker常用命令
docker pull 镜像名称[:tag]
# e.g
docker pull ubuntu:16.04
docker images
docker rmi 镜像的标识(id或者镜像名称:tag)
### 将本地的镜像导出
docker save -o 导出的路径 镜像id/镜像名称:tag
#e.g.
docker save -o ./ubuntu.image ubuntu:16.04
### 加载本地的镜像文件
docker load -i 镜像文件
# e.g.
docker load -i ubuntu.image
docker tag 镜像id 新镜像名称:版本(tag)
# 简单操作
docker run 镜像的标识|镜像名称[:tag]
# 常用的参数
docker run -d -p 宿主机端口:容器端口 --name 容器名称 镜像的标识:镜像名称[:tag]
# -d:代表后台运行容器
# -p 宿主机端口:容器端口 :为了映射当前主机的端口和容器的端口
# --name:容器名称;指定容器的名称
docker ps [-qa]
# -a:查看全部的容器,包括没有运行
# -q:只查看容器的标识
docker exec -it 容器id bash
# 停止指定容器
docker stop 容器id
# 停止全部容器
docker stop $(docker ps -qa)
# 删除指定容器
docker rm 容器id
# 删除全部容器
docker rm $(docker ps -qa)
docker start 容器id
docker commit [OPTIONS] 容器标识 [镜像名称[:TAG]]
# OPTIONS:
# -a :提交的镜像作者;
# -c :使用Dockerfile指令来创建镜像;
# -m :提交时的说明文字;
# -p :在commit时,将容器暂停。
二、搭建步骤
FROM ubuntu:16.04
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update
RUN apt-get install \
python python3 \
python-pip python3-pip \
python-dev libffi-dev libssl-dev \
vim \
lib32ncurses5 lib32z1 \
ruby gem git \
-y
docker build -t pwn:latest .
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh
git clone https://hub.fastgit.org/pwndbg/pwndbg.git # 高速下载油猴脚本:https://zhuanlan.zhihu.com/p/262905603
cd pwndbg
./setup.sh
重试./setup.sh
哪个python库因为网络原因安装失败,那就自己指定源,先用pip3安装它。
git clone git://github.com/Mipu94/peda-heap.git ~/peda-heap
echo "source ~/peda-heap/peda.py" >> ~/.gdbinit
git clone https://hub.fastgit.org/Mipu94/peda-heap.git
echo "source /opt/tools/peda-heap/peda.py" >> ~/.gdbinit
apt install wget
#下载 `gef.sh` 并执行
wget -q -O- https://github.com/hugsy/gef/raw/master/gef.sh | sh
# 下载 `gef.py`, 并将其 `source` 写入 `.gdbinit`
wget -q -O ~/.gdbinit-gef.py https://github.com/hugsy/gef/raw/master/gef.py
echo source ~/.gdbinit-gef.py >> ~/.gdbinit
git clone https://github.com/scwuaptx/Pwngdb.git
cp Pwngdb/.gdbinit ~/
pwndbg:
echo "source /opt/tools/pwndbg/gdbinit.py" > ~/.gdbinit
peda-heap:
echo "source /opt/tools/peda-heap/peda.py" > ~/.gdbinit
gef:
echo "source ~/.gdbinit-gef.py" > ~/.gdbinit
# git clone https://github.com/lieanu/LibcSearcher.git 官方
git clone https://gitclone.com/github.com/lieanu/LibcSearcher.git # 加速
cd LibcSearcher
python setup.py develop
apt-get update
apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pwntools
python -m pip install --upgrade pip
# 豆瓣源
python -m pip install --upgrade pwntools -i https://pypi.douban.com/simple/
# 官方
git clone https://github.com/JonathanSalwan/ROPgadget.git
# 高速
git clone https://gitclone.com/github.com/JonathanSalwan/ROPgadget.git
cd ROPgadget
python setup.py install
# 移除https://rubygems.org源
gem sources --remove https://rubygems.org/
# 增加http://gems.ruby-china.org/源
gem sources -a http://gems.ruby-china.com/
# 安装
gem install one_gadget
# 官方
# git clone https://github.com/matrix1001/glibc-all-in-one.git
# 加速
git clone https://gitclone.com/github.com/matrix1001/glibc-all-in-one.git
cd glibc-all-in-one
./update_list #更新最新版本的glibc
cat list #查看可下载的glibc
./download glibc #glibc为你想要下载glibc的名字
ps:查看当前glibc版本号方法
/lib/x86_64-linux-gnu/libc.so.6
# 官方
# git clone https://github.com/NixOS/patchelf.git
# 加速
git clone https://gitclone.com/github.com/NixOS/patchelf.git
cd patchelf
./bootstrap.sh # 这里报错了,解决方法看下面
./configure
make
make install
make check
apt-get install autoconf automake libtool
apt-get install libffi-dev
cd /lib64 #进入64位的目录 glibc 32位就 cd /lib
# 在root态下链接
ln -s /opt/tools/glibc-all-in-one/libs/2.27-3ubuntu1.4_amd64/ld-2.27.so ./27_14-linux.so.2
#27代表glibc版本,14代表ubuntu后面的数字(单纯为了好记)
patchelf --set-interpreter /lib64/27_14-linux.so.2 ~/hello
# 第一个参数是ld.so的目录 , hello 是二进制文件
patchelf --replace-needed libc.so.6 /opt/tools/glibc-all-in-one/libs/2.27-3ubuntu1.4_amd64/libc-2.27.so ~/hello
#libc.so.6为需要替换的libc路径 第二个参数是需要加载的glibc的目录 , hello 是二进制文件
ldd ~/hello
# 查看是否更换成功
# 创建新镜像
docker commit -a "lzx" pwn:latest
docker save pwn:latest -o pwn.tar
看雪ID:直木
https://bbs.pediy.com/user-home-830671.htm
# 往期推荐
球分享
球点赞
球在看
点击“阅读原文”,了解更多!