@@ -212,6 +212,7 @@ def main(
212
212
username ,
213
213
password ,
214
214
device_ip ,
215
+ source_host ,
215
216
pcap_file_path ,
216
217
output_json_name = None ,
217
218
):
@@ -232,7 +233,6 @@ def main(
232
233
)
233
234
234
235
operator = Operator (KlapTransportV2 (config = fake_device ), creds )
235
-
236
236
packets = []
237
237
238
238
# pyshark is a little weird in how it handles iteration,
@@ -241,6 +241,8 @@ def main(
241
241
try :
242
242
packet = capture .next ()
243
243
packet_number = capture ._current_packet
244
+ if packet .ip .src != source_host :
245
+ continue
244
246
# we only care about http packets
245
247
if hasattr (
246
248
packet , "http"
@@ -325,6 +327,11 @@ def main(
325
327
required = True ,
326
328
help = "the IP of the smart device as it appears in the pcap file." ,
327
329
)
330
+ @click .option (
331
+ "--source-host" ,
332
+ required = True ,
333
+ help = "the IP of the device communicating with the smart device." ,
334
+ )
328
335
@click .option (
329
336
"--username" ,
330
337
required = True ,
@@ -348,14 +355,14 @@ def main(
348
355
required = False ,
349
356
help = "The name of the output file, relative to the current directory." ,
350
357
)
351
- async def cli (username , password , host , pcap_file_path , output ):
358
+ async def cli (username , password , host , source_host , pcap_file_path , output ):
352
359
"""Export KLAP data in JSON format from a PCAP file."""
353
360
# pyshark does not work within a running event loop and we don't want to
354
361
# install click as well as asyncclick so run in a new thread.
355
362
loop = asyncio .new_event_loop ()
356
363
thread = Thread (
357
364
target = main ,
358
- args = [loop , username , password , host , pcap_file_path , output ],
365
+ args = [loop , username , password , host , source_host , pcap_file_path , output ],
359
366
daemon = True ,
360
367
)
361
368
thread .start ()
0 commit comments