|
@@ -55,6 +55,13 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
self.packets = []
|
|
self.packets = []
|
|
self.path_attack_pcap = ""
|
|
self.path_attack_pcap = ""
|
|
|
|
|
|
|
|
+ # get_reply_delay
|
|
|
|
+ self.all_min_delays = None
|
|
|
|
+ self.all_max_delays = None
|
|
|
|
+ self.most_used_mss_value = None
|
|
|
|
+ self.most_used_ttl_value = None
|
|
|
|
+ self.most_used_win_size = None
|
|
|
|
+
|
|
def set_statistics(self, statistics):
|
|
def set_statistics(self, statistics):
|
|
"""
|
|
"""
|
|
Specify the statistics object that will be used to calculate the parameters of this attack.
|
|
Specify the statistics object that will be used to calculate the parameters of this attack.
|
|
@@ -65,6 +72,13 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
"""
|
|
"""
|
|
self.statistics = statistics
|
|
self.statistics = statistics
|
|
|
|
|
|
|
|
+ # get_reply_delay
|
|
|
|
+ self.all_min_delays = self.statistics.process_db_query("SELECT minDelay FROM conv_statistics LIMIT 500;")
|
|
|
|
+ self.all_max_delays = self.statistics.process_db_query("SELECT maxDelay FROM conv_statistics LIMIT 500;")
|
|
|
|
+ self.most_used_mss_value = self.statistics.get_most_used_mss_value()
|
|
|
|
+ self.most_used_ttl_value = self.statistics.get_most_used_ttl_value()
|
|
|
|
+ self.most_used_win_size = self.statistics.get_most_used_win_size()
|
|
|
|
+
|
|
@abc.abstractmethod
|
|
@abc.abstractmethod
|
|
def init_params(self):
|
|
def init_params(self):
|
|
"""
|
|
"""
|
|
@@ -516,10 +530,8 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
min_delay = result[0][0]
|
|
min_delay = result[0][0]
|
|
max_delay = result[0][1]
|
|
max_delay = result[0][1]
|
|
else:
|
|
else:
|
|
- all_min_delays = self.statistics.process_db_query("SELECT minDelay FROM conv_statistics LIMIT 500;")
|
|
|
|
- min_delay = np.median(all_min_delays)
|
|
|
|
- all_max_delays = self.statistics.process_db_query("SELECT maxDelay FROM conv_statistics LIMIT 500;")
|
|
|
|
- max_delay = np.median(all_max_delays)
|
|
|
|
|
|
+ min_delay = np.median(self.all_min_delays)
|
|
|
|
+ max_delay = np.median(self.all_max_delays)
|
|
|
|
|
|
if math.isnan(min_delay): # max_delay is nan too then
|
|
if math.isnan(min_delay): # max_delay is nan too then
|
|
if default < 0:
|
|
if default < 0:
|
|
@@ -682,7 +694,7 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
mss_prob_dict = lea.Lea.fromValFreqsDict(mss_dist)
|
|
mss_prob_dict = lea.Lea.fromValFreqsDict(mss_dist)
|
|
mss_value = mss_prob_dict.random()
|
|
mss_value = mss_prob_dict.random()
|
|
else:
|
|
else:
|
|
- mss_value = Util.handle_most_used_outputs(self.statistics.process_db_query("most_used(mssValue)"))
|
|
|
|
|
|
+ mss_value = Util.handle_most_used_outputs(self.most_used_mss_value)
|
|
|
|
|
|
# Set TTL based on TTL distribution of IP address
|
|
# Set TTL based on TTL distribution of IP address
|
|
ttl_dist = self.statistics.get_ttl_distribution(ip_address)
|
|
ttl_dist = self.statistics.get_ttl_distribution(ip_address)
|
|
@@ -690,7 +702,7 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
ttl_prob_dict = lea.Lea.fromValFreqsDict(ttl_dist)
|
|
ttl_prob_dict = lea.Lea.fromValFreqsDict(ttl_dist)
|
|
ttl_value = ttl_prob_dict.random()
|
|
ttl_value = ttl_prob_dict.random()
|
|
else:
|
|
else:
|
|
- ttl_value = Util.handle_most_used_outputs(self.statistics.process_db_query("most_used(ttlValue)"))
|
|
|
|
|
|
+ ttl_value = Util.handle_most_used_outputs(self.most_used_ttl_value)
|
|
|
|
|
|
# Set Window Size based on Window Size distribution of IP address
|
|
# Set Window Size based on Window Size distribution of IP address
|
|
win_dist = self.statistics.get_win_distribution(ip_address)
|
|
win_dist = self.statistics.get_win_distribution(ip_address)
|
|
@@ -698,7 +710,7 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
win_prob_dict = lea.Lea.fromValFreqsDict(win_dist)
|
|
win_prob_dict = lea.Lea.fromValFreqsDict(win_dist)
|
|
win_value = win_prob_dict.random()
|
|
win_value = win_prob_dict.random()
|
|
else:
|
|
else:
|
|
- win_value = Util.handle_most_used_outputs(self.statistics.process_db_query("most_used(winSize)"))
|
|
|
|
|
|
+ win_value = Util.handle_most_used_outputs(self.most_used_win_size)
|
|
|
|
|
|
return mss_value, ttl_value, win_value
|
|
return mss_value, ttl_value, win_value
|
|
|
|
|