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

Next js prototype #3896

Merged
merged 147 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
2eab14d
UI: Next.js prototype core
VakarisZ Oct 9, 2023
e970d16
UI: Implement redux
VakarisZ Oct 20, 2023
4eaa65d
TODO: Drop this commit, for testing polling only
VakarisZ Oct 20, 2023
14b340c
UI: Remove unnecessary server.tsx file
VakarisZ Oct 20, 2023
0c0fa94
UI: Implement redux example of machine fetching with pooling
VakarisZ Oct 23, 2023
defe9b5
UI: Run production server with https and certificates
VakarisZ Oct 23, 2023
5f806c7
UI: Run next.js webserver on Island start
VakarisZ Oct 25, 2023
0ec39aa
Deploy: Install node server
cakekoa Oct 26, 2023
18e8b85
Build: Install node server to the island
cakekoa Oct 26, 2023
18fd79b
Deploy: Use nextjs generated UI
cakekoa Oct 26, 2023
adaac7d
Build: Ensure nextjs build is copied over
cakekoa Oct 26, 2023
5b78f50
UI: Build with required modules bundled
cakekoa Oct 26, 2023
5f4627c
Build: Use standalone nextjs build
cakekoa Oct 26, 2023
d5eb2f1
UI: Add missing http-proxy-middleware package
cakekoa Oct 26, 2023
d1d3719
Build: Copy node_modules for nextjs build
cakekoa Oct 27, 2023
a9a9a5e
Build: Fail build if node fails to download
cakekoa Oct 27, 2023
08575cf
Build: Copy node_modules for nextjs build
cakekoa Oct 27, 2023
9127ffe
Build: Copy full next.js dependency
cakekoa Oct 30, 2023
e98d3b9
UI: Log messages when node server fails to start
cakekoa Oct 30, 2023
7bf1e62
Common: Add local port usage check
VakarisZ Oct 27, 2023
874abbf
Island: Add configurable node port
VakarisZ Oct 27, 2023
fecf3dc
Island: Add configurable node port
VakarisZ Oct 27, 2023
47624ba
Island: Convert IslandConfigOptions to a pydantic model
cakekoa Nov 1, 2023
2a6b80f
Island: Pass node server options via env variables
cakekoa Nov 1, 2023
300302f
Docs: Update documentation for the node server
cakekoa Nov 1, 2023
c0c19ca
Docs: Add context to `server_config.json` file page
shreyamalviya Nov 2, 2023
4d32b37
Docs: Explain port configuration for each deployment
VakarisZ Nov 3, 2023
17e40d6
UI: Bind the next.js server to 0.0.0.0 instead of default
VakarisZ Nov 6, 2023
e5f21f7
Build: Set capability for docker to open a port below 1024
VakarisZ Nov 7, 2023
9c701cd
Build: Change AppRun to allow the capability to open port < 1024
VakarisZ Nov 7, 2023
c40035e
Build: Change AppRun to allow the capability to open port < 1024
VakarisZ Nov 8, 2023
a6e5560
Build: Change appimage service to have the CAP_NET_BIND_SERVICE
VakarisZ Nov 13, 2023
a8152ed
Build: Change AppRun to assign ambient capabilities
VakarisZ Nov 14, 2023
1a566a9
Build: Simplify user ID check in AppRun
VakarisZ Nov 14, 2023
2a9e5de
Docs: Minor rewording in linux deployment
VakarisZ Nov 14, 2023
edf45aa
Build: Add a comment about EXPOSE 443 in Dockerfile
VakarisZ Nov 14, 2023
d0d9713
Docs: Rename node_port to javascript_runtime_port
VakarisZ Nov 14, 2023
06284f1
Island: Rename node_port to javascript_runtime_port
VakarisZ Nov 14, 2023
4d918b7
Docs: Improve port change documentation
VakarisZ Nov 14, 2023
47c48af
Common: Add a network utility to get filtered connections
VakarisZ Nov 15, 2023
f632afd
Common, Island: Add a utility method to check if port is used
VakarisZ Nov 15, 2023
670a651
Common: Fix type bug in get_connections
VakarisZ Nov 15, 2023
36e3093
Island: App psutil package
VakarisZ Nov 15, 2023
bf98349
Island: Fix a bug in port_is_used call
VakarisZ Nov 15, 2023
34cd423
Docs: Rename javascript_runtime_port to island_port
VakarisZ Nov 16, 2023
89c8830
Island: Rename javascript_runtime_port to island_port
VakarisZ Nov 16, 2023
426257f
Island: Add a todo for island_config_options.py
VakarisZ Nov 16, 2023
73717d0
Island: Move next.js consts to nextjs_process.py
VakarisZ Nov 16, 2023
c005f54
Build: Change AppImage to not use capsh during service run
VakarisZ Nov 16, 2023
773ea0a
Changelog: Add entry about configurable Island port
VakarisZ Nov 17, 2023
f10c851
UI: Add util to get node port
shreyamalviya Nov 21, 2023
eb79b0c
UI: Use custom node port in manual run monkey command generation
shreyamalviya Nov 21, 2023
d1826d5
Island: Use custom node port in local run monkey
shreyamalviya Nov 21, 2023
ade1093
Island: Use custom node port in AWS commands
shreyamalviya Nov 21, 2023
74f41e4
UT: Fix AWS tests
ilija-lazoroski Nov 21, 2023
a479eb8
Island: Rename ISLAND_PORT -> FLASK_PORT
shreyamalviya Nov 21, 2023
5588a59
UI: Rename NODE_PORT -> JS_RUNTIME_PORT
shreyamalviya Nov 21, 2023
c806301
UI: Use JS_RUNTIME_PORT constant in next_ui/server.js
shreyamalviya Nov 21, 2023
b920bee
Island: Revert temporary changes to AgentEvents resource
shreyamalviya Nov 21, 2023
d580f92
Island: Revert temporary changes to Machine model
shreyamalviya Nov 21, 2023
c8d8663
Island: Remove unneeded pysnmp dependency
shreyamalviya Nov 21, 2023
7194b88
Island: Modify logic to build AWSService object
shreyamalviya Nov 21, 2023
2424d12
UT: Fix AWSService tests
shreyamalviya Nov 21, 2023
9bb7457
Island: Change convention 'ip_addresses' -> 'island_ip_addresses'
shreyamalviya Nov 22, 2023
4497149
UI: Move JS_RUNTIME_PORT constant to next_ui/server.js
shreyamalviya Nov 22, 2023
1660f02
UI: Move JS_RUNTIME_PORT const to its own file
shreyamalviya Nov 22, 2023
74d5db5
Island: Use NEXT_PUBLIC_ for port env var
shreyamalviya Nov 23, 2023
86d5047
UI: Use NEXT_PUBLIC_ for port env var
shreyamalviya Nov 23, 2023
32a7cd9
Island: Use monkeytypes in nextjs setup code
VakarisZ Nov 24, 2023
0408733
Island: Add next.js feature flag
VakarisZ Nov 24, 2023
5e6509d
Changelog: Add entry about configurable Island port
VakarisZ Nov 17, 2023
abbdf60
UI: Add the core of next-auth
ordabach Nov 9, 2023
f90c0f5
UI: Fix auth and content
ordabach Nov 9, 2023
d4f9b01
UI: Constant changes
ordabach Nov 15, 2023
b8cd608
UI: Add dynamic secret value for nextAuth
ordabach Nov 15, 2023
4b3ee15
UI: Minor fixes
ordabach Nov 15, 2023
d502133
UI: Add DEV const to choose between dev and prod mode
VakarisZ Nov 21, 2023
0aabc4e
UI: Remove unused vars from next config
VakarisZ Nov 21, 2023
05aabb2
UI: Change next auth env vars to point to localhost
VakarisZ Nov 21, 2023
4fa163d
UI: Allow CRLF line endings for prettier
VakarisZ Nov 23, 2023
9332a74
UI: Remove strict typechecks
VakarisZ Nov 23, 2023
0aeba18
UI: Fix next-auth configuration to point to localhost
VakarisZ Nov 23, 2023
864456c
UI: Simplify credential provider code
VakarisZ Nov 24, 2023
3768196
UI: Remove default svg pictures
VakarisZ Nov 24, 2023
a081163
UI: Change the next-auth ports used based on dev or prod
VakarisZ Nov 24, 2023
020f2e3
UI: Remove unused certs
VakarisZ Nov 24, 2023
7fdbdef
UI: Remove unused authentication mocks
VakarisZ Nov 24, 2023
9a1b755
UI: Remove unused visual assets
VakarisZ Nov 24, 2023
10877e1
UI: Remove unused next.js components
VakarisZ Nov 24, 2023
da57a2d
UI: Keep error logs on production
ordabach Nov 28, 2023
86bbda1
UI: Add favicon
ordabach Nov 29, 2023
3ce595e
UI: Add basic not-found and 404 pages
ordabach Nov 29, 2023
435c285
UI: Remove comments
ordabach Nov 30, 2023
36ace92
UI: Change file structure to route groups
ordabach Nov 29, 2023
d17defa
UI: Remove comments
ordabach Dec 5, 2023
e19f6aa
UI: Update the logout button component
ordabach Dec 13, 2023
b8dd716
UI: Change the import path of the logout component
ordabach Dec 17, 2023
6daf1c7
UI: CSS change to center content
ordabach Dec 13, 2023
41a965a
UI: Change Test to GettingStarted component
ordabach Dec 13, 2023
bc76664
UI: Add app nav
ordabach Dec 13, 2023
6df981a
UI: Remove unused code
ordabach Dec 17, 2023
ac17b2b
UI: Add prop type
ordabach Dec 17, 2023
c0c50a0
UI: Add tooltip to the theme toggle
ordabach Dec 17, 2023
b332000
UI: Prettify tsconfig.json
ordabach Dec 17, 2023
599e923
Island: Improve feature flags to work in production
VakarisZ Nov 30, 2023
b58673a
Build: Add feature flag for next UI build
VakarisZ Dec 1, 2023
a5a20d6
Build: Fix "directory not found" error for node extraction
VakarisZ Dec 1, 2023
6ab1762
Build: Fix a typo in function call
VakarisZ Dec 1, 2023
13a0fc8
Build: Pass feature flag environmental variable to appImage
VakarisZ Dec 4, 2023
cd11f28
Build: Fix a bug that tries to copy nonexistent files
VakarisZ Dec 5, 2023
a0f7e03
Build: Redirect standard output of appimage extraction to /dev/null
VakarisZ Dec 5, 2023
e9074e4
Build: Fix next UI build
VakarisZ Dec 5, 2023
cd10c44
UI: Create production server.js for standalone deployment
VakarisZ Dec 7, 2023
d782e43
UI: Rename next server files to use - as word separator
VakarisZ Dec 8, 2023
7ab7286
UI: Add a build-standalone.js script that creates a standalone deploy…
VakarisZ Dec 8, 2023
c1327e9
UI: Expand development environment constants
VakarisZ Dec 8, 2023
4536a6c
Island: Add error in next.js process launch if UI is not built
VakarisZ Dec 8, 2023
77262b7
UI: Add dotenv package to be able load .env files in server.js
VakarisZ Dec 8, 2023
5a41863
UI: Replace server.js with server-dev.js
VakarisZ Dec 8, 2023
8861a96
UI: Use the more common NODE_ENV const to determine server run type
VakarisZ Dec 8, 2023
49db21d
Build: Fix-up next.js standalone build function in common.sh
VakarisZ Dec 11, 2023
4b1d301
UI: Remove outputFileTracingRoot form generated next config
VakarisZ Dec 15, 2023
4e74ef2
Build: Fix a bug with "remove_node_modules" for legacy UI
VakarisZ Dec 15, 2023
58cd5b3
UI: Remove npm start script
VakarisZ Dec 15, 2023
98bf825
Build: Remove unused node consts from common.sh
VakarisZ Dec 15, 2023
af9c4b2
Deploy: Change npm build command in deploy_linux.sh
VakarisZ Dec 15, 2023
7104b41
Deploy: Change npm build command in deploy_windows.ps1
VakarisZ Dec 15, 2023
0e0fa9a
Build: Don't use environment variables where local variables are suff…
VakarisZ Dec 15, 2023
301a41e
Island: Log port based on feature next_js feature flag
VakarisZ Dec 15, 2023
0280ea5
Island: Fix a typo in island interface log
VakarisZ Dec 18, 2023
7842782
Build: Add port opening capabilities to node binary
VakarisZ Dec 18, 2023
1823b50
Docs: Add a notice about required root permissions for AppImage
VakarisZ Dec 18, 2023
1943efc
Docs: Fix a typo in AWS documentation
VakarisZ Dec 18, 2023
76de8a6
UI: Refactor and fix route enum and its usages
VakarisZ Dec 18, 2023
dfb5493
UI: Rename routes to paths for consistency
VakarisZ Dec 19, 2023
fe361d7
UI: Fix incorrect typescript types
VakarisZ Dec 19, 2023
048dab2
UI: Fix prettier error in paths.constants.tsx
VakarisZ Dec 19, 2023
b878934
UI: Add typescript to MonkeyDrawer
VakarisZ Dec 19, 2023
49cbad4
UI: Move prettier config to a separate file
VakarisZ Dec 19, 2023
9a56184
Build: Fix build_dir naming when build docker UI
ilija-lazoroski Dec 18, 2023
50b26ea
Project: Add check for NextJS ui in Travis
ilija-lazoroski Dec 19, 2023
a2a1821
UI: Rename useResponsive to useSmallScreenCheck
VakarisZ Dec 19, 2023
93f2fba
UI: Fix eslint warnings in provider.tsx
VakarisZ Dec 20, 2023
578fb53
UI: Remove typescript configuration that ignores build errors
VakarisZ Dec 20, 2023
992fb83
Docs: Fix typo in docs
VakarisZ Dec 21, 2023
9afb808
UI: Remove the auto-generated README.md
VakarisZ Dec 21, 2023
db2e4d2
UI: Fix middleware registration in production
VakarisZ Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ jobs:
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=0
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # test for max warnings

# check NextJS code.
- cd ../next_ui
- npm ci # see https://docs.npmjs.com/cli/ci.html
- eslint ./src --quiet # test for errors
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=0
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # test for max warnings


# build documentation
- cd $TRAVIS_BUILD_DIR/docs
- ../hugo --verbose --environment staging
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added
- Configurable Island port through node proxy server. #3827
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to devise a way to expose this port through docker. Either that or provide documentation on how to expose the configured port when running the container

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK --network=host already exposes the port.

Copy link
Contributor

@cakekoa cakekoa Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That may be correct. I tried to test out this feature in docker and couldn't access the UI. I realized that modifying the server port is only applicable to the old UI but I still couldn't get it to work. In fact, if I modify it, the UI is not available at the original port (5000) or the new one

- Ability to change wallpaper as part of the ransomware simulation on Windows.
#1247

Expand Down
26 changes: 22 additions & 4 deletions build_scripts/appimage/AppRun
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
self="$(readlink -f -- $0)"
here="${self%/*}"
APPDIR="${APPDIR:-${here}}"
FEATURE_FLAGS="${FEATURE_FLAGS}"

# Export SSL certificate
export SSL_CERT_FILE="${APPDIR}/opt/_internal/certs.pem"

if [ "$1" == "service" ] ; then
if [ "$1" == "service" ]; then
exec /bin/bash "${APPDIR}/install-infection-monkey-service.sh" ${@:2}
fi

# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo "AppImage: Warning: running as root is not recommended. You should instead run the AppImage as a regular user."
echo "AppImage: If you want to run the Agent as root, do so by choosing manual run mode."
fi

# Call the entry point
for opt in "$@"
do
for opt in "$@"; do
[ "${opt:0:1}" != "-" ] && break
if [[ "${opt}" =~ "I" ]] || [[ "${opt}" =~ "E" ]]; then
# Environment variables are disabled ($PYTHONHOME). Let's run in a safe
Expand All @@ -24,7 +30,19 @@ do
fi
done


export PYTHONNOUSERSITE=1
(PYTHONHOME="${APPDIR}/opt/python3.11" exec "${APPDIR}/opt/python3.11/bin/python3.11" "${APPDIR}/usr/src/monkey_island.py" $@)

run_island="${APPDIR}/opt/python3.11/bin/python3.11 ${APPDIR}/usr/src/monkey_island.py"

if [[ -z ${MONKEY_APPIMAGE_SERVICE_RUN+x} ]]; then
# Save HOME and USER because capsh changes them. Until ubuntu adds --noenv option we have to rely on a workaround
home_original=$HOME
user_original=$USER

(PYTHONHOME="${APPDIR}/opt/python3.11" sudo capsh --keep=1 --user=${user_original} --inh=cap_net_bind_service --addamb=cap_net_bind_service -- -c "env HOME=${home_original} USER=${user_original} FEATURE_FLAGS=${FEATURE_FLAGS} ${run_island}" "$@")
else
(PYTHONHOME="${APPDIR}/opt/python3.11" ${run_island})
fi

exit "$?"
12 changes: 10 additions & 2 deletions build_scripts/appimage/appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ setup_build_dir() {
copy_infection_monkey_service_to_build_dir
modify_deployment "$deployment_type" "$BUILD_DIR"
add_agent_binaries_to_build_dir "$agent_binary_dir" "$BUILD_DIR"
add_node_to_build_dir "$BUILD_DIR" || handle_error

install_monkey_island_python_dependencies
install_mongodb

generate_ssl_cert "$BUILD_DIR"
build_frontend "$BUILD_DIR" "$is_release_build"
if [[ $FEATURE_FLAGS == *"NEXT_JS_UI"* ]]; then
log_message "Building Next.js frontend"
build_nextjs_frontend "$BUILD_DIR" "$is_release_build"
else
log_message "Building legacy frontend"
build_frontend "$BUILD_DIR" "$is_release_build"
fi

remove_python_appdir_artifacts

Expand All @@ -62,7 +69,8 @@ setup_python_appdir() {

chmod u+x "$PYTHON_APPIMAGE"

"./$PYTHON_APPIMAGE" --appimage-extract
log_message "extracting Python Appimage"
"./$PYTHON_APPIMAGE" --appimage-extract 1>/dev/null
rm "$PYTHON_APPIMAGE"
}

Expand Down
4 changes: 3 additions & 1 deletion build_scripts/appimage/install-infection-monkey-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install_service() {
install_systemd_unit "$1"

echo "The Infection Monkey service has been installed and will start on boot."
echo "Run 'systemctl start infection-monkey' to start the service now."
echo "Run 'sudo systemctl start infection-monkey' to start the service now."
}

exit_if_service_installed() {
Expand Down Expand Up @@ -68,7 +68,9 @@ After=network.target
[Service]
User=$1
Type=simple
Environment="MONKEY_APPIMAGE_SERVICE_RUN=1"
ExecStart="${MONKEY_BIN}/${APPIMAGE_NAME}"
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
Expand Down
39 changes: 28 additions & 11 deletions build_scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ copy_monkey_island_to_build_dir() {
local src=$1
local build_dir=$2

cp "$src"/__init__.py "$build_dir"
cp "$src"/monkey_island.py "$build_dir"
cp -r "$src"/common "$build_dir/"

rsync \
-ar \
--exclude=monkey_island/cc/ui/node_modules \
--exclude=monkey_island/cc/ui/.npm \
rsync -ar \
"$src"/monkey_island "$build_dir/"
}

Expand All @@ -22,6 +18,12 @@ modify_deployment() {
fi
}

add_node_to_build_dir() {
local build_dir="$1"
local node_dir="$build_dir/monkey_island/bin/node"
"$build_dir/monkey_island/linux/install_node.sh" "${node_dir}"
}

add_agent_binaries_to_build_dir() {
local agent_binary_dir=$1
local island_binaries_path="$2/monkey_island/cc/binaries/"
Expand Down Expand Up @@ -72,6 +74,27 @@ generate_ssl_cert() {
"$island_path"/linux/create_certificate.sh "$island_path"/cc
}

build_nextjs_frontend() {
local ui_dir="$1/monkey_island/cc/next_ui"
local is_release_build=$2
mkdir -p "$ui_dir"
pushd "$ui_dir" || handle_error

log_message "Generating front end"
npm ci
log_message "Running production front end build"
npm run build

log_message "Removing development artifacts"
mv "${ui_dir}/.next/standalone" "${ui_dir}/standalone"
rm -rf "${ui_dir}/.next"
mkdir "${ui_dir}/.next"
mv "${ui_dir}/standalone" "${ui_dir}/.next"
log_message "Next.js standalone deployment built successfully"

popd || handle_error
}

build_frontend() {
local ui_dir="$1/monkey_island/cc/ui"
local is_release_build=$2
Expand All @@ -89,12 +112,6 @@ build_frontend() {

popd || handle_error

remove_node_modules "$ui_dir"
}

remove_node_modules() {
# Node has served its purpose. We don't need to deliver the node modules with
# the package.
rm -rf "$1/node_modules"
rm -rf "$1/.npm"
}
Expand Down
6 changes: 5 additions & 1 deletion build_scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ FROM python:$PYTHON_VERSION-slim
COPY --from=builder /monkey /monkey
WORKDIR /monkey
EXPOSE 5000
# Javascript runtime server is running on port 443 by default
EXPOSE 443
ENV MONKEY_DOCKER_CONTAINER=true
RUN apt-get update \
&& apt-get install -y iputils-ping \
Expand All @@ -29,6 +31,8 @@ RUN apt-get update \
&& chmod 444 /monkey/monkey_island/cc/server.crt \
&& mkdir /monkey_island_data \
&& chmod 700 /monkey_island_data \
&& chown -R monkey-island:monkey-island /monkey_island_data
&& chown -R monkey-island:monkey-island /monkey_island_data \
&& setcap 'cap_net_bind_service=+ep' /monkey/monkey_island/bin/node/node

USER monkey-island
ENTRYPOINT ["/monkey/entrypoint.sh"]
7 changes: 6 additions & 1 deletion build_scripts/docker/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ setup_build_dir() {
copy_server_config_to_build_dir "$build_dir"
modify_deployment "$deployment_type" "$build_dir"
add_agent_binaries_to_build_dir "$agent_binary_dir" "$build_dir"
add_node_to_build_dir "$build_dir" || handle_error

generate_ssl_cert "$build_dir"

build_frontend "$build_dir" "$is_release_build"
if [[ $FEATURE_FLAGS == *"NEXT_JS_UI"* ]]; then
build_nextjs_frontend "$build_dir" "$is_release_build"
else
build_frontend "$build_dir" "$is_release_build"
fi
}

copy_entrypoint_to_build_dir() {
Expand Down
6 changes: 5 additions & 1 deletion deployment_scripts/deploy_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fi
# We can set main paths after we know the home dir
ISLAND_PATH="$monkey_home/monkey/monkey_island"
MONGO_PATH="$ISLAND_PATH/bin/mongodb"
NODE_SERVER_PATH="$ISLAND_PATH/bin/node"
ISLAND_BINARIES_PATH="$ISLAND_PATH/cc/binaries"
INFECTION_MONKEY_DIR="$monkey_home/monkey/infection_monkey"
MONKEY_BIN_DIR="$INFECTION_MONKEY_DIR/bin"
Expand Down Expand Up @@ -191,6 +192,9 @@ log_message "Generating certificate"
chmod u+x "${ISLAND_PATH}"/linux/create_certificate.sh
"${ISLAND_PATH}"/linux/create_certificate.sh ${ISLAND_PATH}/cc

# Install node server
"${ISLAND_PATH}"/linux/install_node.sh "${NODE_SERVER_PATH}" || handle_error

# Update node
if ! exists npm; then
log_message "Installing nodejs"
Expand Down Expand Up @@ -235,7 +239,7 @@ pushd "$ISLAND_PATH/cc/ui" || handle_error
npm ci

log_message "Generating front end"
npm run dev
npm run build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the current UI support a build target? We used to run dev or dist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what value the dev build had, but on the new UI we can build production or run a dev server with hot reloads. This builds production in case the dev is not intending to work on UI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me rephrase. This is generating the frontend for the old UI ("$ISLAND_PATH/cc/ui"). Does build work for it?

popd || handle_error

# Making dir for binaries
Expand Down
6 changes: 5 additions & 1 deletion deployment_scripts/deploy_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
$install_mongo_script = (Join-Path -Path $monkey_home -ChildPath "$MONKEY_ISLAND_DIR\windows\install_mongo.ps1")
Invoke-Expression "$install_mongo_script -binDir $binDir"

$install_node_script = (Join-Path -Path $monkey_home -ChildPath "$MONKEY_ISLAND_DIR\windows\install_node.ps1")
$node_server_dir = (Join-Path -Path $binDir -ChildPath "node")
Invoke-Expression "$install_node_script -destinationDir $node_server_dir"

# Download OpenSSL
Print-Status "Downloading OpenSSL ..."
$webClient.DownloadFile($OPEN_SSL_URL, $TEMP_OPEN_SSL_ZIP)
Expand Down Expand Up @@ -238,7 +242,7 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
Print-Status "Updating npm"
Push-Location -Path (Join-Path -Path $monkey_home -ChildPath $MONKEY_ISLAND_DIR | Join-Path -ChildPath "\cc\ui")
& npm update
& npm run dev
& npm run build
Pop-Location

# Create infection_monkey/bin directory if not already present
Expand Down
9 changes: 9 additions & 0 deletions docs/content/FAQ/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Below are some of the most common questions we receive about the Infection Monke
- [Downloading logs](#downloading-logs)
- [Log locations](#log-locations)
- [Monkey Island Server logs](#monkey-island-server-logs)
- [Monkey Island UI logs](#monkey-island-ui-logs)
- [Infection Monkey Agent logs](#infection-monkey-agent-logs)
- [Running the Infection Monkey in a production environment](#running-the-infection-monkey-in-a-production-environment)
- [How much of a footprint does the Infection Monkey leave?](#how-much-of-a-footprint-does-the-infection-monkey-leave)
Expand Down Expand Up @@ -198,6 +199,14 @@ It's also possible to change the default log level by editing `log_level` value
`log_level` can be set to `info`(default, less verbose) or `debug`(more verbose).


#### Monkey Island UI logs

The Monkey Island's UI log file (`nextjs.log`) is located in the
[data directory]({{< ref "/reference/data_directory" >}}).

This log contains the output of the server process hosting the web interface.


#### Infection Monkey Agent logs

The Infection Monkey Agent log file can be found in directories specified for
Expand Down
4 changes: 2 additions & 2 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Hub Logo")

## How it works

Architecturally, Infection Monkey is comprised of two components:
Architecturally, Infection Monkey comprises two components:

* Monkey Agent (Monkey for short) - a safe, worm-like binary program which
scans, propagates and simulates attack techniques on the **local network**.
Expand All @@ -34,7 +34,7 @@ Architecturally, Infection Monkey is comprised of two components:
The user can run the Monkey Agent on the Island Server machine or distribute
Monkey Agent binaries on the network manually. Based on the configuration
parameters, Monkey Agents scan, propagate and simulate an attacker's behavior
on the local network. All of the information gathered about the network is
on the local network. All the information gathered about the network is
aggregated in the Island Server and displayed once all Monkey Agents are
finished.

Expand Down
9 changes: 8 additions & 1 deletion docs/content/reference/server_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ weight: 1

## Configuring the Monkey Island

The Monkey Island Server is configured by creating a `server_config.json` file.
The Monkey Island Server is configured through the `server_config.json` file.

{{% notice info %}}
Refer to the [setup guides](../../setup/) to learn how to use
the `server_config.json` file for each deployment.
{{% /notice %}}

### Creating a configuration file

Here's an example `server_config.json` with all options specified:
```json
{
"island_port": 443,
"log_level": "DEBUG",
"ssl_certificate": {
"ssl_certificate_file": "<PATH_TO_CRT_FILE>",
Expand All @@ -41,6 +47,7 @@ Only relevant options can be specified, for example:

See setup instructions for your operating system to understand how to apply these.

- `island_port` - Port used by the Island C&C server. Default is `443`.
- `log_level` - can be set to `"DEBUG"`(verbose), `"INFO"`(less verbose) or `"ERROR"`(silent, except errors).
- `ssl_certificate` - contains paths for files, required to run the Island Server with custom certificate.
- `data_dir` - path to a writeable directory where the Island will store the database and other files.
Expand Down
7 changes: 6 additions & 1 deletion docs/content/setup/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ At this point, AWS will instance and deploy the new machine.

When ready, you can browse to the Infection Monkey running on the fresh deployment at:

`https://{public-ip}:5000`
`https://{public-ip}`

To login to the machine, use *ubuntu* username.

Once you have access to the Monkey Island server, check out the [getting started page]({{< ref "/usage/getting-started" >}}).

## Configuration

AWS EC2 instance is running the AppImage deployment of the Infection Monkey. To configure the VM, shell
into it and follow configuration instructions in the [Linux setup section]({{< ref "/setup/linux#configuring-the-server" >}}).

## Integration with AWS services

The Infection Monkey has built-in integrations with AWS that allows running Agents on EC2 instances.
Expand Down
7 changes: 6 additions & 1 deletion docs/content/setup/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ Select the [Infection Monkey from the Azure Marketplace](https://azuremarketplac
At this point, Azure will provision and deploy your new machine. When ready,
you can browse to the Infection Monkey running on your fresh deployment at:

`https://{public-ip-address}:5000`
`https://{public-ip-address}`

Once you have access to the Monkey Island server, check out the [getting started page]({{< ref "/usage/getting-started" >}}).

## Configuration

Azure VM is running the AppImage deployment of the Infection Monkey. To configure the VM, shell
into it and follow configuration instructions in the [Linux setup section]({{< ref "/setup/linux#configuring-the-server" >}}).

## Upgrading

Currently, there's no "upgrade-in-place" option when a new version is released.
Expand Down
Loading