|
@@ -9,7 +9,7 @@ from definitions import ROOT_DIR
|
|
|
from Attack import BaseAttack
|
|
|
from Attack.AttackParameters import Parameter as Param
|
|
|
from Attack.AttackParameters import ParameterTypes
|
|
|
-from ID2TLib.Utility import update_timestamp, get_interval_pps
|
|
|
+from ID2TLib.Utility import update_timestamp, get_interval_pps, handle_most_used_outputs
|
|
|
from ID2TLib.SMBLib import smb_port
|
|
|
|
|
|
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
|
|
@@ -58,9 +58,9 @@ class EternalBlueExploit(BaseAttack.BaseAttack):
|
|
|
# (values are overwritten if user specifies them)
|
|
|
# Attacker configuration
|
|
|
most_used_ip_address = self.statistics.get_most_used_ip_address()
|
|
|
- if isinstance(most_used_ip_address, list):
|
|
|
- most_used_ip_address = most_used_ip_address[0]
|
|
|
random_ip_address = self.statistics.get_random_ip_address()
|
|
|
+ while random_ip_address == most_used_ip_address:
|
|
|
+ random_ip_address = self.statistics.get_random_ip_address()
|
|
|
self.add_param_value(Param.IP_SOURCE, random_ip_address)
|
|
|
self.add_param_value(Param.MAC_SOURCE, self.statistics.get_mac_address(random_ip_address))
|
|
|
self.add_param_value(Param.PORT_SOURCE, randint(self.minDefaultPort, self.maxDefaultPort))
|
|
@@ -109,14 +109,14 @@ class EternalBlueExploit(BaseAttack.BaseAttack):
|
|
|
source_ttl_prob_dict = Lea.fromValFreqsDict(source_ttl_dist)
|
|
|
source_ttl_value = source_ttl_prob_dict.random()
|
|
|
else:
|
|
|
- source_ttl_value = self.statistics.process_db_query("most_used(ttlValue)")
|
|
|
+ source_ttl_value = handle_most_used_outputs(self.statistics.process_db_query("most_used(ttlValue)"))
|
|
|
|
|
|
destination_ttl_dist = self.statistics.get_ttl_distribution(ip_destination)
|
|
|
if len(destination_ttl_dist) > 0:
|
|
|
destination_ttl_prob_dict = Lea.fromValFreqsDict(destination_ttl_dist)
|
|
|
destination_ttl_value = destination_ttl_prob_dict.random()
|
|
|
else:
|
|
|
- destination_ttl_value = self.statistics.process_db_query("most_used(ttlValue)")
|
|
|
+ destination_ttl_value = handle_most_used_outputs(self.statistics.process_db_query("most_used(ttlValue)"))
|
|
|
|
|
|
# Set Window Size based on Window Size distribution of IP address
|
|
|
source_win_dist = self.statistics.get_win_distribution(ip_source)
|
|
@@ -134,7 +134,7 @@ class EternalBlueExploit(BaseAttack.BaseAttack):
|
|
|
destination_win_prob_dict = Lea.fromValFreqsDict(destination_win_dist)
|
|
|
|
|
|
# Set MSS (Maximum Segment Size) based on MSS distribution of IP address
|
|
|
- mss_value = self.statistics.process_db_query("most_used(mssValue)")
|
|
|
+ mss_value = handle_most_used_outputs(self.statistics.process_db_query("most_used(mssValue)"))
|
|
|
if not mss_value:
|
|
|
mss_value = 1465
|
|
|
|