From 6dbac85256493576081f7c3674dc3e3c1984718f Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Wed, 14 Jul 2021 15:00:21 +0200 Subject: [PATCH 1/3] ui: Hide scoutsuite run options in ransomware mode --- .../pages/RunMonkeyPage/RunOptions.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js index db8ca17f6..5fe6444d7 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js @@ -11,6 +11,7 @@ import AWSRunButton from './RunOnAWS/AWSRunButton'; import CloudOptions from './scoutsuite-setup/CloudOptions'; const CONFIG_URL = '/api/configuration/island'; +const MODE_URL = '/api/island-mode' function RunOptions(props) { @@ -56,6 +57,23 @@ function RunOptions(props) { return InlineSelection(defaultContents, newProps); } + function getIslandMode() { + let mode = ''; + authComponent.authFetch(MODE_URL) + .then(res => res.json()) + .then(res => { + mode = res.mode + } + ); + + if (mode === 'ransomware') { + return false; + } + else { + return true; + } + } + function defaultContents() { return ( <> @@ -69,14 +87,15 @@ function RunOptions(props) { setComponent(LocalManualRunOptions, {ips: ips, setComponent: setComponent}) }}/> - - } + {getIslandMode() && { setComponent(CloudOptions, {ips: ips, setComponent: setComponent}) }}/> + } ); } From f725efd41aa21e598c271968990c54d71ed4fc33 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Wed, 14 Jul 2021 16:30:41 +0200 Subject: [PATCH 2/3] ui: Refactor scoutsuite hiding functions --- .../components/pages/RunMonkeyPage/RunOptions.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js index 5fe6444d7..f38c48990 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js @@ -58,20 +58,18 @@ function RunOptions(props) { } function getIslandMode() { - let mode = ''; + let mode = 'advanced'; authComponent.authFetch(MODE_URL) .then(res => res.json()) .then(res => { mode = res.mode } ); + return mode; + } - if (mode === 'ransomware') { - return false; - } - else { - return true; - } + function shouldShowScoutsuite(){ + return getIslandMode() === 'advanced'; } function defaultContents() { @@ -87,8 +85,8 @@ function RunOptions(props) { setComponent(LocalManualRunOptions, {ips: ips, setComponent: setComponent}) }}/> - {getIslandMode() && } - {getIslandMode() && } + {shouldShowScoutsuite() && { From a78642865221161f3c7456ae6376de5bf6580084 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 14 Jul 2021 12:52:24 -0400 Subject: [PATCH 3/3] Island: Pass island mode as a prop from Main.js to child components --- .../cc/ui/src/components/Main.js | 15 ++++++++++++- .../pages/RunMonkeyPage/RunMonkeyPage.js | 2 +- .../pages/RunMonkeyPage/RunOptions.js | 22 +++++-------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/Main.js b/monkey/monkey_island/cc/ui/src/components/Main.js index dc1e063ff..c068b9caf 100644 --- a/monkey/monkey_island/cc/ui/src/components/Main.js +++ b/monkey/monkey_island/cc/ui/src/components/Main.js @@ -27,6 +27,7 @@ import {StandardLayoutComponent} from './layouts/StandardLayoutComponent'; import LoadingScreen from './ui-components/LoadingScreen'; const reportZeroTrustRoute = '/report/zeroTrust'; +const islandModeRoute = '/api/island-mode' class AppComponent extends AuthComponent { updateStatus = () => { @@ -113,15 +114,26 @@ class AppComponent extends AuthComponent { infection_done: false, report_done: false, isLoggedIn: undefined, - needsRegistration: undefined + needsRegistration: undefined, + islandMode: undefined }, noAuthLoginAttempted: undefined }; } + updateIslandMode() { + this.authFetch(islandModeRoute) + .then(res => res.json()) + .then(res => { + this.setState({islandMode: res.mode}) + } + ); + } + componentDidMount() { this.updateStatus(); this.interval = setInterval(this.updateStatus, 10000); + this.updateIslandMode() } componentWillUnmount() { @@ -147,6 +159,7 @@ class AppComponent extends AuthComponent { completedSteps={this.state.completedSteps}/>)} {this.renderRoute('/run-monkey', )} {this.renderRoute('/infection/map', diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunMonkeyPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunMonkeyPage.js index 2a27c5be3..b87c118f9 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunMonkeyPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunMonkeyPage.js @@ -17,7 +17,7 @@ class RunMonkeyPageComponent extends AuthComponent { Go ahead and run the monkey! (Or configure the monkey to fine tune its behavior)

- + ); } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js index f38c48990..1cc2aed7b 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js @@ -11,7 +11,6 @@ import AWSRunButton from './RunOnAWS/AWSRunButton'; import CloudOptions from './scoutsuite-setup/CloudOptions'; const CONFIG_URL = '/api/configuration/island'; -const MODE_URL = '/api/island-mode' function RunOptions(props) { @@ -57,22 +56,11 @@ function RunOptions(props) { return InlineSelection(defaultContents, newProps); } - function getIslandMode() { - let mode = 'advanced'; - authComponent.authFetch(MODE_URL) - .then(res => res.json()) - .then(res => { - mode = res.mode - } - ); - return mode; + function shouldShowScoutsuite(islandMode){ + return islandMode !== 'ransomware'; } - function shouldShowScoutsuite(){ - return getIslandMode() === 'advanced'; - } - - function defaultContents() { + function defaultContents(props) { return ( <> - {shouldShowScoutsuite() && } - {shouldShowScoutsuite() && } + {shouldShowScoutsuite(props.islandMode) && {