-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from punk-security/add-js-include-takovers
Allow multiple files on ingest
- Loading branch information
Showing
6 changed files
with
69 additions
and
16 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
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
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 |
---|---|---|
@@ -1,6 +1,31 @@ | ||
from os import linesep | ||
|
||
|
||
class Finding(object): | ||
def __init__(self, domain, signature, info, confidence): | ||
self.domain = domain | ||
def __init__( | ||
self, | ||
domain, | ||
signature, | ||
info, | ||
confidence, | ||
): | ||
self.domain = domain.domain | ||
self.signature = signature | ||
self.info = info.replace("\n", " ").replace("\r", "").rstrip() | ||
self.confidence = confidence.name | ||
self.a_records = domain.A | ||
self.aaaa_records = domain.AAAA | ||
self.cname_records = domain.CNAME | ||
self.ns_records = domain.NS | ||
|
||
def populated_records(self): | ||
resp = "" | ||
if self.a_records: | ||
resp += f"A: {self.a_records}," | ||
if self.aaaa_records: | ||
resp += f"AAAA: {self.aaaa_records}," | ||
if self.cname_records: | ||
resp += f"CNAME: {self.cname_records}," | ||
if self.ns_records: | ||
resp += f"NS: {self.ns_records}," | ||
return resp.rstrip(",") |
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
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 |
---|---|---|
@@ -1,14 +1,40 @@ | ||
import logging | ||
from domain import Domain | ||
from os import listdir | ||
from os.path import isfile, join | ||
|
||
description = "Read domains from a file, one per line" | ||
description = "Read domains from a file (or folder of files), one per line" | ||
|
||
|
||
def fetch_domains(filename, **args): | ||
with open(filename) as file: | ||
try: | ||
lines = file.readlines() | ||
logging.warn(f"Ingested {len(lines)} domains from file '{filename}'") | ||
except Exception as e: | ||
logging.error(f"Could not read any domains from file {filename} -- {e}") | ||
return [Domain(line.rstrip()) for line in lines] | ||
if isfile(filename): | ||
with open(filename) as file: | ||
try: | ||
domains = file.readlines() | ||
logging.warn(f"Ingested {len(domains)} domains from file '{filename}'") | ||
except Exception as e: | ||
logging.error(f"Could not read any domains from file {filename} -- {e}") | ||
exit(-1) | ||
else: | ||
domains = [] | ||
files = fetch_nested_files(filename) | ||
for f in files: | ||
try: | ||
with open(f) as file: | ||
domains += file.readlines() | ||
logging.debug(f"Ingested domains from file '{file}'") | ||
except: | ||
logging.debug(f"Could not read file '{file}'") | ||
logging.warn(f"Ingested {len(domains)} domains from folder '{filename}'") | ||
return [Domain(domain.rstrip()) for domain in domains] | ||
|
||
|
||
def fetch_nested_files(dir): | ||
files = [] | ||
for item in listdir(dir): | ||
path = join(dir, item) | ||
if isfile(path): | ||
files.append(path) | ||
else: | ||
files = [*files, *fetch_nested_files(path)] | ||
return files |
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