Advertisement
AceScottie

bruteforce with character checking

Sep 4th, 2018
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. import hashlib
  2. import binascii
  3. from itertools import chain, product
  4. from sets import Set
  5.  
  6. def has_lower(att):
  7.     lower = Set(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])
  8.     stm = False
  9.     for i in att:
  10.         if i in lower:
  11.             stm = True
  12.             break
  13.     return stm
  14.            
  15. def has_upper(att):
  16.     upper = Set(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'])
  17.     stm = False
  18.     for i in att:
  19.         if i in upper:
  20.             stm = True
  21.             break
  22.     return stm
  23. def has_digit(att):
  24.     digit = Set(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'])
  25.     stm = False
  26.     for i in att:
  27.         if i in digit:
  28.             stm = True
  29.             break
  30.     return stm
  31.            
  32. def has_symb(att):
  33.     symb = Set(['!', '$', '%', '^', '&', '*', '(', ')', '{', '}', ':', '@', '~', '<', '>', '?', '[', ']', ';', '#', ',', '.', '/'])
  34.     stm = False
  35.     for i in att:
  36.         if i in digit:
  37.             stm = True
  38.             break
  39.     return stm
  40.  
  41. def con_passwd(key):
  42.         m = hashlib.md5()
  43.         m.update(key)
  44.         key = m.hexdigest()
  45.         return key
  46.  
  47.    
  48. def bruteforce():
  49.     charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!$%^&*(){}:@~<>?[];#,./'
  50.     return (''.join(candidate) for candidate in chain.from_iterable(product(charset, repeat=i) for i in range(8, 64)))
  51.  
  52.  
  53. if __name__ == "__main__":
  54.     for attempt in bruteforce():
  55.         if has_lower(attempt) and has_upper(attempt) and has_digit(attempt) and has_symb(attempt):
  56.             k1 = con_passwd(attempt)
  57.             print(attempt, k1, True)
  58.         else:
  59.             print(attempt, False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement