Last active
October 24, 2019 01:40
-
-
Save mcd1992/b9bf6a302f2d593ca135fc884825c0f9 to your computer and use it in GitHub Desktop.
Docker CTF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reversing container for CTFs by mcd1992 | |
# docker run -ti --rm -v `pwd`:/workdir/ --security-opt seccomp:unconfined -P mcd1992/archctf:latest | |
FROM archlinux/base:latest | |
MAINTAINER mcd1992 | |
# Make port 31337 available for listening (must use -p for publishing) | |
EXPOSE 31337 | |
# Enable pacman colors and multilib repo; add vim to editor /etc/profile; set LOCALE to en_US.UTF-8 | |
RUN sed -i 's/#Color/Color/' /etc/pacman.conf &&\ | |
echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf &&\ | |
echo -e "\nexport EDITOR=vim\nexport VISUAL=vim\nexport PATH=\$PATH:/usr/bin/core_perl:\$HOME/bin:\$HOME/.local/bin" >> /etc/profile &&\ | |
echo "LANG=en_US.UTF-8" > /etc/locale.conf && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen &&\ | |
mkdir -p /etc/gdb && echo "source /usr/share/gef/gef.py" >> /etc/gdb/gdbinit | |
# Update to latest packages from repos and install some extras; also symlink vi to vim | |
ENV EXTRA_INSTALLS="sudo wget git vim base-devel bash-completion tmux perl iproute2 bind-tools nmap openbsd-netcat python-pip strace ltrace tree" | |
RUN pacman -Syyu --noconfirm $EXTRA_INSTALLS && ln -s /usr/bin/vim /usr/bin/vi | |
# Create tmux config file | |
RUN echo -e "unbind C-b\nset -g prefix C-a\nbind C-a last-window\nbind a send-prefix" > /etc/tmux.conf | |
# Create a sudo-able and regular user; create a group for /workdir access; add wheel group to sudoers | |
RUN groupadd workdir &&\ | |
useradd -d /home/sudouser -G wheel,workdir -m -U sudouser &&\ | |
useradd -d /home/user -G workdir -m -U user &&\ | |
echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheelgroup | |
# Create /workdir directory on root for volume mounting | |
RUN mkdir -m 2771 /workdir &&\ | |
chgrp workdir /workdir | |
# Change to sudouser user and cd to their home directory | |
USER sudouser | |
WORKDIR /home/sudouser | |
# Git clone yay repo | |
RUN git clone --depth=1 https://aur.archlinux.org/yay.git | |
# Install yay | |
WORKDIR /home/sudouser/yay | |
RUN makepkg -s -f -i --noconfirm | |
# Cleanup and install CTF tools | |
WORKDIR /home/sudouser | |
ENV CTF_TOOLS="downgrade radare2-git gdb gef-git ipython ropgadget python-pwntools-git python-keystone python-ropper pwndbg ropper" | |
RUN yes "" | yay -Syu --noconfirm $CTF_TOOLS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment