1313import time
1414from multiprocessing import Pool
1515
16- from analyzers import hosts , conversations
1716import pcap
1817
1918NUM_THREADS = 4
2019
21- ANALYZERS = [
22- hosts ,
23- conversations
24- ]
25-
2620ASCII_LOGO = """
2721
2822@@@@@@@ @@@@@@@ @@@@@@ @@@@@@@ @@@@@@ @@@@@@@ @@@@@@ @@@ @@@
3832
3933"""
4034
35+
4136class Main :
4237
43- def __init__ (self , outputdir , inputdir , parser ):
38+ def __init__ (self , outputdir , inputdir ):
4439
4540 # log files
4641 self .outputdir = outputdir
@@ -59,12 +54,6 @@ def __init__(self, outputdir, inputdir, parser):
5954 )
6055 self .inputdir = inputdir
6156
62- # initialize all analyzers
63- for a in ANALYZERS :
64- a .init ()
65-
66- self .parser = parser
67-
6857 def _log_errors (self ):
6958 if not self .ignoredFiles :
7059 return
@@ -75,12 +64,9 @@ def _log_errors(self):
7564
7665 print ("ignored {} files" .format (len (self .ignoredFiles )))
7766
78- def _log_results (self ):
79- for a in ANALYZERS :
80- a .log (self .outputdir )
8167
8268 def start (self ):
83- pcapfiles = pcap .walk (self .inputdir )
69+ pcapfiles = pcap .walk (self .inputdir )[: 3 ]
8470 print (
8571 "Collected list of {} files in {}" .
8672 format (len (pcapfiles ), self .inputdir )
@@ -98,7 +84,7 @@ def start(self):
9884 # asynchronously
9985 pool .apply_async (
10086 pcap .process_pcap ,
101- (fn , [ a . analyze for a in ANALYZERS ], progressbar_position , self . parser )
87+ (fn , progressbar_position )
10288 )
10389
10490 # close pool
@@ -108,7 +94,6 @@ def start(self):
10894 pool .join ()
10995
11096 self ._log_errors ()
111- self ._log_results ()
11297
11398 # return number of pcap files
11499 return len (pcapfiles )
@@ -128,20 +113,13 @@ def start(self):
128113 default = '.' ,
129114 help = 'path to the output directory'
130115 )
131- parser .add_argument (
132- '-p' , '--parser' ,
133- nargs = '?' ,
134- default = pcap .Parser .DPKT .name ,
135- choices = [p .name for p in pcap .Parser ]
136- )
137116
138117 args = parser .parse_args ()
139118 print (ASCII_LOGO )
140119
141120 scanner = Main (
142121 outputdir = args .outputdir ,
143- inputdir = args .inputdir ,
144- parser = args .parser
122+ inputdir = args .inputdir
145123 )
146124 # measure time
147125 startTime = time .time ()
0 commit comments