Initial pcap handling code.

This commit is contained in:
Yaro Kasear 2025-04-10 15:06:03 -05:00
parent fff377afd0
commit c38d283cfa

View file

@ -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 + [