emperor886

Wordlist Script

Dec 3rd, 2021 (edited)
1,115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. #-----------------------------------------------------
  2. #   Wordlist Adjustment
  3. #
  4. #   Description:
  5. #       Removes items from a wordlist
  6. #       Currently set to remove anything less than 8 characters to make the wordlist useful for WPA
  7. #
  8. #   Usage:
  9. #       python wordlist.py file
  10. #
  11. #   Parameters:
  12. #       File - the name of the wordlist
  13. #
  14. #   History:
  15. #   Date        Author      Description
  16. #   2021-12-02  A. Walker   Initial Creation
  17. #   2021-12-07  A. Walker   Fixed Header (usage)
  18. #-----------------------------------------------------
  19.  
  20. import sys, re
  21.  
  22. filename = sys.argv[1]
  23. file = open(filename, 'r')
  24.  
  25. name_search = re.search(r"(^.+)\.(.*)", filename)
  26.  
  27. old_file_name = name_search.group(1)
  28. file_format = name_search.group(2)
  29.  
  30. new_file_name = old_file_name + "_new" + "." + file_format
  31. new_file = open(new_file_name, 'a')
  32.  
  33. total_records = 0
  34. moved_records = 0
  35.  
  36. try:
  37.  
  38.     for line in file:
  39.        
  40.         total_records += 1
  41.         match = re.search(r"(^.{8,25}$)", line)
  42.         if match:
  43.             moved_records += 1
  44.             new_file.write(match.group(1))
  45.             new_file.write("\n")
  46.         else:
  47.             pass
  48.  
  49. except (UnicodeDecodeError, UnicodeEncodeError):
  50.     print("There was a Unicode problem. It did not affect script function.")
  51.  
  52. file.close()
  53.  
  54. 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