From 3b7d35868aef6640ead4bf78799bb30cf29142ad Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 12 Jul 2021 16:41:20 +0530 Subject: [PATCH 1/6] cc: Show exploitation stats on ransomware report page --- .../report-components/RansomwareReport.js | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 86ba1ebf4..8d7e76c0c 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -14,17 +14,56 @@ class RansomwareReport extends React.Component {

This report shows information about the ransomware simulation run by Infection Monkey.

+ {this.getExploitationStats()} ) } + getExploitationStats() { + let num_scanned = this.props.report.propagation_stats.num_scanned_nodes; + let num_exploited = this.props.report.propagation_stats.num_exploited_nodes; + let exploit_counts = this.props.report.propagation_stats.num_exploited_per_exploit; + + let exploitation_details = []; + for (let exploit in exploit_counts) { + let count = exploit_counts[exploit]; + if (count === 1) { + exploitation_details.push( +
+ {count} machine was exploited by + the {exploit}. +
+ ) + } + else { + exploitation_details.push( +
+ {count} machines were exploited by + the {exploit}. +
+ ) + } + } + + return ( +
+

+ The Monkey discovered {num_scanned} machines + and successfully breached {num_exploited} of them. +

+ {exploitation_details} +
+ ) + } + render() { let content = {}; if (this.stillLoadingDataFromServer()) { content = ; } else { - content =
{this.generateReportContent()}
; + content = this.generateReportContent(); } + return (
From c8e010498514da1adee4cdebdf7f1d65da42f424 Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 12 Jul 2021 16:47:32 +0530 Subject: [PATCH 2/6] cc: Extract ransomware report's exploitation stats component to a separate function --- .../report-components/RansomwareReport.js | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 8d7e76c0c..1f5f9b0d7 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -22,9 +22,23 @@ class RansomwareReport extends React.Component { getExploitationStats() { let num_scanned = this.props.report.propagation_stats.num_scanned_nodes; let num_exploited = this.props.report.propagation_stats.num_exploited_nodes; + + return ( +
+

+ The Monkey discovered {num_scanned} machines + and successfully breached {num_exploited} of them. +

+ {this.getExploitationStatsPerExploit()} +
+ ) + } + + getExploitationStatsPerExploit() { let exploit_counts = this.props.report.propagation_stats.num_exploited_per_exploit; let exploitation_details = []; + for (let exploit in exploit_counts) { let count = exploit_counts[exploit]; if (count === 1) { @@ -33,7 +47,7 @@ class RansomwareReport extends React.Component { {count} machine was exploited by the {exploit}.
- ) + ); } else { exploitation_details.push( @@ -41,19 +55,11 @@ class RansomwareReport extends React.Component { {count} machines were exploited by the {exploit}. - ) + ); } } - return ( -
-

- The Monkey discovered {num_scanned} machines - and successfully breached {num_exploited} of them. -

- {exploitation_details} -
- ) + return exploitation_details; } render() { From 50c24c77f4099c8807dd0ea157a76de8c7386f43 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 12 Jul 2021 09:25:41 -0400 Subject: [PATCH 3/6] Island: Use Pluralize to display ransomware propagation stats --- .../report-components/RansomwareReport.js | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 1f5f9b0d7..52ca82c42 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -2,6 +2,7 @@ import React from 'react'; import ReportHeader, {ReportTypes} from './common/ReportHeader'; import ReportLoader from './common/ReportLoader'; +import pluralize from 'pluralize' class RansomwareReport extends React.Component { stillLoadingDataFromServer() { @@ -41,22 +42,13 @@ class RansomwareReport extends React.Component { for (let exploit in exploit_counts) { let count = exploit_counts[exploit]; - if (count === 1) { - exploitation_details.push( -
- {count} machine was exploited by - the {exploit}. -
- ); - } - else { - exploitation_details.push( -
- {count} machines were exploited by - the {exploit}. -
- ); - } + exploitation_details.push( +
+ {count}  + {pluralize('machine', count)} {pluralize('was', count)} exploited by the  + {exploit}. +
+ ); } return exploitation_details; From 644a90c2f34d70fe085814d1177592bc655ab85c Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 12 Jul 2021 09:31:28 -0400 Subject: [PATCH 4/6] Island: Add "Propagation" header to ransomware report --- .../cc/ui/src/components/report-components/RansomwareReport.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 52ca82c42..55f513961 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -26,6 +26,9 @@ class RansomwareReport extends React.Component { return (
+

+ Propagation +

The Monkey discovered {num_scanned} machines and successfully breached {num_exploited} of them. From 6fdf0858ac01e06e403377ed5c9d5f6e3325544b Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 12 Jul 2021 09:32:01 -0400 Subject: [PATCH 5/6] Island: Remove superfluous description from ransomware report --- .../src/components/report-components/RansomwareReport.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 55f513961..07a6ceb15 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -11,12 +11,9 @@ class RansomwareReport extends React.Component { generateReportContent() { return ( -

-

- This report shows information about the ransomware simulation run by Infection Monkey. -

- {this.getExploitationStats()} -
+
+ {this.getExploitationStats()} +
) } From ced3c3b137c9c2cca3963133969394aab291bad0 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 12 Jul 2021 12:41:42 -0400 Subject: [PATCH 6/6] Island: Extract getScannedVsExploitedStats() method --- .../report-components/RansomwareReport.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js index 07a6ceb15..bb24dcaa1 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/RansomwareReport.js @@ -18,23 +18,29 @@ class RansomwareReport extends React.Component { } getExploitationStats() { - let num_scanned = this.props.report.propagation_stats.num_scanned_nodes; - let num_exploited = this.props.report.propagation_stats.num_exploited_nodes; - return (

Propagation

-

- The Monkey discovered {num_scanned} machines - and successfully breached {num_exploited} of them. -

+ {this.getScannedVsExploitedStats()} {this.getExploitationStatsPerExploit()}
) } + getScannedVsExploitedStats() { + let num_scanned = this.props.report.propagation_stats.num_scanned_nodes; + let num_exploited = this.props.report.propagation_stats.num_exploited_nodes; + + return( +

+ The Monkey discovered {num_scanned} machines + and successfully breached {num_exploited} of them. +

+ ) + } + getExploitationStatsPerExploit() { let exploit_counts = this.props.report.propagation_stats.num_exploited_per_exploit;