def bruteforce(input_file, wordlist_file, parallel=False): print('** Bruteforce Backup Password **') magic, length = get_header(input_file) if magic == MAGIC_ENCRYPTED: print("RouterOS Encrypted Backup") print("Length:", length, "bytes") salt = get_salt(input_file) print("Salt (hex):", salt.hex()) magic_check = get_magic_check(input_file) print("Magic Check (hex):", magic_check.hex()) if parallel: print("Parallel brute forcing...") from multiprocessing import Pool, Manager from functools import partial global counter global found counter = 0 found = False namespace = Manager().Namespace() namespace.found = found namespace.password = None Pool().map(partial(brute, namespace, salt, magic_check), wordlist_file) found = namespace.found password = namespace.password else: print("Brute forcing...") found = False for password in wordlist_file: cipher = setup_cipher(salt, password.strip()) if check_password(cipher, magic_check): found = True break if found: print("Password found:", password) else: print("Password NOT found") elif magic == MAGIC_PLAINTEXT: print("RouterOS Plaintext Backup") print("No decryption needed!") else: print("Invalid file!") print("Cannot decrypt!") input_file.close() wordlist_file.close()