import itertools import string # Target password to guess target_password = "dog" # Characters to use in brute-force charset = string.ascii_lowercase # 'abcdefghijklmnopqrstuvwxyz' # Maximum length of password to try max_length = 4 def brute_force(target): for length in range(1, max_length + 1): for attempt in itertools.product(charset, repeat=length): guess = ''.join(attempt) print(f"Trying: {guess}") if guess == target: print(f"Password found: {guess}") return guess print("Password not found.") return None brute_force(target_password)