SecLists/Passwords/Default-Credentials
g0tmi1k e9337bebcf
Merge pull request #999 from ItsIgnacioPortal/RouterCredentials
feat(passwords): Added router default users and passwords

Source: https://portforward.com/

```
import os
from bs4 import BeautifulSoup

invalidValues = ["none", "N/A", "blank", "user created", "password changes when reset", "none; created during initial setup", "PrintedOnRouterLabel", "provided by ISP"]
invalidKeywords = ["none", "leave blank", "n/a", "blank", "found by", "found on", "printed on", "configured during", "create", "last", "located", "on ", "sticker on", "refer to"]

def extract_credentials(file_path):
	with open(file_path, 'r') as file:
		content = file.read()
		soup = BeautifulSoup(content, 'html.parser')
		table = soup.find('table')
		if table:
			model = table.find('th').text.strip().lower().replace('model', '').strip().replace(' ', '-').replace('/', '-')
			usernames = set()
			passwords = set()
			for row in table.find_all('tr')[1:]:
				cols = row.find_all('td')
				username = cols[1].text.strip()
				password = cols[2].text.strip()

				if username not in invalidValues:
					addUsername = True
					tempusername = username.lower()

					for keyword in invalidKeywords:
						if tempusername.startswith(keyword):
							addUsername=False
							break

					if addUsername:
						usernames.add(username)

				if password not in invalidValues:
					addPassword = True
					temppassword = password.lower()
					for keyword in invalidKeywords:
						if temppassword.startswith(keyword):
							addPassword=False
							break

					if addPassword:
						passwords.add(password)

			return model, sorted(usernames), sorted(passwords)
		else:
			return None, None, None

def save_credentials(model, usernames, passwords, output_dir):
	if model and usernames and passwords:
		user_file_path = os.path.join(output_dir, f'{model}_default-users.txt')
		pass_file_path = os.path.join(output_dir, f'{model}_default-passwords.txt')
		with open(user_file_path, 'w') as user_file:
			user_file.write('\n'.join(usernames))
		with open(pass_file_path, 'w') as pass_file:
			pass_file.write('\n'.join(passwords))

def process_files(input_dir, output_dir):
	for file_name in os.listdir(input_dir):
		print(f'Processing file {file_name}')
		file_path = os.path.join(input_dir, file_name)
		model, usernames, passwords = extract_credentials(file_path)
		save_credentials(model, usernames, passwords, output_dir)

# Input directory containing the text files
input_dir = "C:\\Users\\User\\Desktop\\out\\portforward.com"
# Output directory where the output files will be saved
output_dir = "C:\\Users\\User\\Github\\SecLists\\Passwords\\Default-Credentials\\Routers"
process_files(input_dir, output_dir)
```
2024-04-05 15:26:08 +01:00
..
2024-04-05 04:03:05 -03:00
2021-07-16 22:01:51 +02:00
2019-08-23 15:57:08 +02:00