-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aureum01 <[email protected]>
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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") |