Skip to content

Instantly share code, notes, and snippets.

@joswr1ght
Created April 14, 2022 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joswr1ght/ed3f2673907e203baff324d090290116 to your computer and use it in GitHub Desktop.
Save joswr1ght/ed3f2673907e203baff324d090290116 to your computer and use it in GitHub Desktop.
Read Nessus CSV report, extract records of interest
#!/usr/bin/env python3
import csv
import sys
import os
if (len(sys.argv) == 1):
sys.stderr.write(
f"Usage: {os.path.basename(sys.argv[0])} <nessus-csv-file>\n")
sys.exit(1)
records = []
with open(sys.argv[1]) as csv_file, \
open('extract.csv', 'w') as out_file:
csv_reader = csv.reader(csv_file, delimiter=',')
csv_writer = csv.writer(out_file)
reccount = 0
for row in csv_reader:
if reccount == 0:
csv_writer.writerow(row)
reccount += 1
continue
# Row 7 is the issue Name field, ignore unapplicable or out-of-scope
# things
if ("PCI" in row[7] or "SWEET32" in row[7] or "Logjam" in row[7]
or "CGI Generic" in row[7] or "TLS Version 1.0" in row[7]
or "Linux Kernel TCP Sequence Number" in row[7]
or "HSTS Missing" in row[7]
or "SSRF" in row[7]):
continue
# Skip informational or uncategorized entries
if (row[3] not in ["High", "Medium", "Low"]):
continue
records.append(row)
csv_writer.writerow(row)
reccount += 1
print(f"Wrote {reccount} records. Summary:")
for rec in records:
print(f"{rec[15]} -> [{rec[3]}] {rec[7]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment