Linted code iwht black tool
This commit is contained in:
@@ -13,122 +13,116 @@ from logger import get_app_logger
|
||||
|
||||
class Wordlists:
|
||||
"""Loads and provides access to wordlists from wordlists.json"""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self._data = self._load_config()
|
||||
|
||||
|
||||
def _load_config(self):
|
||||
"""Load wordlists from JSON file"""
|
||||
config_path = Path(__file__).parent.parent / 'wordlists.json'
|
||||
config_path = Path(__file__).parent.parent / "wordlists.json"
|
||||
|
||||
try:
|
||||
with open(config_path, 'r') as f:
|
||||
with open(config_path, "r") as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
get_app_logger().warning(f"Wordlists file {config_path} not found, using default values")
|
||||
get_app_logger().warning(
|
||||
f"Wordlists file {config_path} not found, using default values"
|
||||
)
|
||||
return self._get_defaults()
|
||||
except json.JSONDecodeError as e:
|
||||
get_app_logger().warning(f"Invalid JSON in {config_path}: {e}")
|
||||
return self._get_defaults()
|
||||
|
||||
|
||||
def _get_defaults(self):
|
||||
"""Fallback default wordlists if JSON file is missing or invalid"""
|
||||
return {
|
||||
"usernames": {
|
||||
"prefixes": ["admin", "user", "root"],
|
||||
"suffixes": ["", "_prod", "_dev"]
|
||||
"suffixes": ["", "_prod", "_dev"],
|
||||
},
|
||||
"passwords": {
|
||||
"prefixes": ["P@ssw0rd", "Admin"],
|
||||
"simple": ["test", "demo", "password"]
|
||||
},
|
||||
"emails": {
|
||||
"domains": ["example.com", "test.com"]
|
||||
},
|
||||
"api_keys": {
|
||||
"prefixes": ["sk_live_", "api_", ""]
|
||||
"simple": ["test", "demo", "password"],
|
||||
},
|
||||
"emails": {"domains": ["example.com", "test.com"]},
|
||||
"api_keys": {"prefixes": ["sk_live_", "api_", ""]},
|
||||
"databases": {
|
||||
"names": ["production", "main_db"],
|
||||
"hosts": ["localhost", "db.internal"]
|
||||
"hosts": ["localhost", "db.internal"],
|
||||
},
|
||||
"applications": {
|
||||
"names": ["WebApp", "Dashboard"]
|
||||
},
|
||||
"users": {
|
||||
"roles": ["Administrator", "User"]
|
||||
},
|
||||
"server_headers": ["Apache/2.4.41 (Ubuntu)", "nginx/1.18.0"]
|
||||
"applications": {"names": ["WebApp", "Dashboard"]},
|
||||
"users": {"roles": ["Administrator", "User"]},
|
||||
"server_headers": ["Apache/2.4.41 (Ubuntu)", "nginx/1.18.0"],
|
||||
}
|
||||
|
||||
|
||||
@property
|
||||
def username_prefixes(self):
|
||||
return self._data.get("usernames", {}).get("prefixes", [])
|
||||
|
||||
|
||||
@property
|
||||
def username_suffixes(self):
|
||||
return self._data.get("usernames", {}).get("suffixes", [])
|
||||
|
||||
|
||||
@property
|
||||
def password_prefixes(self):
|
||||
return self._data.get("passwords", {}).get("prefixes", [])
|
||||
|
||||
|
||||
@property
|
||||
def simple_passwords(self):
|
||||
return self._data.get("passwords", {}).get("simple", [])
|
||||
|
||||
|
||||
@property
|
||||
def email_domains(self):
|
||||
return self._data.get("emails", {}).get("domains", [])
|
||||
|
||||
|
||||
@property
|
||||
def api_key_prefixes(self):
|
||||
return self._data.get("api_keys", {}).get("prefixes", [])
|
||||
|
||||
|
||||
@property
|
||||
def database_names(self):
|
||||
return self._data.get("databases", {}).get("names", [])
|
||||
|
||||
|
||||
@property
|
||||
def database_hosts(self):
|
||||
return self._data.get("databases", {}).get("hosts", [])
|
||||
|
||||
|
||||
@property
|
||||
def application_names(self):
|
||||
return self._data.get("applications", {}).get("names", [])
|
||||
|
||||
|
||||
@property
|
||||
def user_roles(self):
|
||||
return self._data.get("users", {}).get("roles", [])
|
||||
|
||||
|
||||
@property
|
||||
def directory_files(self):
|
||||
return self._data.get("directory_listing", {}).get("files", [])
|
||||
|
||||
|
||||
@property
|
||||
def directory_dirs(self):
|
||||
return self._data.get("directory_listing", {}).get("directories", [])
|
||||
|
||||
|
||||
@property
|
||||
def error_codes(self):
|
||||
return self._data.get("error_codes", [])
|
||||
|
||||
|
||||
@property
|
||||
def sql_errors(self):
|
||||
return self._data.get("sql_errors", {})
|
||||
|
||||
|
||||
@property
|
||||
def attack_patterns(self):
|
||||
return self._data.get("attack_patterns", {})
|
||||
|
||||
|
||||
@property
|
||||
def server_errors(self):
|
||||
return self._data.get("server_errors", {})
|
||||
|
||||
|
||||
@property
|
||||
def server_headers(self):
|
||||
return self._data.get("server_headers", [])
|
||||
|
||||
|
||||
@property
|
||||
def attack_urls(self):
|
||||
"""Deprecated: use attack_patterns instead. Returns attack_patterns for backward compatibility."""
|
||||
@@ -137,10 +131,10 @@ class Wordlists:
|
||||
|
||||
_wordlists_instance = None
|
||||
|
||||
|
||||
def get_wordlists():
|
||||
"""Get the singleton Wordlists instance"""
|
||||
global _wordlists_instance
|
||||
if _wordlists_instance is None:
|
||||
_wordlists_instance = Wordlists()
|
||||
return _wordlists_instance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user