Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-----------------------------------------------------
- # Wordlist Adjustment
- #
- # Description:
- # Removes items from a wordlist
- # Currently set to remove anything less than 8 characters to make the wordlist useful for WPA
- #
- # Usage:
- # python wordlist.py file
- #
- # Parameters:
- # File - the name of the wordlist
- #
- # History:
- # Date Author Description
- # 2021-12-02 A. Walker Initial Creation
- # 2021-12-07 A. Walker Fixed Header (usage)
- #-----------------------------------------------------
- import sys, re
- filename = sys.argv[1]
- file = open(filename, 'r')
- name_search = re.search(r"(^.+)\.(.*)", filename)
- old_file_name = name_search.group(1)
- file_format = name_search.group(2)
- new_file_name = old_file_name + "_new" + "." + file_format
- new_file = open(new_file_name, 'a')
- total_records = 0
- moved_records = 0
- try:
- for line in file:
- total_records += 1
- match = re.search(r"(^.{8,25}$)", line)
- if match:
- moved_records += 1
- new_file.write(match.group(1))
- new_file.write("\n")
- else:
- pass
- except (UnicodeDecodeError, UnicodeEncodeError):
- print("There was a Unicode problem. It did not affect script function.")
- file.close()
- print("The file", filename, "contained", total_records, "records,", moved_records, "of which were moved to", new_file_name)
Add Comment
Please, Sign In to add comment