SERBIANHACKERS

SRBTOOL | Mongo DB Crack

Apr 20th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.97 KB | None | 0 0
  1. #SRBHACKERS
  2.  
  3. #!/usr/bin/env python3
  4.  
  5. import hashlib
  6. import sys
  7. import threading
  8. import queue
  9. import time
  10.  
  11.  
  12. THREADS = 400
  13. TIMEOUT = 5
  14. SLEEP = 5
  15.  
  16.  
  17. def load_pwds(filename, cred_queue):
  18.     # Load the password candidates into the queue.
  19.     f = open(filename, 'rb')
  20.     fail_count = 0
  21.     for line in f:
  22.         try:
  23.             line = line.decode()
  24.         except UnicodeDecodeError:
  25.             fail_count += 1
  26.             continue
  27.  
  28.         line = line.rstrip('\r\n')
  29.         if line == '':
  30.             continue
  31.  
  32.         cred_queue.put(line)
  33.  
  34.     print('Fail count: {0}'.format(fail_count))
  35.     f.close()
  36.  
  37.  
  38. def verify(hashes, cred_queue):
  39.     while fin.isSet() is False:
  40.         try:
  41.             pwd = cred_queue.get(timeout=TIMEOUT)
  42.  
  43.         except queue.Empty:
  44.             return
  45.  
  46.         for name, hash in hashes:
  47.             pw = '{0}:mongo:{1}'.format(name, pwd)
  48.             pwhash = hashlib.md5(pw.encode()).hexdigest()
  49.  
  50.             if pwhash == hash:
  51.                 print('{0}:{1}:{2}'.format(name, hash, pwd))
  52.  
  53.  
  54. if __name__ == '__main__':
  55.  
  56.     if len(sys.argv) != 3:
  57.         print('Usage: mongodb_cr_crack.py hashfile wordfile')
  58.         sys.exit(1)
  59.  
  60.     hashfile = sys.argv[1]
  61.     wordfile = sys.argv[2]
  62.     hashes = []
  63.     cred_queue = queue.Queue()
  64.     fin = threading.Event()
  65.  
  66.     # Get our hashes.
  67.     for line in open(hashfile):
  68.         line = line.rstrip('\r\n')
  69.         if line != '' and line[0] != '#':
  70.             hashes.append(line.split(':'))
  71.  
  72.     # Setup the threads for testing the hashes
  73.     for i in range(THREADS):
  74.         t = threading.Thread(target=verify, args=(hashes, cred_queue))
  75.         t.start()
  76.  
  77.     # Load passwords using a thread.
  78.     t = threading.Thread(target=load_pwds, args=(wordfile, cred_queue))
  79.     t.start()
  80.  
  81.     # Launch the threads and kill them on Ctrl-C
  82.     try:
  83.         while threading.active_count() > 1:
  84.             time.sleep(SLEEP)
  85.  
  86.     except KeyboardInterrupt:
  87.         fin.set()
Add Comment
Please, Sign In to add comment