Agent: Add 'source' field when creating TCPScanEvent in TCP scanner

This commit is contained in:
Shreya Malviya 2022-09-30 13:47:31 +05:30
parent 35d3038bc8
commit bab4ebc2bc
1 changed files with 2 additions and 1 deletions

View File

@ -11,6 +11,7 @@ from common.types import PortStatus
from common.utils import Timer from common.utils import Timer
from infection_monkey.i_puppet import PortScanData from infection_monkey.i_puppet import PortScanData
from infection_monkey.network.tools import BANNER_READ, DEFAULT_TIMEOUT, tcp_port_to_service from infection_monkey.network.tools import BANNER_READ, DEFAULT_TIMEOUT, tcp_port_to_service
from infection_monkey.utils.ids import get_agent_id
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -46,7 +47,7 @@ def _generate_tcp_scan_event(host: str, port_scan_data: Dict[int, PortScanData])
for port, data in port_scan_data.items(): for port, data in port_scan_data.items():
port_statuses[port] = data.status port_statuses[port] = data.status
return TCPScanEvent(target=host, ports=port_statuses) return TCPScanEvent(source=get_agent_id(), target=host, ports=port_statuses)
def _build_port_scan_data( def _build_port_scan_data(