Fixed "is monkey running on island" check by splitting port from ip string
This commit is contained in:
parent
507bf43b9b
commit
c817415ef3
|
@ -33,6 +33,7 @@ from infection_monkey.telemetry.attack.t1106_telem import T1106Telem
|
|||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||
from common.version import get_version
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from monkey_island.cc.network_utils import remove_port_from_ip_string
|
||||
|
||||
MAX_DEPTH_REACHED_MESSAGE = "Reached max depth, shutting down"
|
||||
|
||||
|
@ -384,4 +385,5 @@ class InfectionMonkey(object):
|
|||
LOG.debug("default server set to: %s" % self._default_server)
|
||||
|
||||
def is_started_on_island(self):
|
||||
return is_running_on_server(self._default_server) and WormConfiguration.depth == WormConfiguration.max_depth
|
||||
island_ip = remove_port_from_ip_string(self._default_server)
|
||||
return is_running_on_server(island_ip) and WormConfiguration.depth == WormConfiguration.max_depth
|
||||
|
|
|
@ -5,7 +5,7 @@ import socket
|
|||
import struct
|
||||
import sys
|
||||
from typing import List
|
||||
import collections
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from netifaces import interfaces, ifaddresses, AF_INET
|
||||
from ring import lru
|
||||
|
@ -86,3 +86,8 @@ def get_subnets():
|
|||
]
|
||||
)
|
||||
return subnets
|
||||
|
||||
|
||||
def remove_port_from_ip_string(ip_string: str) -> str:
|
||||
url = urlparse("http://" + ip_string)
|
||||
return str(url.hostname)
|
||||
|
|
Loading…
Reference in New Issue