Guest User

Untitled

a guest
May 4th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #!/usr/bin/python2.7
  2.  
  3. #Kali VM with one core processor benchmark:
  4. #SHA512 + salt: 400 combinations per second
  5. #SHA1 + salt: 7214 cominations per second
  6.  
  7. import crypt
  8. import optparse
  9. import time
  10. import threading
  11.  
  12. lock = threading.Semaphore(value = 1)
  13.  
  14. def hashing(pw, salt_length, line):
  15. salt = pw[0:salt_length]
  16. line = line.strip('\n')
  17. encrypt = crypt.crypt(line, salt)
  18. lock.acquire()
  19. return encrypt
  20.  
  21. def main():
  22. parser = optparse.OptionParser('usage: Usage: ' + '-f <Shadowfile> -d <Dictionary>')
  23. parser.add_option('-f', dest='shadow', type='string', help='Specify shadow file')
  24. parser.add_option('-d', dest='dictionary', type='string', help='Specify dictionary file')
  25. (options, args) = parser.parse_args()
  26. if (options.shadow == None) | (options.dictionary == None):
  27. print parser.usage
  28. exit(0)
  29. else:
  30. shadow = options.shadow
  31. dictionary = options.dictionary
  32. f = open(shadow, 'r').readlines()
  33. d = open(dictionary, 'r').readlines()
  34. for line in f:
  35. if ':' in line:
  36. user = line.split(':')[0]
  37. pw = line.split(':')[1].strip(' ')
  38. print('Encrypted password:' + pw)
  39. salt = raw_input('Enter the length of salt above please. Example:[$1-6$salt$]: ')
  40. salt = int(salt)
  41. print('[+]Checking password for user:' + user)
  42. start_time = time.time()
  43. for line in d:
  44. t = Thread(target=hashing, args=(pw, salt, line))
  45. t.start()
  46. if encrypt == pw:
  47. print('[+]Password found!:' + line + 'And it took about %s seconds to crack it' % (time.time() - start_time) + '\n')
  48. break
  49.  
  50. d.close()
  51. f.close()
  52.  
  53. if __name__ == "__main__":
  54. main()
Add Comment
Please, Sign In to add comment