Initial pcap handling code.
This commit is contained in:
parent
fff377afd0
commit
c38d283cfa
1 changed files with 20 additions and 0 deletions
|
@ -31,6 +31,26 @@ def analyze_pcap(pcapng_path, start_ts, end_ts):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
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:
|
with open(args.csv, newline='') as infile, open(args.output, 'w', newline='', encoding='utf-8') as outfile:
|
||||||
reader = csv.DictReader(infile)
|
reader = csv.DictReader(infile)
|
||||||
fieldnames = reader.fieldnames + [
|
fieldnames = reader.fieldnames + [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue