# 使用32位基础镜像 FROM --platform=linux/386 i386/ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
# 不再需要添加i386架构,基础镜像已为32位 # RUN dpkg --add-architecture i386 && apt-get -y update
# 基础工具 RUN apt-get update && apt-get install -y \ apt-transport-https \ vim \ git \ curl \ wget \ sudo \ netcat-openbsd \ openssh-server \ unzip \ bison \ flex
# Python工具 RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ python3-venv \ python3-dev \ python3-setuptools
# 开发工具链 RUN apt-get update && apt-get install -y \ build-essential \ libglib2.0-dev \ #libfdt-dev \ libpixman-1-dev \ zlib1g-dev \ gdb \ clang \ lldb \ make \ cmake
# 32位库(适配纯32位系统) RUN apt-get update && apt-get install -y \ libc6-dbg \ libgcc-s1 \ zlib1g # 32位系统中替代lib32z1的库
# enable ssh login RUN rm -f /etc/service/sshd/down RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config &&\ sed -ri 's/#UseDNS\ no/UseDNS\ no/g' /etc/ssh/sshd_config && \ sed -ri "s/StrictModes yes/StrictModes no/g" /etc/ssh/sshd_config && \ sed -ri "s/UsePAM yes/UsePAM no/g" /etc/ssh/sshd_config
# enable login with password RUN echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config
# defaultly we have a user `ubuntu` in the image RUN echo "root:123456" | chpasswd
# enable ssh key login #RUN mkdir /home/ubuntu/.ssh && \ # echo "Your ssh key" > /home/ubuntu/.ssh/authorized_keys
# keep container running RUN echo "#!/bin/sh\nservice ssh restart\nsleep infinity" > /root/start.sh RUN chmod +x /root/start.sh
# create venv for pip(改为 root 的虚拟环境) RUN python3 -m venv /pip_venv && \ echo "\n\n# pip venv\nsource /pip_venv/bin/activate" >> /root/.bashrc # 改到 root 的 bashrc # 安装编译依赖(放在安装pwn工具的RUN指令之前) RUN apt-get update && apt-get install -y \ build-essential \ gcc-10 g++-10 \ libssl-dev \ rustc cargo \ && rm -rf /var/lib/apt/lists/* \ # 切换默认GCC为10版本(支持c++20) && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 \ && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
# pwn-related tools RUN /pip_venv/bin/pip config set global.index-url https://pypi.org/simple && \ /pip_venv/bin/pip config set global.trusted-host pypi.org && \ /pip_venv/bin/pip install --default-timeout=100 --retries=10 -U pip && \ /pip_venv/bin/pip install --default-timeout=100 --retries=10 --no-cache-dir \ cryptography==39.0.1 \ pwntools \ ROPgadget \ z3-solver \ smmap2 \ apscheduler \ ropper \ unicorn \ keystone-engine \ capstone # 安装CA证书,解决SSL验证问题 RUN apt-get update && apt-get install -y ca-certificates && \ update-ca-certificates && \ rm -rf /var/lib/apt/lists/* # 替换pip源为清华源,并信任相关域名 RUN /pip_venv/bin/pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \ /pip_venv/bin/pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn && \ /pip_venv/bin/pip config set global.timeout 100 RUN /pip_venv/bin/pip install --retries 20 --default-timeout 200 \ angr==9.2.10 \ pebble \ r2pipe \ git+https://github.com/lieanu/LibcSearcher.git \ poetry \ z3-solver==4.8.8
# 克隆 pwndbg 并切换到支持 Python 3.8 的分支 # 添加 Poetry 安装路径到环境变量 RUN export PATH="/pip_venv/bin:$PATH" && \ git clone https://github.com/pwndbg/pwndbg && \ cd pwndbg && \ git checkout 2024.08.29 && \ chmod +x setup.sh && \ ./setup.sh
CMD ["/root/start.sh"] EXPOSE 22
|