From 1d748640926d4f3bf32ef92f31ccb08c5c0217b6 Mon Sep 17 00:00:00 2001 From: vakaris_zilius Date: Wed, 16 Mar 2022 16:00:58 +0000 Subject: [PATCH] Island: Fix agent stopping bugs 2 bugs fixed: UI used miliseconds instead of seconds and island kept stopping monkeys, but it should only stop monkey once to not prevent more runs --- monkey/monkey_island/cc/services/infection_lifecycle.py | 7 ++++++- monkey/monkey_island/cc/ui/src/components/pages/MapPage.js | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/services/infection_lifecycle.py b/monkey/monkey_island/cc/services/infection_lifecycle.py index 871c279cc..865602168 100644 --- a/monkey/monkey_island/cc/services/infection_lifecycle.py +++ b/monkey/monkey_island/cc/services/infection_lifecycle.py @@ -29,7 +29,12 @@ def should_agent_die(guid: int) -> bool: def _should_agent_stop(monkey: Monkey) -> bool: - return monkey.config.should_stop + if monkey.config.should_stop: + # Only stop the agent once, to allow further runs on that machine + monkey.config.should_stop = False + monkey.save() + return True + return False def _is_monkey_killed_manually(monkey: Monkey) -> bool: diff --git a/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js b/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js index 3c1350f58..9b4b09f4c 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js @@ -88,10 +88,11 @@ class MapPageComponent extends AuthComponent { { method: 'POST', headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({kill_time: Date.now()}) + // Python uses seconds, Date.now uses milliseconds, so convert + body: JSON.stringify({kill_time: Date.now() / 1000}) }) .then(res => res.json()) - .then(res => {this.setState({killPressed: true}); console.log(res)}); + .then(res => {this.setState({killPressed: true})}); }; renderKillDialogModal = () => {