diff --git a/dockerfile-kasm-cyberbro b/dockerfile-kasm-cyberbro new file mode 100644 index 00000000..5fc114ae --- /dev/null +++ b/dockerfile-kasm-cyberbro @@ -0,0 +1,48 @@ +ARG BASE_TAG="develop" +ARG BASE_IMAGE="core-ubuntu-noble" +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:5000 +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_deluxe.sh \ + /ubuntu/install/firefox/install_firefox.sh \ + /ubuntu/install/cyberbro/install_cyberbro.sh \ + /ubuntu/install/cleanup/cleanup.sh" + +# Copy install scripts +COPY ./src/ $INST_DIR + +RUN cp /usr/share/backgrounds/bg_kasm.png /usr/share/backgrounds/bg_default.png +COPY ./src/ubuntu/install/cyberbro/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} || exit 1; \ + 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/cyberbro/README.md b/docs/cyberbro/README.md new file mode 100644 index 00000000..35652e7d --- /dev/null +++ b/docs/cyberbro/README.md @@ -0,0 +1,43 @@ +# About This Image + +This Image contains a browser-accessible version of [Cyberbro](https://github.com/stanfrbd/cyberbro). + +![Screenshot][Image_Screenshot] + +[Image_Screenshot]: https://github.com/user-attachments/assets/f6ffb648-e161-4c59-9359-51183b0b0ca0 "Image Screenshot" + +# Environment Variables + +## Firefox Configuration + +* `FIREFOX_APP_ARGS` - Additional arguments to pass to firefox when launched. + +## Cyberbro Configuration + +Here is a list of all available environment variables that can be used with examples: + +```bash +PROXY_URL=http://127.0.0.1:9000 +VIRUSTOTAL=api_key_here +ABUSEIPDB=api_key_here +IPINFO=api_key_here +GOOGLE_SAFE_BROWSING=api_key_here +MDE_TENANT_ID=api_key_here +MDE_CLIENT_ID=api_key_here +MDE_CLIENT_SECRET=api_key_here +SHODAN=api_key_here +OPENCTI_API_KEY=api_key_here +OPENCTI_URL=https://demo.opencti.io +API_PREFIX=my_api +GUI_ENABLED_ENGINES=reverse_dns,rdap,hudsonrock,mde,shodan,opencti,virustotal +CONFIG_PAGE_ENABLED=true +``` + +> Note: if you set `GUI_ENABLED_ENGINES` to `""` then all engines will be enabled in the GUI. \ +> By default, all **free engines** will be enabled in the GUI. + +Refer to [Cyberbro Wiki](https://github.com/stanfrbd/cyberbro/wiki) for more information. + +You must edit the config in your KASM Cyberbro Workspace settings to add these environment variables, according to [KASM official doc](https://kasmweb.com/docs/latest/guide/workspaces.html#examples) + +![image](https://github.com/user-attachments/assets/33125248-31e8-4315-a772-e0546a8be659) \ No newline at end of file diff --git a/docs/cyberbro/demo.txt b/docs/cyberbro/demo.txt new file mode 100644 index 00000000..04359184 --- /dev/null +++ b/docs/cyberbro/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/cyberbro/description.txt b/docs/cyberbro/description.txt new file mode 100644 index 00000000..a14e442e --- /dev/null +++ b/docs/cyberbro/description.txt @@ -0,0 +1 @@ +Cyberbro for Kasm Workspaces \ No newline at end of file diff --git a/src/ubuntu/install/cyberbro/custom_startup.sh b/src/ubuntu/install/cyberbro/custom_startup.sh new file mode 100644 index 00000000..25914db5 --- /dev/null +++ b/src/ubuntu/install/cyberbro/custom_startup.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -ex +START_COMMAND="firefox" +PGREP="firefox" +export MAXIMIZE="true" +export MAXIMIZE_NAME="Mozilla Firefox" +MAXIMIZE_SCRIPT=$STARTUPDIR/maximize_window.sh +DEFAULT_FIREFOX_ARGS="" +FIREFOX_ARGS=${FIREFOX_APP_ARGS:-$DEFAULT_FIREFOX_ARGS} + +CYBERBRO_SERVER="127.0.0.1:5000" + +# Check if GUI_ENABLED_ENGINES is set else apply default +if [ -z ${GUI_ENABLED_ENGINES+x} ]; then + GUI_ENABLED_ENGINES=reverse_dns,rdap,ipquery,spur,phishtank,threatfox,urlscan,google,github,ioc_one_html,ioc_one_pdf,abusix,hudsonrock +fi + +# Make GUI_ENABLED_ENGINES an environment variable +export GUI_ENABLED_ENGINES + +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://$CYBERBRO_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/cyberbro/cyberbro-* + # Start Cyberbro server in background + bash -c "source venv/bin/activate && gunicorn -b 0.0.0.0:5000 app:app &" + 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 \ No newline at end of file diff --git a/src/ubuntu/install/cyberbro/install_cyberbro.sh b/src/ubuntu/install/cyberbro/install_cyberbro.sh new file mode 100644 index 00000000..0271e5d2 --- /dev/null +++ b/src/ubuntu/install/cyberbro/install_cyberbro.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -xe + +# Get latest Cyberbro version +CYBERBRO_VERSION=$(curl -sX GET "https://api.github.com/repos/stanfrbd/cyberbro/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') + +# Install Cyberbro +echo "Install Cyberbro" +apt-get update +apt-get install -y python3-pip git virtualenv +CYBERBRO_HOME=$HOME/cyberbro +mkdir -p $CYBERBRO_HOME +cd $CYBERBRO_HOME +wget https://github.com/stanfrbd/cyberbro/archive/${CYBERBRO_VERSION}.tar.gz +tar zxvf ${CYBERBRO_VERSION}.tar.gz +rm ${CYBERBRO_VERSION}.tar.gz +cd cyberbro-* + +# Enter virtualenv to avoid conflicts with system packages +virtualenv venv +source venv/bin/activate + +pip3 install -r requirements.txt + +deactivate + +# Cleanup for app layer +chown -R 1000:0 $HOME +find /usr/share/ -name "icon-theme.cache" -exec rm -f {} \; +if [ -z ${SKIP_CLEAN+x} ]; then + apt-get autoclean + rm -rf \ + /var/lib/apt/lists/* \ + /var/tmp/* \ + /tmp/* +fi +