From c38d283cfada3eae4d32b278e9b473629d969675 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 10 Apr 2025 15:06:03 -0500 Subject: [PATCH] Initial pcap handling code. --- kismet_enrich_from_pcap.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kismet_enrich_from_pcap.py b/kismet_enrich_from_pcap.py index 1d6bf35..cd042f6 100644 --- a/kismet_enrich_from_pcap.py +++ b/kismet_enrich_from_pcap.py @@ -31,6 +31,26 @@ def analyze_pcap(pcapng_path, start_ts, end_ts): def main(): args = parse_args() + cap = pyshark.FileCapture( + args.pcapng, + use_json=True, + include_raw=False, + keep_packets=False + ) + + # Checking if the pcapng file is valid + count = 0 + try: + for packet in cap: + count += 1 + if count > 0: + break + except Exception as e: + print(f"[!] Error reading pcapng file: {e}") + return + finally: + cap.close() + with open(args.csv, newline='') as infile, open(args.output, 'w', newline='', encoding='utf-8') as outfile: reader = csv.DictReader(infile) fieldnames = reader.fieldnames + [