Agent, Island: send network information in monkey wakeup telemetry

Network information is required for segmentation reports, that's why it gets sent in the wakeup telemetry. It could be joined with "ip_addresses", but that would require a bigger refactoring on the island side
This commit is contained in:
vakarisz 2022-02-28 16:13:56 +02:00 committed by VakarisZ
parent 1b484e0365
commit 1c602a3315
3 changed files with 6 additions and 9 deletions

View File

@ -13,7 +13,7 @@ import infection_monkey.tunnel as tunnel
from common.common_consts.api_url_consts import T1216_PBA_FILE_DOWNLOAD_PATH
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT
from infection_monkey.config import GUID, WormConfiguration
from infection_monkey.network.info import local_ips
from infection_monkey.network.info import get_host_subnets, local_ips
from infection_monkey.transport.http import HTTPConnectProxy
from infection_monkey.transport.tcp import TcpProxy
from infection_monkey.utils import agent_process
@ -48,6 +48,7 @@ class ControlClient(object):
"guid": GUID,
"hostname": hostname,
"ip_addresses": local_ips(),
"networks": get_host_subnets(),
"description": " ".join(platform.uname()),
"config": WormConfiguration.as_dict(),
"parent": parent,

View File

@ -42,6 +42,7 @@ class Monkey(Document):
description = StringField()
hostname = StringField()
ip_addresses = ListField(StringField())
networks = ListField()
launch_time = FloatField()
keepalive = DateTimeField()
modifytime = DateTimeField()

View File

@ -160,16 +160,11 @@ class ReportService:
@staticmethod
def get_monkey_subnets(monkey_guid):
network_info = mongo.db.telemetry.find_one(
{"telem_category": "system_info", "monkey_guid": monkey_guid},
{"data.network_info.networks": 1},
)
if network_info is None or not network_info["data"]:
return []
networks = Monkey.objects.get(guid=monkey_guid).networks
return [
ipaddress.ip_interface(str(network["addr"] + "/" + network["netmask"])).network
for network in network_info["data"]["network_info"]["networks"]
ipaddress.ip_interface(f"{network['addr']}/{network['netmask']}").network
for network in networks
]
@staticmethod