Advertisement
Pringleman

Py Password Brute Force List Generator v0.3

Jan 30th, 2020
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.65 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Jan 28 22:25:17 2020
  4.  
  5. @author: david
  6. """
  7. import os
  8.  
  9. debug = False
  10.  
  11. #File setup
  12. root_dir = os.path.dirname(os.path.realpath(__file__))
  13. f = open(root_dir+"\\passwords.txt","w+")
  14.  
  15. def get_number_between(low,high):
  16.     """
  17.    Takes two numbers.
  18.    Asks the user to enter a number between those numbers (inclusive).
  19.    Refuses any invalid entries.
  20.    Returns the correctly entered number.
  21.    """
  22.     number = -999
  23.     while (number < low) or (number > high):
  24.         try:
  25.             print("Enter a number between " + str(low) + " and " + str(high)
  26.                     + " inclusive.")
  27.             number = int(input())
  28.         except ValueError:
  29.             number = -999
  30.     return number
  31.            
  32.  
  33. print("Enter minimum password length:")
  34. min_pass_length = get_number_between(1,20)
  35.  
  36. print("Enter maximum password length:")
  37. max_pass_length = get_number_between(1,30)
  38.  
  39. characters = [""]
  40. a_to_z_low = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p",
  41.               "q","r","s","t","u","v","w","x","y","z"]
  42. a_to_z_high = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
  43.                "Q","R","S","T","U","V","W","X","Y","Z"]
  44. zero_to_9 = ["0","1","2","3","4","5","6","7","8","9"]
  45. special_chars = ["!","\"","£","$","%","^","&","*","(",")","-","=","+","_","@",
  46.                  "#","[","]","{","}","|","\\"]
  47.  
  48. print("Select character set:")
  49. print("1) all (a-z, A-Z, 0-9, special characters)")
  50. print("2) Manual selection")
  51.                
  52. char_select = get_number_between(1,2)
  53.  
  54. if char_select == 1:
  55.     print("All characters selected")
  56.     characters = characters + a_to_z_low + a_to_z_high + zero_to_9 + special_chars + [" "]
  57.     print(characters)
  58.  
  59. if char_select == 2:
  60.     print("Manual selection")
  61.     print("Current characters:")
  62.     print(characters)
  63.     print("Select character set to add.")
  64.     print("1) a-z")
  65.     print("2) A-Z")
  66.     print("3) 0-9")
  67.     print("4) Special characters")
  68.     print("5) Spaces")
  69.     print("6) Clear selection")
  70.     print("7) Done")
  71.     selected, selected1, selected2, selected3, selected4, selected5 = False, False, False, False, False, False
  72.     while not selected:
  73.         set_select = get_number_between(1,7)
  74.         if set_select == 1 and not selected1:
  75.             characters = characters + a_to_z_low
  76.             selected1 = True
  77.         if set_select == 2 and not selected2:
  78.             characters = characters + a_to_z_high
  79.             selected2 = True
  80.         if set_select == 3 and not selected3:
  81.             characters = characters + zero_to_9
  82.             selected3 = True
  83.         if set_select == 4 and not selected4:
  84.             characters = characters + special_chars
  85.             selected4 = True
  86.         if set_select == 5 and not selected5:
  87.             characters.append(" ")
  88.             selected5 = True
  89.         if set_select == 6:
  90.             characters = [""]
  91.             selected1, selected2, selected3, selected4, selected5 = False, False, False, False, False
  92.         if set_select == 7:
  93.             if characters != [""]:
  94.                 selected = True
  95.             else:
  96.                 print("Select at leaset one character set.")
  97.         print("Current character set:")
  98.         print(characters)
  99.  
  100. password = []
  101.  
  102. #Create a list of password characters matching the max length of password
  103. for i in range(max_pass_length):
  104.     password.append("")
  105.  
  106. #Prepopulate the characters of the min length of the password
  107. for i in range(min_pass_length):
  108.     if debug:
  109.         print(i)
  110.     password[-(i+1)] = characters[1]
  111.    
  112. complete = False
  113.  
  114. #DEBUG
  115. if debug:
  116.     print("DEBUG")
  117.     print(password)
  118.  
  119. while (not complete):
  120.     current_character = -1
  121.     for character in characters[1:]:
  122.         password[current_character] = character
  123.         pword=""
  124.         for ch in password:
  125.             pword += ch
  126.         pword += "\n"
  127.         if debug:
  128.             print(pword)
  129.         else:
  130.             f.write(pword)
  131.     char_num = 1
  132.    
  133.     #Test if complete
  134.     if len(set(password)) == 1:
  135.         if password[0] == characters[-1]:
  136.             complete = True
  137.            
  138.     #If not, increment higher characters accordingly
  139.     else:
  140.         while True:
  141.             if characters.index(password[current_character-char_num]) == len(characters)-1:
  142.                 char_num += 1
  143.             else:
  144.                 password[current_character-char_num] = characters[characters.index(password[current_character-char_num])+1]
  145.                 if char_num > 1:
  146.                     password[current_character-char_num+1] = characters[0]
  147.                
  148.                 break
  149. f.close
  150. print("\n===Done===")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement