python wordlist generator.py


SUBMITTED BY: Guest

DATE: Nov. 30, 2013, 9:57 a.m.

FORMAT: Python

SIZE: 2.8 kB

HITS: 909

  1. import itertools, sys
  2. def combList(charString, maxLength):
  3. """Genorate inital word list. This is just diff combinations"""
  4. #var to keepmtrack of how many times we've been through the loop
  5. times = 0
  6. #list to hold combinations
  7. poss = []
  8. for iteration in range(maxLength):
  9. #Use try statment to make sure the max length isn't longer
  10. #than the characters we're going to use
  11. try:
  12. #Iter genorator for combos
  13. comb = itertools.combinations(charString,times+1)
  14. except ValueError:
  15. print "Character string larger than max lenght\nplease try again"
  16. sys.exit()
  17. #Genorator gives tuple with seporated values ex: ('w','o','r','d')
  18. for word in comb:
  19. #join tupe as string and add to list
  20. s = ''.join(word)
  21. poss.append(s)
  22. times += 1
  23. return poss
  24. def permList(combinations):
  25. """Genorates permutations of the genorated combonation list"""
  26. #going to write ultimate list to a file
  27. #if not, you can run into virtual memory errors if the list gets above 4Gb
  28. f = open("wordlist.txt","w")
  29. #var to hold how many words we have
  30. x = 0
  31. for word in combinations:
  32. #loop through combonations and genorate a list of all
  33. #possable ways to combine letters
  34. permutation = itertools.permutations(word)
  35. for permWord in permutation:
  36. f.write(''.join(permWord)+"\n")
  37. x += 1
  38. #del used permutation to free up some memory
  39. #not so much needed, but this script will rape memory if
  40. #appending to a list insteady of writing to a file
  41. del permutation
  42. #always close file handles
  43. f.close()
  44. return x
  45. def main():
  46. """Main program, gets user info and computes the lists"""
  47. ch = raw_input("characters to try: ")
  48. num = input("max length: ")
  49. combo = combList(ch,num)
  50. print "list genorated"
  51. print "doing wordlist now"
  52. permTotal = permList(combo)
  53. f = open("wordlist.txt","r")
  54. print "working..."
  55. for i in range(permTotal+1):
  56. word = f.readline().strip()
  57. #This is where you would be doing the actule brute forcing
  58. #you could try and log into a website or crack a password protected
  59. #zip file, genorate md5's and crack a password dump
  60. #if linux, brute force WPA wifi with iwconfig
  61. #and any thing else you might need for a password
  62. print word
  63. f.close()
  64. print "done\n"
  65. raw_input(".....")
  66. main()

comments powered by Disqus