Skip to content
Snippets Groups Projects
Commit 78157230 authored by tanibose's avatar tanibose
Browse files

Attacker code

parent 865999f8
No related branches found
No related tags found
No related merge requests found
import socket
import signal
import sys
import time
# Socket configuration
HOST = '127.0.0.1' # Localhost
PORT = 65432 # Port of the main script
def send_signal(signal_value):
"""
Sends a signal to the main script to indicate an attack or stop signal.
"""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
try:
client_socket.connect((HOST, PORT))
client_socket.sendall(str(signal_value).encode())
print(f"[INFO] Sent signal: {signal_value}")
except ConnectionRefusedError:
print("[ERROR] Failed to connect to the main script. Is it running?")
sys.exit(1)
def cleanup(signal_received, frame):
"""
Cleanup when the script is interrupted (CTRL+C).
Sends a signal to stop the attack.
"""
print("\n[INFO] Stopping attack...")
send_signal(0) # Signal to stop the attack
sys.exit(0)
def launch_attack():
"""
Launches a simulated DoS attack by continuously sending the attack signal.
"""
print("[INFO] Starting DoS attack...")
send_signal(1) # Signal to indicate the attack has started
while True:
# Simulate sending attack packets (e.g., using hping3)
# Uncomment the below line if hping3 is available and configure accordingly
# os.system(f"hping3 --flood --icmp {TARGET_IP}")
print("[INFO] Simulating attack... (Press CTRL+C to stop)")
time.sleep(5) # Simulate attack duration
if __name__ == "__main__":
# Handle CTRL+C gracefully
signal.signal(signal.SIGINT, cleanup)
try:
launch_attack()
except Exception as e:
print(f"[ERROR] {e}")
cleanup(None, None)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment