Untitled
import sys import re def hex_decode(match): hex_string = match.group(1) try: # Decode the hex string return bytes.fromhex(hex_string).decode('utf-8') except ValueError: # Return the original string if decoding fails return match.group(0) def decode_hex_data(data): # Regex to find all $HEX[...] patterns hex_pattern = re.compile(r'\$HEX\[(.*?)\]') return hex_pattern.sub(hex_decode, data) def read_combolists(file_paths): passwords = set() for file_path in file_paths: try: with open(file_path, 'r') as file: for line in file: if ':' in line: parts = line.strip().split(':', 1) password = decode_hex_data(parts[1]) passwords.add(password) except FileNotFoundError: print(f"File not found: {file_path}") except Exception as e: print(f"Error processing file {file_path}: {e}") return passwords def write_passwords_to_file(passwords, output_file): with open(output_file, 'w') as file: for password in passwords: file.write(password + '\n') # Main execution if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: python script.py file1.txt file2.txt ...") else: file_paths = sys.argv[1:] passwords = read_combolists(file_paths) output_file = 'unique_passwords.txt' write_passwords_to_file(passwords, output_file) print(f"Unique passwords extracted to '{output_file}'")
Leave a Comment