Open McWally13 opened 1 week ago
Well, using the code in the standard way, there really isn't much chance of the real password being found. To find the correct login, a good idea would be to use more advanced wordlists, such as rockyou.txt (one of or the largest of them) as a file for both users and passwords (or any other way you want) or any other larger wordlist that is on the internet.
But another problem is that using these large wordlists would take a long time to test all the combinations, a really long time, you can reduce the code's sleep time to try to reduce this time or create your own python code to make your own wordlist (especially if you already have some idea of what the router's password might be).
A simple code example to create your wordlist:
import itertools
import string
import multiprocessing
from multiprocessing import Pool
import time
def get_characters(char_type):
if char_type == 'letters':
return string.ascii_letters
elif char_type == 'numbers':
return string.digits
elif char_type == 'symbols':
return string.punctuation
elif char_type == 'letters_numbers':
return string.ascii_letters + string.digits
elif char_type == 'letters_symbols':
return string.ascii_letters + string.punctuation
elif char_type == 'numbers_symbols':
return string.digits + string.punctuation
elif char_type == 'all':
return string.ascii_letters + string.digits + string.punctuation
else:
raise ValueError("Invalid character type. Choose from 'letters', 'numbers', 'symbols', 'letters_numbers', 'letters_symbols', 'numbers_symbols', or 'all'.")
def generate_combinations_segment(length, start, end):
characters = get_characters(character_type)
combinations = itertools.product(characters, repeat=length)
# Skip to the correct combination
for _ in range(start):
next(combinations)
# Generate combinations in range
for _ in range(end - start):
yield next(combinations)
def save_combinations_segment(length, start, end, filename):
combinations = generate_combinations_segment(length, start, end)
with open(filename, 'a') as file:
for combination in combinations:
file.write(''.join(combination) + '\n')
def divide_work(length, total_processes):
characters = get_characters(character_type)
total_combinations = len(characters) ** length
combinations_per_segment = total_combinations // total_processes
return [(length, i * combinations_per_segment, (i + 1) * combinations_per_segment)
for i in range(total_processes)]
if __name__ == "__main__":
length = int(input("Enter the length of combinations: "))
character_type = input("Enter character type (letters, numbers, symbols, letters_numbers, letters_symbols, numbers_symbols, all): ").strip().lower()
output_file = "combinations.txt"
total_processes = int(input("Enter the number of processes to use: "))
# Make sure the file is empty before starting
open(output_file, 'w').close()
# Measure execution time
start_time = time.time()
# Divide work between processes
tasks = divide_work(length, total_processes)
with Pool(processes=total_processes) as pool:
pool.starmap(save_combinations_segment,
[(length, start, end, output_file)
for length, start, end in tasks])
end_time = time.time()
total_time = end_time - start_time
print(f"Combinations saved to {output_file}")
print(f"Total execution time: {total_time:.2f} seconds")
Another idea could also be to add some logic to the project codes to save the logins that have already been tested and failed, so that it does not repeat this same attempt the next time the code is run, I'll have to take a look at that.
Well, that's what I thought, I'll try to add this logic for saving failed attempts in my fork.
Quick question, ig this only works for routers that still have their default password right? No chance of working with changed passwords?
Still thanks for ur work.