Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Cyberbro workspace #131

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
48 changes: 48 additions & 0 deletions dockerfile-kasm-cyberbro
Original file line number Diff line number Diff line change
@@ -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"]
43 changes: 43 additions & 0 deletions docs/cyberbro/README.md
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions docs/cyberbro/demo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Live Demo

<a href="https://app.kasmweb.com/#/cast/<TO_BE_DEFINED>" target="_blank"><img src="https://5856039.fs1.hubspotusercontent-na1.net/hubfs/5856039/dockerhub/GIFs/<TO_BE_DEFINED>" width="640" height="360"></a>

**Launch a real-time demo in a new browser window:** <a href="https://app.kasmweb.com/#/cast/<TO_BE_DEFINED>" target="_blank">Live Demo</a>.

<a href="https://app.kasmweb.com/#/cast/<TO_BE_DEFINED>" target="_blank"><img src="https://5856039.fs1.hubspotusercontent-na1.net/hubfs/5856039/dockerhub/casting-buttons/<TO_BE_DEFINED>" width="300" height="104"></a>

&lowast;*Note: Demo is limited to 3 minutes and has upload/downloads restricted for security purposes.*
1 change: 1 addition & 0 deletions docs/cyberbro/description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cyberbro for Kasm Workspaces
85 changes: 85 additions & 0 deletions src/ubuntu/install/cyberbro/custom_startup.sh
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions src/ubuntu/install/cyberbro/install_cyberbro.sh
Original file line number Diff line number Diff line change
@@ -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