|
@@ -472,8 +472,6 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
context.add_other_created_file(new_xml_path)
|
|
|
return new_xml_path
|
|
|
|
|
|
- # print a line break to have follwing status messages on a new line
|
|
|
- print()
|
|
|
|
|
|
# parse input CSV or XML
|
|
|
filepath_xml = self.get_param_value(Param.FILE_XML)
|
|
@@ -484,26 +482,30 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
|
|
|
# only use CSV input if the XML path is the default one
|
|
|
# --> prefer XML input over CSV input (in case both are given)
|
|
|
+ print_updates = False
|
|
|
if filepath_csv and filepath_xml == self.DEFAULT_XML_PATH:
|
|
|
filename = os.path.splitext(filepath_csv)[0]
|
|
|
filesize = os.path.getsize(filepath_csv) / 2**20 # get filesize in MB
|
|
|
if filesize > 10:
|
|
|
- print("Parsing input CSV file...", end=" ")
|
|
|
+ print("\nParsing input CSV file...", end=" ")
|
|
|
sys.stdout.flush()
|
|
|
+ print_updates = True
|
|
|
cpp_comm_proc.parse_csv(filepath_csv)
|
|
|
- print("done.")
|
|
|
- print("Writing corresponding XML file...", end=" ")
|
|
|
- sys.stdout.flush()
|
|
|
+ if print_updates:
|
|
|
+ print("done.")
|
|
|
+ print("Writing corresponding XML file...", end=" ")
|
|
|
+ sys.stdout.flush()
|
|
|
filepath_xml = cpp_comm_proc.write_xml(filename)
|
|
|
filepath_xml = move_xml_to_outdir(filepath_xml)
|
|
|
- print("done.")
|
|
|
+ if print_updates: print("done.")
|
|
|
else:
|
|
|
filesize = os.path.getsize(filepath_xml) / 2**20 # get filesize in MB
|
|
|
if filesize > 10:
|
|
|
print("Parsing input XML file...", end=" ")
|
|
|
sys.stdout.flush()
|
|
|
+ print_updates = True
|
|
|
cpp_comm_proc.parse_xml(filepath_xml)
|
|
|
- print("done.")
|
|
|
+ if print_updates: print("done.")
|
|
|
|
|
|
|
|
|
# find a good communication mapping in the input file that matches the users parameters
|
|
@@ -515,19 +517,23 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
start_idx = self.get_param_value(Param.INTERVAL_SELECT_START)
|
|
|
end_idx = self.get_param_value(Param.INTERVAL_SELECT_END)
|
|
|
|
|
|
- print("Selecting communication interval from input CSV/XML file...", end=" ")
|
|
|
- sys.stdout.flush()
|
|
|
- if strategy == "optimal" and filesize > 4 and self.statistics.get_packet_count() > 1000:
|
|
|
- print("\nWarning: Because of the large input files and the (chosen) interval selection strategy 'optimal',")
|
|
|
- print("this may take a while. Consider using selection strategy 'random' or 'custom'...", end=" ")
|
|
|
+ potential_long_find_time = (strategy == "optimal" and (filesize > 4 and self.statistics.get_packet_count() > 1000))
|
|
|
+ if print_updates or potential_long_find_time:
|
|
|
+ if not print_updates: print()
|
|
|
+ print("Selecting communication interval from input CSV/XML file...", end=" ")
|
|
|
sys.stdout.flush()
|
|
|
+ if potential_long_find_time:
|
|
|
+ print("\nWarning: Because of the large input files and the (chosen) interval selection strategy 'optimal',")
|
|
|
+ print("this may take a while. Consider using selection strategy 'random' or 'custom'...", end=" ")
|
|
|
+ sys.stdout.flush()
|
|
|
+ print_updates = True
|
|
|
|
|
|
comm_interval = comm_proc.get_comm_interval(cpp_comm_proc, strategy, number_init_bots, duration, start_idx, end_idx)
|
|
|
|
|
|
if not comm_interval:
|
|
|
print("Error: An interval that satisfies the input cannot be found.")
|
|
|
return []
|
|
|
- print("done.") # print corresponding message to interval finding message
|
|
|
+ if print_updates: print("done.") # print corresponding message to interval finding message
|
|
|
|
|
|
# retrieve the mapping information
|
|
|
mapped_ids, packet_start_idx, packet_end_idx = comm_interval["IDs"], comm_interval["Start"], comm_interval["End"]
|
|
@@ -536,7 +542,7 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
|
|
|
rm_idx = randrange(0, len(mapped_ids))
|
|
|
del mapped_ids[rm_idx]
|
|
|
|
|
|
- print("Generating attack packets...", end=" ")
|
|
|
+ if print_updates: print("Generating attack packets...", end=" ")
|
|
|
sys.stdout.flush()
|
|
|
# get the messages contained in the chosen interval
|
|
|
abstract_packets = cpp_comm_proc.get_messages(packet_start_idx, packet_end_idx);
|