-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new-signature-nucleitemplates_wix-takeover.yml
- Loading branch information
Showing
86 changed files
with
18,989 additions
and
599 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 +1,19 @@ | ||
from .lib.baddns import BadDNS_cname | ||
import os | ||
import importlib | ||
from pathlib import Path | ||
from .base import BadDNS_base | ||
|
||
module_dir = Path(__file__).parent / "modules" | ||
module_files = list(os.listdir(module_dir)) | ||
modules_loaded = {} | ||
for file in module_files: | ||
file = module_dir / file | ||
if file.is_file() and file.suffix.lower() == ".py" and file.stem not in ["base", "__init__"]: | ||
modules = importlib.import_module(f"baddns.modules.{file.stem}") | ||
for m in modules.__dict__.keys(): | ||
module = getattr(modules, m) | ||
try: | ||
if BadDNS_base in module.__bases__: | ||
modules_loaded[file.stem] = module | ||
except AttributeError: | ||
continue |
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,68 @@ | ||
import os | ||
import yaml | ||
import logging | ||
import pkg_resources | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
from .lib.signature import BadDNSSignature | ||
from .lib.errors import BadDNSSignatureException | ||
|
||
|
||
class BadDNS_base: | ||
def __init__( | ||
self, | ||
target, | ||
http_client_class=None, | ||
dns_client=None, | ||
signatures_dir=None, | ||
custom_nameservers=None, | ||
cli=False, | ||
**kwargs, | ||
): | ||
self.http_client_class = http_client_class | ||
self.dns_client = dns_client | ||
self.target = target | ||
self.signatures_dir = signatures_dir | ||
self.signatures = [] | ||
self.load_signatures(signatures_dir) | ||
self.custom_nameservers = custom_nameservers | ||
self.parent_class = kwargs.get("parent_class", "self") | ||
self.cli = cli | ||
|
||
def infomsg(self, msg): | ||
if self.cli: | ||
log.info(msg) | ||
else: | ||
log.debug(msg) | ||
|
||
def load_signatures(self, signatures_dir=None): | ||
if signatures_dir: | ||
if not os.path.exists(signatures_dir): | ||
raise BadDNSSignatureException(f"Signatures directory [{signatures_dir}] does not exist") | ||
else: | ||
signatures_dir = pkg_resources.resource_filename("baddns", "signatures") | ||
|
||
log.debug(f"attempting to load signatures from: {signatures_dir}") | ||
|
||
for filename in os.listdir(signatures_dir): | ||
if filename.endswith(".yml"): | ||
file_path = os.path.join(signatures_dir, filename) | ||
|
||
# Open each file and load the YAML contents | ||
try: | ||
with open(file_path, "r") as file: | ||
signature_data = yaml.safe_load(file) | ||
signature = BadDNSSignature() | ||
signature.initialize(**signature_data) | ||
self.signatures.append(signature) | ||
except BadDNSSignatureException as e: | ||
log.error(f"Error loading signature from {filename}: {e}") | ||
if len(self.signatures) == 0: | ||
raise BadDNSSignatureException(f"No signatures were successfuly loaded from [{signatures_dir}]") | ||
else: | ||
log.debug(f"Loaded [{str(len(self.signatures))}] signatures from [{signatures_dir}]") | ||
|
||
|
||
def get_all_modules(*args, **kwargs): | ||
return [m for m in BadDNS_base.__subclasses__()] |
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
Oops, something went wrong.