Agent: Use consistent DISPLAY_NAME constant in fingerprinters

This commit is contained in:
Mike Salvatore 2022-02-10 07:15:03 -05:00
parent aadc055f74
commit 98a2f0b887
4 changed files with 9 additions and 5 deletions

View File

@ -13,6 +13,7 @@ from infection_monkey.i_puppet import (
PortStatus, PortStatus,
) )
DISPLAY_NAME = "ElasticSearch"
ES_PORT = 9200 ES_PORT = 9200
ES_HTTP_TIMEOUT = 5 ES_HTTP_TIMEOUT = 5
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -54,7 +55,7 @@ def _query_elasticsearch(host: str) -> Dict[str, Any]:
def _get_service_from_query_info(elasticsearch_info: Dict[str, Any]) -> Dict[str, Any]: def _get_service_from_query_info(elasticsearch_info: Dict[str, Any]) -> Dict[str, Any]:
try: try:
return { return {
"display_name": "ElasticSearch", "display_name": DISPLAY_NAME,
"port": ES_PORT, "port": ES_PORT,
"cluster_name": elasticsearch_info["cluster_name"], "cluster_name": elasticsearch_info["cluster_name"],
"name": elasticsearch_info["name"], "name": elasticsearch_info["name"],

View File

@ -15,6 +15,8 @@ from infection_monkey.i_puppet import (
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
DISPLAY_NAME = "HTTP"
class HTTPFingerprinter(IFingerprinter): class HTTPFingerprinter(IFingerprinter):
""" """
@ -38,7 +40,7 @@ class HTTPFingerprinter(IFingerprinter):
if server_header_contents is not None: if server_header_contents is not None:
services[f"tcp-{port}"] = { services[f"tcp-{port}"] = {
"display_name": "HTTP", "display_name": DISPLAY_NAME,
"port": port, "port": port,
"name": "http", "name": "http",
"data": (server_header_contents, ssl), "data": (server_header_contents, ssl),

View File

@ -6,6 +6,7 @@ from typing import Any, Dict, Optional
from infection_monkey.i_puppet import FingerprintData, IFingerprinter, PingScanData, PortScanData from infection_monkey.i_puppet import FingerprintData, IFingerprinter, PingScanData, PortScanData
MSSQL_SERVICE = "MSSQL" MSSQL_SERVICE = "MSSQL"
DISPLAY_NAME = MSSQL_SERVICE
SQL_BROWSER_DEFAULT_PORT = 1434 SQL_BROWSER_DEFAULT_PORT = 1434
_BUFFER_SIZE = 4096 _BUFFER_SIZE = 4096
_MSSQL_SOCKET_TIMEOUT = 5 _MSSQL_SOCKET_TIMEOUT = 5
@ -78,7 +79,7 @@ def _query_mssql_for_instance_data(host: str) -> Optional[bytes]:
def _get_services_from_server_data(data: bytes) -> Dict[str, Any]: def _get_services_from_server_data(data: bytes) -> Dict[str, Any]:
services = {MSSQL_SERVICE: {}} services = {MSSQL_SERVICE: {}}
services[MSSQL_SERVICE]["display_name"] = MSSQL_SERVICE services[MSSQL_SERVICE]["display_name"] = DISPLAY_NAME
services[MSSQL_SERVICE]["port"] = SQL_BROWSER_DEFAULT_PORT services[MSSQL_SERVICE]["port"] = SQL_BROWSER_DEFAULT_PORT
# Loop through the server data # Loop through the server data

View File

@ -13,7 +13,7 @@ from infection_monkey.i_puppet import (
PortStatus, PortStatus,
) )
SMB_DISPLAY_NAME = "SMB" DISPLAY_NAME = "SMB"
SMB_PORT = 445 SMB_PORT = 445
SMB_SERVICE = "tcp-445" SMB_SERVICE = "tcp-445"
@ -145,7 +145,7 @@ class SMBFingerprinter(IFingerprinter):
) -> FingerprintData: ) -> FingerprintData:
services = {} services = {}
smb_service = { smb_service = {
"display_name": SMB_DISPLAY_NAME, "display_name": DISPLAY_NAME,
"port": SMB_PORT, "port": SMB_PORT,
} }
os_type = None os_type = None