NoAttack is a tool designed to monitor incoming network traffic and automatically enable or disable Cloudflare's "Under Attack" mode based on defined thresholds. It integrates various components, including Redis, Cloudflare, and a Discord Webhook for notification purposes.
- Monitors incoming network traffic in real time.
- Automatically enables "Under Attack" mode in Cloudflare when traffic exceeds a predefined threshold.
- Sends alerts via a Discord webhook during critical events.
- Includes Redis for caching operations.
Before starting, make sure the following are installed:
- Docker and Docker Compose
- Python 3.12 or later (if not using Docker Compose)
-
Clone the repository:
git clone https://github.com/SytxLabs/NoAttack.git cd NoAttack -
Setup configuration: Edit the
config.yamlfile to include your Cloudflare credentials and other settings:CLOUDFLARE: API_KEY: "<Your Cloudflare API Key>" EMAIL: "<Your Email Address>" ZONE_IDS: [ "<Zone ID 1>", "<Zone ID 2>" ] REDIS: HOST: "<Redis Host>" PASSWORD: "<Redis Password>" PORT: 6379 SETTINGS: CHECK_INTERVAL: 60 # Monitoring interval in seconds LOGGING: true # Enable logging MAX_INCOMING_TRAFFIC_MB: 50 # Maximum threshold for incoming traffic WEBHOOK: "<Discord Webhook URL>"
-
Build and run using Docker Compose:
docker-compose up --build
-
Install dependencies manually (if not using Docker Compose):
- Install dependencies via pip:
pip install -r requirements.txt
- Run the script:
python main.py
- Install dependencies via pip:
NoAttack monitors incoming network traffic and takes automated actions based on the configuration.
-
Monitor Traffic:
- Logs real-time data about incoming and outgoing traffic in MB/s.
-
Activate Cloudflare "Under Attack" Mode:
- If traffic exceeds the
MAX_INCOMING_TRAFFIC_MBlimit, Cloudflare's "Under Attack" mode is activated for all specified zones.
- If traffic exceeds the
-
Deactivate Cloudflare "Under Attack" Mode:
- When traffic drops below the threshold, the "Under Attack" mode is deactivated.
-
Notifications:
- Sends real-time updates regarding the activation or deactivation of the "Under Attack" mode to the specified Discord webhook.
- Simply run the application using:
or
docker-compose up
python main.py
- If logging is enabled (
SETTINGS.LOGGING: true), the application will send notifications to the Discord webhook.
- Redis Integration: Used for caching to optimize performance.
- Discord Webhook: Sends notifications about changes to ensure visibility for administrators.
| Key | Description | Example |
|---|---|---|
SETTINGS.MAX_INCOMING_TRAFFIC_MB |
Maximum allowed incoming traffic before enabling Cloudflare's "Under Attack" mode. | 50 |
SETTINGS.CHECK_INTERVAL |
Time interval (in seconds) between traffic checks. | 60 |
SETTINGS.WEBHOOK |
Discord webhook URL for notifications. | https://discord.com/api/... |
SETTINGS.LOGGING |
Allow to send notifications to Discord | true |
CLOUDFLARE.API_KEY |
Your Cloudflare API key. | example_cloudflare_api_key |
CLOUDFLARE.ZONE_IDS |
List of Cloudflare Zone IDs to manage. | [zone_1_id, zone_2_id] |
REDIS.HOST |
Redis host address. | 127.0.0.1 |
REDIS.PASSWORD |
Redis password (if any). | redis_password |
REDIS.PORT |
Redis port number. | 6379 |
For development purposes:
- Add changes to the application code and rebuild the Docker container:
docker-compose up --build
- After modifying the code and or
config.yaml, run the Python application:python main.py
- Cloudflare API Errors:
- Ensure your API key and Zone IDs are correct in
config.yaml. - Verify your internet connection.
- Ensure your API key and Zone IDs are correct in
The idea for this project was inspired by guidedhacking.