Make monkey always try to ping the remote machine.

This catches more events for the cross segment analyser
This commit is contained in:
Daniel Goldberg 2018-09-12 19:32:01 +03:00
parent 2ada581672
commit f4669bf3f5
2 changed files with 8 additions and 8 deletions

View File

@ -129,8 +129,7 @@ class InfectionMonkey(object):
if not self._keep_running or not WormConfiguration.alive: if not self._keep_running or not WormConfiguration.alive:
break break
machines = self._network.get_victim_machines(WormConfiguration.scanner_class, machines = self._network.get_victim_machines(max_find=WormConfiguration.victims_max_find,
max_find=WormConfiguration.victims_max_find,
stop_callback=ControlClient.check_for_stop) stop_callback=ControlClient.check_for_stop)
is_empty = True is_empty = True
for machine in machines: for machine in machines:

View File

@ -6,7 +6,7 @@ from infection_monkey.config import WormConfiguration
from infection_monkey.network.info import local_ips, get_interfaces_ranges from infection_monkey.network.info import local_ips, get_interfaces_ranges
from infection_monkey.model import VictimHost from infection_monkey.model import VictimHost
from infection_monkey.network import HostScanner from infection_monkey.network import HostScanner
from infection_monkey.network import TcpScanner, PingScanner
__author__ = 'itamar' __author__ = 'itamar'
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -62,7 +62,7 @@ class NetworkScanner(object):
return subnets_to_scan return subnets_to_scan
def get_victim_machines(self, scan_type, max_find=5, stop_callback=None): def get_victim_machines(self, max_find=5, stop_callback=None):
""" """
Finds machines according to the ranges specified in the object Finds machines according to the ranges specified in the object
:param scan_type: A hostscanner class, will be instanced and used to scan for new machines :param scan_type: A hostscanner class, will be instanced and used to scan for new machines
@ -70,10 +70,9 @@ class NetworkScanner(object):
:param stop_callback: A callback to check at any point if we should stop scanning :param stop_callback: A callback to check at any point if we should stop scanning
:return: yields a sequence of VictimHost instances :return: yields a sequence of VictimHost instances
""" """
if not scan_type:
return
scanner = scan_type() TCPscan = TcpScanner()
Pinger = PingScanner()
victims_count = 0 victims_count = 0
for net_range in self._ranges: for net_range in self._ranges:
@ -94,9 +93,11 @@ class NetworkScanner(object):
continue continue
LOG.debug("Scanning %r...", victim) LOG.debug("Scanning %r...", victim)
pingAlive = Pinger.is_host_alive(victim)
tcpAlive = TCPscan.is_host_alive(victim)
# if scanner detect machine is up, add it to victims list # if scanner detect machine is up, add it to victims list
if scanner.is_host_alive(victim): if pingAlive or tcpAlive:
LOG.debug("Found potential victim: %r", victim) LOG.debug("Found potential victim: %r", victim)
victims_count += 1 victims_count += 1
yield victim yield victim