-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreporter.py
38 lines (30 loc) · 1.15 KB
/
reporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import logging
import json
import csv
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class Reporter:
def __init__(self, vulnerable_domains):
self.vulnerable_domains = vulnerable_domains
def report(self, output_file="vulnerable_domains.txt"):
output_format = output_file.split(".")[-1]
if output_format == "json":
self.report_json(output_file)
elif output_format == "csv":
self.report_csv(output_file)
else:
self.report_txt(output_file)
logger.info("Vulnerabilities reported.")
def report_json(self, output_file):
with open(output_file, "w") as f:
json.dump(list(self.vulnerable_domains), f, indent=4)
def report_csv(self, output_file):
with open(output_file, "w") as f:
writer = csv.writer(f)
writer.writerow(["Domain"])
for domain in self.vulnerable_domains:
writer.writerow([domain])
def report_txt(self, output_file):
with open(output_file, "w") as f:
for domain in self.vulnerable_domains:
f.write(f"{domain}\n")