Skip to content

Commit 84e4615

Browse files
author
Cosmin Bianu
committed
Translated print messages to English
1 parent 2ef3edc commit 84e4615

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

AttackerCalc.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def __init__(self, pcap=None, list_of_packets=None, policy='first_ip', window_si
99
self.filter = filter_ip
1010
self.number_of_ip = number_of_ip
1111
self.list_of_packets = list_of_packets
12-
assert self.get_number_of_ip() == 1, "La classe non e' ancora implementata per riconoscere piu' attacanti"
13-
assert self.get_window_size() > 0, "Dimensioni della finestra non valide"
12+
assert self.get_number_of_ip() == 1, "Multiple attackers are not supported (yet)"
13+
assert self.get_window_size() > 0, "Invalid window size (it must be >=1)"
1414

1515
def compute_attacker(self):
1616
policy = self.get_policy()
@@ -19,18 +19,18 @@ def compute_attacker(self):
1919
elif(policy == "max_in_window"):
2020
ip = self.max_in_window_policy()
2121
else:
22-
print("Selezionare una policy.")
22+
print("Please select a policy.")
2323
return ip
2424

2525
def first_ip_policy(self):
26-
assert self.list_of_packets is not None or self.pcap is not None, "Assegnare un pcap o una lista di pacchetti"
27-
print("\n" + "Calcolo attaccante" + "\n")
26+
assert self.list_of_packets is not None or self.pcap is not None, "No PCAP or packets list has been provided"
27+
print("\n" + "Processing attacker information" + "\n")
2828
if(self.get_list_of_packets() is not None):
2929
pkts = self.get_list_of_packets()
3030
elif(self.get_pcap() is not None):
3131
pkts = rdpcap(self.get_pcap())
3232
else:
33-
print("Assegnare un pcap o una lista di pacchetti.")
33+
print("No PCAP or packets list has been provided.")
3434
return []
3535
ip_list = []
3636
for i in range(0, len(pkts) - 1):
@@ -45,14 +45,14 @@ def first_ip_policy(self):
4545
return ip_list
4646

4747
def max_in_window_policy(self):
48-
assert self.list_of_packets is not None or self.pcap is not None, "Assegnare un pcap o una lista di pacchetti"
49-
print("\n" + "Calcolo attaccante" + "\n")
48+
assert self.list_of_packets is not None or self.pcap is not None, "No PCAP or packets list has been provided"
49+
print("\n" + "Processing attacker information" + "\n")
5050
if(self.get_list_of_packets() is not None):
5151
pkts = self.get_list_of_packets()
5252
elif(self.get_pcap() is not None):
5353
pkts = rdpcap(self.get_pcap())
5454
else:
55-
print("Assegnare un pcap o una lista di pacchetti.")
55+
print("No PCAP or packets list has been provided.")
5656
return []
5757
ip_dict = {}
5858
if(len(pkts) >= self.get_window_size()):
@@ -71,7 +71,7 @@ def max_in_window_policy(self):
7171
else:
7272
pass
7373
else:
74-
print("Fornita una finestra troppo piccola.")
74+
print("Window size is too small")
7575
return []
7676

7777
def find_max_between_IP(ip_dict):
@@ -103,7 +103,7 @@ def get_filter(self):
103103
return self.filter
104104

105105
def add_ip_to_filter(self, list_of_ip):
106-
assert isinstance(list_of_ip, list), "Inserire gli ip in una lista."
106+
assert isinstance(list_of_ip, list), "IPs must be added to the filter in the form of a list"
107107
for ip in list_of_ip:
108108
self.filter.append(ip)
109109

CreateFeaturesHandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class CreateFeaturesHandler():
99

1010
def __init__(self, pkts_window_size=10, single_csv=True):
1111
self.pkts_window_size = pkts_window_size
12-
assert self.pkts_window_size >=1, "Valore per la finestra non valido"
12+
assert self.pkts_window_size >=1, "Invalid window size (it must be >=1)"
1313
self.single_csv = single_csv
14-
assert (self.single_csv is True) or (self.single_csv is False), "Valore non valido per il flag single_csv"
14+
assert (self.single_csv is True) or (self.single_csv is False), "Invalid value for the single_csv option (it must be a boolean)"
1515
self.featuresCalc = FeaturesCalc(flow_type="malware", min_window_size=pkts_window_size)
1616
ip_to_ignore = ["127.0.0.1"]
1717
self.filter_1 = PacketFilter(ip_whitelist_filter=[], ip_blacklist_filter=ip_to_ignore, TCP=True)
@@ -84,7 +84,7 @@ def legitimate_features():
8484
csv.add_row(self.featuresCalc.get_features_name())
8585
array_of_pkts = []
8686
filter_res = []
87-
print("\nCalcolo features di " + pcap + "\n")
87+
print("\nComputing features for " + pcap + "\n")
8888
pkts = rdpcap(pcap)
8989
for pkt in pkts:
9090
for filter in self.filters:

FeaturesCalc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class FeaturesCalc():
99
def __init__(self, flow_type, min_window_size=2):
1010
self.flow_type = flow_type
1111
self.min_window_size = int(min_window_size)
12-
assert self.flow_type == "malware" or self.flow_type == "legitimate", "Flow_type non valido. Valori validi sono malware o legitimate."
13-
assert self.min_window_size > 0, "Valore non valido per min_windows_size. Deve essere maggiore di 0."
12+
assert self.flow_type == "malware" or self.flow_type == "legitimate", "flow_type is invalid (must be either 'malware' or 'legitimate')"
13+
assert self.min_window_size > 0, "Invalid min_windows_size (it must be >=0)."
1414
self.label = None
1515
if(self.flow_type == "malware"):
1616
self.label = self.malware_label
@@ -88,7 +88,7 @@ def DNS_over_TCP_ratio(packets_list):
8888
else:
8989
total_packet_high_level_list.append(0.0)
9090
else:
91-
print("Errore imprevisto in dnsOverTCPRatio()")
91+
print("Unexpected error in dnsOverTCPRatio()")
9292
total_packet_high_level = float(sum(total_packet_high_level_list))
9393
if (total_packet_high_level != 0):
9494
ratio_list.append(float(total_DNS / total_packet_high_level))
@@ -266,7 +266,7 @@ def compute_tcp_flags(packets_list):
266266
return (syn_counter, fin_counter, ack_counter, psh_counter, urg_counter, rst_counter)
267267

268268
if(len(packets_list) < self.get_min_window_size()):
269-
print("\nNumero di paccheti troppo basso\n")
269+
print("\nPacket count in list is smaller than the minimum window size\n")
270270
return None
271271
else:
272272
syn_lst, fin_lst, ack_lst, psh_lst, urg_lst, rst_lst = compute_tcp_flags(packets_list)
@@ -323,7 +323,7 @@ def get_min_window_size(self):
323323
return self.min_window_size
324324

325325
def set_flow_type(self, flow_type):
326-
assert self.flow_type == "malware" or self.flow_type == "legitimate", "Flow_type non valido. Valori validi sono malware o legitimate."
326+
assert self.flow_type == "malware" or self.flow_type == "legitimate", "flow_type is invalid (must be either 'malware' or 'legitimate')"
327327
self.flow_type = flow_type
328328
if(self.flow_type == "malware"):
329329
self.label = self.malware_label

0 commit comments

Comments
 (0)