Dehashed-API Cleanup
This file takes a dehashed-API output file and cleans it up to have an output of username:password
in a case-insensitive, de-duped list:
import os
import datetime
# Prompt user for input file
input_file = input("Enter the name of the input file (e.g., companycreds.txt): ").strip()
# Check if the file exists
if not os.path.isfile(input_file):
print(f"Error: File '{input_file}' not found.")
exit()
# Generate a timestamped output file name
timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H%M')
base_name, ext = os.path.splitext(input_file)
output_file = f"{base_name}_{timestamp}-clean{ext}"
# Read the file and process lines
with open(input_file, 'r') as file:
lines = file.readlines()
# Extract email and password, and store in a dictionary to handle deduplication
entries = {}
for line in lines:
parts = line.split(',')
email_part = parts[0].split('email:')[-1].strip()
password_part = parts[1].split('password:')[-1].strip()
entries[email_part] = password_part
# Sort the dictionary by email (case-insensitive)
sorted_entries = sorted(entries.items(), key=lambda x: x[0].lower())
# Write the sorted entries to the output file
with open(output_file, 'w') as file:
for email, password in sorted_entries:
file.write(f'{email}:{password}\n')
print(f"Processed entries saved to {output_file}.")