Browse Source

add debug mode

which does not delete the temporary pcap
Jens Keim 6 years ago
parent
commit
beeee8e5af
2 changed files with 14 additions and 7 deletions
  1. 4 2
      code/CLI.py
  2. 10 5
      code/Core/Controller.py

+ 4 - 2
code/CLI.py

@@ -72,7 +72,8 @@ class CLI(object):
         parser.add_argument('-V', '--non-verbose', help='reduces terminal clutter', action='store_true', default=False)
         parser.add_argument('-o', '--output', metavar="PCAP_FILE", help='path to the output pcap file')
         parser.add_argument('-ie', '--inject_empty', action='store_true',
-                                       help='injects ATTACK into an EMPTY PCAP file, using the statistics of the input PCAP.')
+                            help='injects ATTACK into an EMPTY PCAP file, using the statistics of the input PCAP.')
+        parser.add_argument('-d', '--debug', help='Runs ID2T in debug mode.', action='store_true', default=False)
 
         # Attack arguments
         parser.add_argument('-a', '--attack', metavar="ATTACK", action='append',
@@ -144,7 +145,8 @@ class CLI(object):
         Evaluates given queries.
         """
         # Create Core Controller
-        controller = Controller(self.args.input, self.args.extraTests, self.args.non_verbose, self.args.output)
+        controller = Controller(self.args.input, self.args.extraTests, self.args.non_verbose, self.args.output,
+                                self.args.debug)
 
         # Load PCAP statistics
         controller.load_pcap_statistics(self.args.export, self.args.recalculate, self.args.statistics)

+ 10 - 5
code/Core/Controller.py

@@ -15,7 +15,8 @@ import Core.StatsDatabase as StatsDB
 
 
 class Controller:
-    def __init__(self, pcap_file_path: str, do_extra_tests: bool, non_verbose: bool=True, pcap_out_path: str=None):
+    def __init__(self, pcap_file_path: str, do_extra_tests: bool, non_verbose: bool=True, pcap_out_path: str=None,
+                 debug: bool=False):
         """
         Creates a new Controller, acting as a central coordinator for the whole application.
 
@@ -31,6 +32,7 @@ class Controller:
         self.seed = None
         self.durations = []
         self.added_packets = 0
+        self.debug = debug
 
         # Initialize class instances
         print("Input file: %s" % self.pcap_src_path)
@@ -149,10 +151,13 @@ class Controller:
             print("done.")
 
             # delete intermediate PCAP files
-            print('Deleting intermediate attack pcap...', end=" ")
-            sys.stdout.flush()  # force python to print text immediately
-            os.remove(attacks_pcap_path)
-            print("done.")
+            if self.debug:
+                print('NOT deleting intermediate attack pcap while in debug mode.')
+            else:
+                print('Deleting intermediate attack pcap...', end=" ")
+                sys.stdout.flush()  # force python to print text immediately
+                os.remove(attacks_pcap_path)
+                print("done.")
 
             # write label file with attacks
             self.label_manager.write_label_file(self.pcap_dest_path)