Skip to content

Commit

Permalink
Add several ctf tools, rust, fix metasploit, and fix binwalk
Browse files Browse the repository at this point in the history
  • Loading branch information
stack committed Apr 3, 2024
1 parent fba2b69 commit e7b99cf
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 24 deletions.
85 changes: 67 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ ARG MSF_PATH="/opt/metasploit-framework/bin"
ARG MSF_SCRIPT="msfinstall"
ARG R2="https://github.com/radareorg/radare2.git"
ARG R2_PATH="/radare/radare2/sys"
ARG RSACTFTOOL="https://github.com/RsaCtfTool/RsaCtfTool.git"
ARG RUST_PATH="${HOME}""/.cargo/bin"
ARG PIP_FILE="${HOME}""/requirements.txt"
ARG SASQUATCH="https://github.com/devttys0/sasquatch"
ARG SECLISTS="https://github.com/danielmiessler/SecLists.git"
ARG WORDLIST_DIR_MAIN="/data/wordlists"
ARG WORDLIST_DIR_LINK="/usr/share/wordlists"
Expand All @@ -45,9 +48,10 @@ RUN dpkg --add-architecture i386 &&\

# Add a bunch of random things we may need from apt.
# For some reason, when I try to install too much at once,
# I get apt errors. So let's break it up:
# I get apt errors. Splitting up the installs also help us
# identify where an install issue is, so let's break it up:

# Start with some reandom things we need
# Start with some random things we need
RUN apt -y install\
bat\
ca-certificates\
Expand All @@ -60,6 +64,11 @@ RUN apt -y install\
trash-cli &&\
mkdir -p ~/.local/share/Trash

# Fix our locale
RUN sed -i '/^#.*en_US.UTF-8.*/s/^#//' /etc/locale.gen &&\
locale-gen en_US.UTF-8 &&\
dpkg-reconfigure locales

# Next, networking tools
RUN apt -y install\
curl\
Expand All @@ -80,19 +89,34 @@ RUN apt -y install\
RUN apt -y install\
libexpat1-dev\
libgmp-dev\
liblzma-dev\
liblzo2-dev\
libmpfr-dev

# Next, some things we need for hacking
# Next, some things we need for hacking.
# We have to split some of these out individually
# since some of these packages are huge

# Part 1 (random tools)
RUN apt -y install\
checksec\
hashcat\
hexedit\
patchelf\
postgresql\
procps\
sagemath\
procps

# Part 2 (sagemath by itself)
RUN apt -y install\
sagemath

# Part 3 (qemu full and user)
RUN apt -y install\
qemu\
qemu-user-static\
qemu-user-static

# Part 4 (remaining packages)
RUN apt -y install\
strace\
wine\
xz-utils
Expand All @@ -103,11 +127,6 @@ RUN apt -y install\
RUN apt -y install\
binutils-aarch64-linux-gnu

# Fix our locale
RUN sed -i '/^#.*en_US.UTF-8.*/s/^#//' /etc/locale.gen &&\
locale-gen en_US.UTF-8 &&\
dpkg-reconfigure locales

# Add NodeJS
RUN cd /tmp &&\
curl -sL install-node.vercel.app/lts > ./lts &&\
Expand All @@ -126,7 +145,7 @@ RUN apt -y install vim neovim &&\
# and update PATH now to avoid issues in the future
ENV VIRTUAL_ENV="${HOME}""/""${VENV}"
ARG VENV="prophesy"
ENV PATH="${VIRTUAL_ENV}""/bin:""${HOME}""/bin:""${PATH}"
ENV PATH="${VIRTUAL_ENV}""/bin:""${HOME}""/bin:""${RUST_PATH}"":""${PATH}"

RUN apt -y install\
python3\
Expand Down Expand Up @@ -163,6 +182,18 @@ RUN cd /tmp &&\
./setup.py install &&\
rm -rf /tmp/binwalk

# Binwalk requires sasquatch, which must be built separately
# The patch that is required fixes a "if statement not guarded" error.
# I have no idea why this happens, and this solution I just found online.
# No reason to trust it outside of the container...
RUN cd /tmp &&\
git clone "${SASQUATCH}" &&\
wget https://raw.githubusercontent.com/devttys0/sasquatch/82da12efe97a37ddcd33dba53933bc96db4d7c69/patches/patch0.txt &&\
mv -f ./patch0.txt ./sasquatch/patches/patch0.txt &&\
cd ./sasquatch &&\
./build.sh &&\
rm -rf /tmp/sasquatch

# Install wordlists
RUN cd /tmp &&\
git clone "${SECLISTS}" &&\
Expand All @@ -173,20 +204,38 @@ RUN cd /tmp &&\
tar -xzf rockyou.txt.tar.gz

# Install metasploit
RUN cd /tmp &&\
curl "${MSF}" > "${MSF_SCRIPT}" &&\
chmod +x "${MSF_SCRIPT}" &&\
./"${MSF_SCRIPT}" &&\
rm -rf ./"${MSF_SCRIPT}"
RUN curl -fsSL https://apt.metasploit.com/metasploit-framework.gpg.key |\
gpg --dearmor |\
tee /usr/share/keyrings/metasploit.gpg > /dev/null

RUN echo "deb [signed-by=/usr/share/keyrings/metasploit.gpg] http://downloads.metasploit.com/data/releases/metasploit-framework/apt lucid main" |\
tee /etc/apt/sources.list.d/metasploit.list &&\
apt update -y &&\
apt install -y metasploit-framework

# Install Radare2
# And we have to keep the source dir around, so put it somewhere permanent
# We have to keep the source dir around, so put it somewhere permanent
RUN mkdir /radare &&\
cd /radare &&\
git clone "${R2}" &&\
cd "${R2_PATH}" &&\
./install.sh

# Install and link RsaCtfTool
# We have to keep this source dir around, as well
RUN cd / &&\
git clone "${RSACTFTOOL}" &&\
ln -s /RsaCtfTool/RsaCtfTool.py /usr/local/bin/RsaCtfTool

# Install rust and rust tools we like
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh &&\
sh ./rustup.sh -y &&\
rm -rf ./rustup.sh

RUN rustup update
RUN cargo install pwninit
RUN cargo install rustscan

# Cleanup
RUN apt clean &&\
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ isn't ideal, but it is the best solution I have now. Obviously, from the
host, you can make any changes to the files you want (assuming you have
`root`).

## TODO
## v1.3

[X] Add patchelf
[X] Add sagemath
[ ] Add RsaCtfTool
[ ] Actually test binwalk extraction. Sasquatch doesn't work
[ ] Add pwninit via cargo
- Added patchelf
- Added rust, rustmap, and pwninit
- Added sagemath
- Added RsaCtfTool
- Binwalk extraction for squashfs was broken. Installed patch version of sasquatch to fix this
- Full update and upgrade of binaries
- Updated metasploit to use apt. The install script was broken for me

### Additional v1.3 Update Notes

The size of the image has blown up to just under 18GB. The process of building is time consuming and error prone since some of the installs take a lot of time and Docker seems to throw random errors if a single process lingers around too long. Basically, what we are getting at here is that we can no longer sanely recommend building locally, and we very likely will remove this option from the script in the next release. The option is retained at the moment, since we want people to be able to customize thei grasshopper Dockerfile, but, if this isn't done in advance, you could spend more than an hour building (the build takes 20-30 minutes, but if you encounter timeouts or errors, you just have to try again, which I have had to do 3 or 4 times in the past).
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
angr==9.2.68
gmpy==1.17
gmpy2==2.1.5
Pillow==10.0.0
pwntools==4.10.0
pycryptodome==3.18.0
Expand Down

0 comments on commit e7b99cf

Please sign in to comment.