Skip to content

Instantly share code, notes, and snippets.

@seamustuohy
Created August 27, 2018 01:49
Show Gist options
  • Save seamustuohy/bc337b9365768dd7b8fd42f4128d7c99 to your computer and use it in GitHub Desktop.
Save seamustuohy/bc337b9365768dd7b8fd42f4128d7c99 to your computer and use it in GitHub Desktop.
Viper - Proof Of Concept
# This file is part of Viper - https://github.com/viper-framework/viper
# See the file 'LICENSE' for copying permission.
#
FROM ubuntu:rolling
# FROM debian:buster
MAINTAINER Viper-Framework (https://github.com/viper-framework)
# Set Local
ENV LANG C.UTF-8
# === Viper Base & Intallation Dependencies ===
USER root
RUN apt-get update && apt-get install -y \
git \
gcc \
python3-dev \
python3-pip \
sudo \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Create Viper User
# Running all commands as a non-root sudo privlaged user to recreate a real install
RUN groupadd -r viper && \
useradd -r -g viper -d /home/viper -s /bin/bash -c "Viper User" viper && \
mkdir /home/viper && \
chown -R viper:viper /home/viper
# Make passwordless sudo'er for demonstration purposes
RUN echo "viper ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Become our non-root example user
USER viper
# Viper Dependencies
RUN sudo apt-get update && \
sudo apt-get install -y \
libssl-dev \
swig \
libffi-dev \
ssdeep `# Fuzzy Module` \
libfuzzy-dev `# Fuzzy Module` \
exiftool `# PyExifTool` \
unrar `# Archive Core Module` \
p7zip-full `# Archive Core Module` \
--no-install-recommends && \
sudo rm -rf /var/lib/apt/lists/*
RUN sudo -H pip3 install setuptools wheel --upgrade
# === Tor Support ===
ENV TOR_ENABLED True
RUN sudo apt-get update && \
sudo apt-get install -y \
tor \
--no-install-recommends && \
sudo rm -rf /var/lib/apt/lists/*
# === TOR END ===
# === ClamAV ===
ENV CLAMAV_ENABLED True
RUN sudo apt-get update && \
sudo apt-get install -y \
clamav-daemon \
--no-install-recommends && \
sudo rm -rf /var/lib/apt/lists/*
RUN sudo freshclam
RUN sudo mkdir /var/run/clamav && \
sudo chown clamav:clamav /var/run/clamav && \
sudo chmod 750 /var/run/clamav
# === CLAMAV END ===
# === RADARE ===
ENV RADARE_ENABLED True
RUN sudo apt-get update && \
sudo apt-get install -y \
patch \
make \
--no-install-recommends && \
sudo rm -rf /var/lib/apt/lists/*
# Get latest radare2 release and build it
WORKDIR /home/viper
RUN git clone https://github.com/radare/radare2.git \
&& cd radare2 \
&& ./sys/user.sh
# # Add Radare to the environment
ENV PATH="/home/viper/bin:${PATH}"
# === RADARE END ===
# === Scraper Support (And General Twisted Support) ===
ENV SCRAPER_ENABLED True
RUN sudo apt-get update && \
sudo apt-get install -y \
libdpkg-perl \
--no-install-recommends && \
sudo rm -rf /var/lib/apt/lists/*
# === SCRAPER END ===
# Will force rebuild from this point based on a change to this string
# This will re-pull the git repo and rebuild
# Useful since pip operates seemingly at random in the way it works
ARG GIT_CACHE_DATE="2018-08-26-21-45"
WORKDIR /home/viper
ARG BRANCH="issue_696"
# UNCOMMENT
RUN git clone https://github.com/seamustuohy/viper \
&& cd viper \
&& git checkout "${BRANCH}" \
&& git submodule init \
&& git submodule update
WORKDIR /home/viper/viper
RUN sudo -H pip3 install .
# Testing & Debugging Dependencies
RUN sudo -H pip3 install flake8 pytest pytest-cov pytest-django tox
COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
# Swap back to root user for the entrypoint setup script
USER root
WORKDIR /home/viper/viper
# It will auto-run pytest if started without "bash" as the command
CMD ["sudo" "-u" "viper" "pytest"]
#!/bin/bash
set -e
set -o pipefail
set -x
init(){
# ClamAV
if [[ ! -z "$CLAMAV_ENABLED" ]]; then
local clamav_running=$(ps -aux | grep [c]lamd)
if [ -z "$clamav_running" ]; then
echo "Starting clamav updater"
freshclam -d &
echo "Starting clamav in background"
clamd &
else
echo "ClamAV is running in already: ${clamav_running}"
fi
fi
# Tor
if [[ ! -z "$TOR_ENABLED" ]]; then
local tor_running=$(ps -aux | grep [t]or)
if [ -z "$tor_running" ]; then
echo "starting Tor in backgroud"
sudo -H -u viper /usr/bin/tor -f /etc/tor/torrc &
else
echo "Tor is running in already: ${tor_running}"
fi
fi
}
init
"$@"
docker build --rm --force-rm -t "s2e/viper" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment