Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2.7
- #Kali VM with one core processor benchmark:
- #SHA512 + salt: 400 combinations per second
- #SHA1 + salt: 7214 cominations per second
- import crypt
- import optparse
- import time
- import threading
- lock = threading.Semaphore(value = 1)
- def hashing(pw, salt_length, line):
- salt = pw[0:salt_length]
- line = line.strip('\n')
- encrypt = crypt.crypt(line, salt)
- lock.acquire()
- return encrypt
- def main():
- parser = optparse.OptionParser('usage: Usage: ' + '-f <Shadowfile> -d <Dictionary>')
- parser.add_option('-f', dest='shadow', type='string', help='Specify shadow file')
- parser.add_option('-d', dest='dictionary', type='string', help='Specify dictionary file')
- (options, args) = parser.parse_args()
- if (options.shadow == None) | (options.dictionary == None):
- print parser.usage
- exit(0)
- else:
- shadow = options.shadow
- dictionary = options.dictionary
- f = open(shadow, 'r').readlines()
- d = open(dictionary, 'r').readlines()
- for line in f:
- if ':' in line:
- user = line.split(':')[0]
- pw = line.split(':')[1].strip(' ')
- print('Encrypted password:' + pw)
- salt = raw_input('Enter the length of salt above please. Example:[$1-6$salt$]: ')
- salt = int(salt)
- print('[+]Checking password for user:' + user)
- start_time = time.time()
- for line in d:
- t = Thread(target=hashing, args=(pw, salt, line))
- t.start()
- if encrypt == pw:
- print('[+]Password found!:' + line + 'And it took about %s seconds to crack it' % (time.time() - start_time) + '\n')
- break
- d.close()
- f.close()
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment