Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Parse John
- # Developed by Hans-Michael Varbaek
- # VarBITS
- # Version 1.0
- """
- SAMPLE INPUT FILE:
- SAMPLEP (domain.com\jdoe:1)
- BIKINIB (domain.com\ssquarepants:1)
- RANDOMP (domain.com\rrandomuser:1)
- OTTOM12 (domain.com\ssquarepants:2)
- ASSWORD (domain.com\jdoe:2)
- ASSWORD (domain.com\rrandomuser:2)
- Note: Delete lines that do not look like the above before running this program/script.
- """
- input_filepointer = open("john.txt", "r")
- output_dict = {}
- output_filename = "john_parsed.txt"
- # Clear the file and write a header
- with open(output_filename, "w") as filename:
- output = "username,domain,password\n" # Use \r\n for Windows
- filename.write(output)
- for line in input_filepointer:
- line = line.strip()
- newline = line.split('\t\t\t') # Three "tabs" are assumed here, change this
- password = newline[0] # SAMPLEP
- domain_and_user = newline[1].replace("(", "").replace(")", "").split("\\") # ["domain.com", "jdoe:1"]
- domain = domain_and_user[0] # domain.com
- user = domain_and_user[1].split(':')[0] # jdoe
- sequence = domain_and_user[1].split(':')[1] # 1 or 2
- if sequence == "1":
- output_dict[user] = {"password": password, "domain": domain}
- else:
- output_dict[user]["password"] += password
- for user in output_dict:
- with open(output_filename, "a") as filename:
- output = "{},{},{}\n".format(user, output_dict[user]["domain"], output_dict[user]["password"])
- # Use \r\n for Windows
- filename.write(output)
- """
- SAMPLE OUTPUT:
- username,domain,password
- ssquarepants,domain.com,BIKINIBOTTOM12
- rrandomuser,domain.com,RANDOMPASSWORD
- jdoe,domain.com,SAMPLEPASSWORD
- You can load this in Excel or OpenOffice for example if you have a lot of entries.
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement