@@ -87,7 +87,7 @@ def _process_packet(session: Session, packet: Packet, must_inspect_strings: bool
8787 logger .info (session , "Credit card '{}' found: '{}'" .format (credit_card .name , credit_card .number ))
8888
8989
90- def _process_packets_from (packets_input : Capture , manager : SessionsManager , must_inspect_strings : bool ):
90+ def _process_packets_from (packets_input : Capture , manager : SessionsManager , must_inspect_strings : bool = False ):
9191 """
9292 Loops over available packets, retrieves its session and handles potential exceptions.
9393
@@ -131,7 +131,8 @@ def _process_packets_from(packets_input: Capture, manager: SessionsManager, must
131131 clean_before_exit ()
132132
133133
134- def process_pcap (filename : str , must_inspect_strings = False , tshark_filter = None , debug = False , decode_as = None ) -> SessionsManager :
134+ def process_pcap (filename : str , must_inspect_strings = False , tshark_filter = None , debug = False ,
135+ decode_as = None , creds_found_callback = None ) -> SessionsManager :
135136 """
136137 Initialize the processing of a pcap file and retrieve results of the analysis.
137138 This is one of the main entry points most people will want to use.
@@ -154,6 +155,9 @@ def process_pcap(filename: str, must_inspect_strings=False, tshark_filter=None,
154155 decode_as : Dict[str, str]
155156 Associate a protocol to a port so that tshark processes packets correctly.
156157
158+ creds_found_callback : Callable[[Credentials], None]
159+ The function to call every time new credentials are found. Credentials are passed as parameter.
160+
157161 Returns
158162 -------
159163 A `SessionsManager` instance which gives to ability to the user of that function to retrieve
@@ -162,6 +166,7 @@ def process_pcap(filename: str, must_inspect_strings=False, tshark_filter=None,
162166
163167 logger .DEBUG_MODE = debug
164168 sessions_manager = SessionsManager ()
169+ Session .creds_found_callback = creds_found_callback
165170
166171 with pyshark .FileCapture (filename , display_filter = tshark_filter , decode_as = decode_as , debug = debug ) as pcap :
167172 logger .info ("Processing packets in '{}'" .format (filename ))
@@ -184,7 +189,8 @@ def process_pcap(filename: str, must_inspect_strings=False, tshark_filter=None,
184189 return sessions_manager
185190
186191
187- def active_processing (interface : str , must_inspect_strings = False , tshark_filter = None , debug = False , decode_as = None , pcap_output = None ):
192+ def active_processing (interface : str , must_inspect_strings = False , tshark_filter = None , debug = False , decode_as = None ,
193+ pcap_output = None , creds_found_callback = None ):
188194 """
189195 Initialize packets capturing on a given interface file.
190196 This is one of the main entry points most people will want to use.
@@ -209,11 +215,15 @@ def active_processing(interface: str, must_inspect_strings=False, tshark_filter=
209215
210216 pcap_output : str
211217 Captured packets will be output to that file path.
218+
219+ creds_found_callback : Callable[[Credentials], None]
220+ The function to call every time new credentials are found. Credentials are passed as parameter.
212221 """
213222
214223 logger .DEBUG_MODE = debug
215224
216225 sessions = SessionsManager (remove_outdated = True )
226+ Session .creds_found_callback = creds_found_callback
217227
218228 signal .signal (signal .SIGINT , signal_handler )
219229
0 commit comments