From cf63c0bde4388f7943c72bc80b5337c30ec726be Mon Sep 17 00:00:00 2001 From: Justin Travis Date: Fri, 17 Nov 2023 03:07:32 +0000 Subject: [PATCH] Resolve KASM-5241 "Feature/ spiderfoot" --- ci-scripts/template-vars.yaml | 9 +++ dockerfile-kasm-spiderfoot | 48 ++++++++++++ docs/spiderfoot/README.md | 12 +++ docs/spiderfoot/demo.txt | 9 +++ docs/spiderfoot/description.txt | 1 + .../install/spiderfoot/custom_startup.sh | 78 +++++++++++++++++++ .../install/spiderfoot/install_spiderfoot.sh | 17 ++++ 7 files changed, 174 insertions(+) create mode 100644 dockerfile-kasm-spiderfoot create mode 100644 docs/spiderfoot/README.md create mode 100644 docs/spiderfoot/demo.txt create mode 100644 docs/spiderfoot/description.txt create mode 100644 src/ubuntu/install/spiderfoot/custom_startup.sh create mode 100644 src/ubuntu/install/spiderfoot/install_spiderfoot.sh diff --git a/ci-scripts/template-vars.yaml b/ci-scripts/template-vars.yaml index 3eb4738..9f915c5 100644 --- a/ci-scripts/template-vars.yaml +++ b/ci-scripts/template-vars.yaml @@ -119,6 +119,15 @@ multiImages: changeFiles: - dockerfile-kasm-remmina - src/ubuntu/install/remmina/** + - name: spiderfoot + base: core-ubuntu-focal + dockerfile: dockerfile-kasm-spiderfoot + changeFiles: + - dockerfile-kasm-spiderfoot + - src/ubuntu/install/spiderfoot/** + - src/ubuntu/install/firefox/** + - src/ubuntu/install/tools/** + - src/ubuntu/install/cleanup/** - name: sublime-text base: core-ubuntu-focal dockerfile: dockerfile-kasm-sublime-text diff --git a/dockerfile-kasm-spiderfoot b/dockerfile-kasm-spiderfoot new file mode 100644 index 0000000..775424e --- /dev/null +++ b/dockerfile-kasm-spiderfoot @@ -0,0 +1,48 @@ +ARG BASE_TAG="develop" +ARG BASE_IMAGE="core-ubuntu-focal" +FROM kasmweb/$BASE_IMAGE:$BASE_TAG + +USER root + +ENV HOME /home/kasm-default-profile +ENV STARTUPDIR /dockerstartup +ENV LAUNCH_URL http://127.0.0.1:5002 +WORKDIR $HOME + +### Envrionment config +ENV DEBIAN_FRONTEND=noninteractive \ + SKIP_CLEAN=true \ + KASM_RX_HOME=$STARTUPDIR/kasmrx \ + DONT_PROMPT_WSL_INSTALL="No_Prompt_please" \ + INST_DIR=$STARTUPDIR/install \ + INST_SCRIPTS="/ubuntu/install/tools/install_tools.sh \ + /ubuntu/install/firefox/install_firefox.sh \ + /ubuntu/install/spiderfoot/install_spiderfoot.sh \ + /ubuntu/install/cleanup/cleanup.sh" + +# Copy install scripts +COPY ./src/ $INST_DIR + +RUN cp /usr/share/extra/backgrounds/bg_kasm.png /usr/share/extra/backgrounds/bg_default.png +COPY ./src/ubuntu/install/spiderfoot/custom_startup.sh $STARTUPDIR/custom_startup.sh +RUN chmod +x $STARTUPDIR/custom_startup.sh +RUN chmod 755 $STARTUPDIR/custom_startup.sh + +# Run installations +RUN \ + for SCRIPT in $INST_SCRIPTS; do \ + bash ${INST_DIR}${SCRIPT}; \ + done && \ + $STARTUPDIR/set_user_permission.sh $HOME && \ + rm -f /etc/X11/xinit/Xclients && \ + chown 1000:0 $HOME && \ + mkdir -p /home/kasm-user && \ + chown -R 1000:0 /home/kasm-user && \ + rm -Rf ${INST_DIR} + +# Userspace Runtime +ENV HOME /home/kasm-user +WORKDIR $HOME +USER 1000 + +CMD ["--tail-log"] diff --git a/docs/spiderfoot/README.md b/docs/spiderfoot/README.md new file mode 100644 index 0000000..a0d0192 --- /dev/null +++ b/docs/spiderfoot/README.md @@ -0,0 +1,12 @@ +# About This Image + +This Image contains a browser-accessible version of [Spiderfoot](https://github.com/smicallef/spiderfoot). + +![Screenshot][Image_Screenshot] + +[Image_Screenshot]: https://5856039.fs1.hubspotusercontent-na1.net/hubfs/5856039/dockerhub/image-screenshots/spiderfoot.png "Image Screenshot" + +# Environment Variables + +* `SPIDERFOOT_APP_ARGS` - Additional arguments to pass to spiderfoot when launched. +* `FIREFOX_APP_ARGS` - Additional arguments to pass to firefox when launched. diff --git a/docs/spiderfoot/demo.txt b/docs/spiderfoot/demo.txt new file mode 100644 index 0000000..7e03625 --- /dev/null +++ b/docs/spiderfoot/demo.txt @@ -0,0 +1,9 @@ +# Live Demo + + + +**Launch a real-time demo in a new browser window:** Live Demo. + + + +∗*Note: Demo is limited to 3 minutes and has upload/downloads restricted for security purposes.* diff --git a/docs/spiderfoot/description.txt b/docs/spiderfoot/description.txt new file mode 100644 index 0000000..ab3d1da --- /dev/null +++ b/docs/spiderfoot/description.txt @@ -0,0 +1 @@ +Spiderfoot for Kasm Workspaces \ No newline at end of file diff --git a/src/ubuntu/install/spiderfoot/custom_startup.sh b/src/ubuntu/install/spiderfoot/custom_startup.sh new file mode 100644 index 0000000..3d70879 --- /dev/null +++ b/src/ubuntu/install/spiderfoot/custom_startup.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +set -ex +START_COMMAND="firefox" +PGREP="firefox" +export MAXIMIZE="false" +export MAXIMIZE_NAME="Mozilla Firefox" +MAXIMIZE_SCRIPT=$STARTUPDIR/maximize_window.sh +DEFAULT_FIREFOX_ARGS="" +FIREFOX_ARGS=${FIREFOX_APP_ARGS:-$DEFAULT_FIREFOX_ARGS} + +SPIDERFOOT_SERVER="127.0.0.1:5002" +DEFAULT_SPIDERFOOT_ARGS="-l $SPIDERFOOT_SERVER" +SPIDERFOOT_ARGS=${SPIDERFOOT_APP_ARGS:-$DEFAULT_SPIDERFOOT_ARGS} + +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" + +while [[ $1 != -- ]]; do + case $1 in + -g|--go) GO='true'; shift 1;; + -a|--assign) ASSIGN='true'; shift 1;; + -u|--url) OPT_URL=$2; shift 2;; + *) echo "bad option: $1" >&2; exit 1;; + esac +done +shift + +# Process non-option arguments. +for arg; do + echo "arg! $arg" +done + +FORCE=$2 + +# run with vgl if GPU is available +if [ -f /opt/VirtualGL/bin/vglrun ] && [ ! -z "${KASM_EGL_CARD}" ] && [ ! -z "${KASM_RENDERD}" ] && [ -O "${KASM_RENDERD}" ] && [ -O "${KASM_EGL_CARD}" ] ; then + START_COMMAND="/opt/VirtualGL/bin/vglrun -d ${KASM_EGL_CARD} $START_COMMAND" +fi + +check_web_server() { + curl -s -o /dev/null http://$SPIDERFOOT_SERVER && return 0 || return 1 +} + +kasm_startup() { + if [ -n "$KASM_URL" ] ; then + URL=$KASM_URL + elif [ -z "$URL" ] ; then + URL=$LAUNCH_URL + fi + + if [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ; then + + echo "Entering process startup loop" + set +x + while true + do + if ! pgrep -x $PGREP > /dev/null + then + /usr/bin/filter_ready + /usr/bin/desktop_ready + cd $HOME/spiderfoot/spiderfoot-4.0/ + xfce4-terminal -x python3 sf.py $SPIDERFOOT_ARGS & + while ! check_web_server; do + sleep 1 + done + set +e + bash ${MAXIMIZE_SCRIPT} & + $START_COMMAND $FIREFOX_ARGS $URL + set -e + fi + sleep 1 + done + set -x + + fi +} + +kasm_startup diff --git a/src/ubuntu/install/spiderfoot/install_spiderfoot.sh b/src/ubuntu/install/spiderfoot/install_spiderfoot.sh new file mode 100644 index 0000000..fe1c3f2 --- /dev/null +++ b/src/ubuntu/install/spiderfoot/install_spiderfoot.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -xe +echo "Install Spiderfoot" + +apt-get update +apt-get install -y python3-pip + +SPIDERFOOT_HOME=$HOME/spiderfoot + +mkdir -p $SPIDERFOOT_HOME +cd $SPIDERFOOT_HOME +wget https://github.com/smicallef/spiderfoot/archive/v4.0.tar.gz +tar zxvf v4.0.tar.gz +cd spiderfoot-4.0 +pip3 install -r requirements.txt + +chown -R 1000:1000 $SPIDERFOOT_HOME \ No newline at end of file