Monkey: add launch time to the monkey collection

Launch time is needed if we want to tell the user when exactly the exploit occurred/monkey got run
This commit is contained in:
VakarisZ 2021-07-26 11:20:48 +03:00
parent 52207c15b8
commit 91ca828c72
4 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# Default time format used in the application, follows European standard.
# Example: 1992-03-04 10:32:05
DEFAULT_TIME_FORMAT = "%Y-%m-%d %H:%M:%S"

View File

@ -1,6 +1,7 @@
import json
import logging
import platform
from datetime import datetime
from pprint import pformat
from socket import gethostname
from urllib.parse import urljoin
@ -11,6 +12,7 @@ from requests.exceptions import ConnectionError
import infection_monkey.monkeyfs as monkeyfs
import infection_monkey.tunnel as tunnel
from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH
from common.common_consts.time_formats import DEFAULT_TIME_FORMAT
from common.common_consts.timeouts import (
LONG_REQUEST_TIMEOUT,
MEDIUM_REQUEST_TIMEOUT,
@ -60,6 +62,7 @@ class ControlClient(object):
"internet_access": has_internet_access,
"config": WormConfiguration.as_dict(),
"parent": parent,
"launch_time": str(datetime.now().strftime(DEFAULT_TIME_FORMAT)),
}
if ControlClient.proxies:

View File

@ -40,6 +40,7 @@ class Monkey(Document):
hostname = StringField()
internet_access = BooleanField()
ip_addresses = ListField(StringField())
launch_time = StringField()
keepalive = DateTimeField()
modifytime = DateTimeField()
# TODO make "parent" an embedded document, so this can be removed and the schema explained (

View File

@ -70,6 +70,7 @@ PbaResults # unused class (monkey/monkey_island/cc/models/pba_results.py:4)
internet_access # unused variable (monkey/monkey_island/cc/models/monkey.py:43)
config_error # unused variable (monkey/monkey_island/cc/models/monkey.py:53)
pba_results # unused variable (monkey/monkey_island/cc/models/monkey.py:55)
launch_time # unused variable (monkey/monkey_island/cc/models/monkey.py)
command_control_channel # unused variable (monkey/monkey_island/cc/models/monkey.py:58)
meta # unused variable (monkey/monkey_island/cc/models/zero_trust/finding.py:37)
meta # unused variable (monkey/monkey_island/cc/models/monkey_ttl.py:34)