-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathWarpScanner.py
2174 lines (1882 loc) · 64.1 KB
/
WarpScanner.py
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
V=70
import urllib.request
import urllib.parse
from urllib.parse import quote
import os
try:
import requests
except Exception:
print("Requests module not installed. Installing now...")
os.system('pip install requests')
try:
import requests
except Exception:
os.system('wget https://github.com/psf/requests/releases/download/v2.32.2/requests-2.32.2.tar.gz')
os.system('tar -xzvf requests-2.32.2.tar.gz')
os.chdir('requests-2.32.2')
os.system('python setup.py install')
try:
import requests
except Exception:
os.system('curl -L -o requests-2.32.2.tar.gz https://github.com/psf/requests/releases/download/v2.32.2/requests-2.32.2.tar.gz')
os.system('tar -xzvf requests-2.32.2.tar.gz')
os.chdir('requests-2.32.2')
os.system('python setup.py install')
import requests
import re
import socket
from concurrent.futures import ThreadPoolExecutor, as_completed
import time
try:
import rich
except Exception:
print("Rich module not installed. Installing now...")
os.system('pip install rich')
from rich.console import Console
from rich.prompt import Prompt
from rich import print as rprint
from rich.table import Table
try:
import retrying
except Exception:
print("retrying module not installed. Installing now...")
os.system('pip install retrying')
try:
import retrying
except Exception:
os.system("wget https://github.com/rholder/retrying/archive/refs/tags/v1.3.3.tar.gz")
os.system("tar -zxvf v1.3.3.tar.gz")
os.chdir("retrying-1.3.3")
os.system("python setup.py install")
from retrying import retry
from requests.exceptions import ConnectionError
import random
import subprocess
import json
import sys
try:
from icmplib import ping as pinging
except Exception:
os.system('pip install icmplib')
from icmplib import ping as pinging
import base64
try:
import datetime
except Exception:
os.system('pip install datetime')
import datetime
try:
from alive_progress import alive_bar
except Exception:
os.system("pip install alive_progress")
from alive_progress import alive_bar
api=''
ports = [1074, 894, 908, 878]
console = Console()
wire_config_temp=''
wire_c=1
wire_p=0
send_msg_wait=0
results=[]
resultss=[]
save_result=[]
save_best=[]
best_result=[]
WoW_v2=''
isIran=''
max_workers_number=0
do_you_save='2'
which=''
ping_range='n'
def gt_resolution():
return os.get_terminal_size().columns
def info():
console.clear()
table = Table(show_header=True,title="Info", header_style="bold blue")
table.add_column("Creator", width=15)
table.add_column("contact", justify="right")
table.add_row("arshiacomplus","1 - Telegram")
table.add_row("arshiacomplus","2 - github")
console.print(table)
print('\nEnter a Number\n')
options2={"1" : "open Telegram Channel", "2" : "open github ", "0":"Exit"}
for key, value in options2.items():
rprint(f" [bold yellow]{key}[/bold yellow]: {value}")
whats2 = Prompt.ask("Choose an option", choices=list(options2.keys()), default="1")
if whats2=='0':
os.execv(sys.executable, ['python'] + sys.argv)
elif whats2=='1':
os.system("termux-open-url 'https://t.me/arshia_mod_fun'")
elif whats2=='2' :
os.system("termux-open-url 'https://github.com/arshiacomplus/'")
def check_ipv6():
try:
ipv6 = requests.get('http://v6.ipv6-test.com/api/myip.php', timeout=15)
if ipv6.status_code == 200:
ipv6 ="[green]Available[/green]"
except Exception:
ipv6 = "Unavailable"
try:
ipv4 = requests.get('http://v4.ipv6-test.com/api/myip.php',timeout=15)
if ipv4.status_code == 200:
ipv4= "[green]Available[/green]"
except Exception:
ipv4 = "Unavailable"
return [ipv4,ipv6]
def input_p(pt ,options):
os.system('clear')
options.update({"0" : "Exit"})
print(pt)
for key, value in options.items():
rprint(f" [bold yellow]{key}[/bold yellow]: {value}")
whats = Prompt.ask("Choose an option", choices=list(options.keys()), default="1")
if whats=='0':
os.execv(sys.executable, ['python'] + sys.argv)
return whats
def urlencode(string):
if string is None:
return None
return urllib.parse.quote(string, safe='a-zA-Z0-9.~_-')
def free_cloudflare_account2():
@retry(stop_max_attempt_number=3, wait_fixed=2000, retry_on_exception=lambda x: isinstance(x, ConnectionError))
def file_o():
try:
response = urllib.request.urlopen("https://fscarmen.cloudflare.now.cc/wg", timeout=30).read().decode('utf-8')
return response
except Exception:
response = requests.get("https://fscarmen.cloudflare.now.cc/wg", timeout=30)
return response.text
response = file_o()
PublicKey=response[response.index(':')+2:response.index('\n')]
PrivateKey=response[response.index('\n')+13:]
reserved=[222,6,184]
return ["2606:4700:110:8d48:52cb:c565:3a80:c416/128" , PrivateKey , reserved, PublicKey]
def byte_to_base64(myb):
return base64.b64encode(myb).decode('utf-8')
def generate_public_key(key_bytes):
# Convert the private key bytes to an X25519PrivateKey object
private_key = X25519PrivateKey.from_private_bytes(key_bytes)
# Perform the scalar multiplication to get the public key
public_key = private_key.public_key()
# Serialize the public key to bytes
public_key_bytes = public_key.public_bytes(
encoding=serialization.Encoding.Raw,
format=serialization.PublicFormat.Raw
)
return public_key_bytes
def generate_private_key():
key = os.urandom(32)
# Modify random bytes using algorithm described at:
# https://cr.yp.to/ecdh.html.
key = list(key) # Convert bytes to list for mutable operations
key[0] &= 248
key[31] &= 127
key[31] |= 64
return bytes(key) # Convert list back to bytes
def register_key_on_CF(pub_key):
url = 'https://api.cloudflareclient.com/v0a4005/reg'
# url = 'https://api.cloudflareclient.com/v0a2158/reg'
# url = 'https://api.cloudflareclient.com/v0a3596/reg'
body = {"key": pub_key,
"install_id": "",
"fcm_token": "",
"warp_enabled": True,
"tos": datetime.datetime.now().isoformat()[:-3] + "+07:00",
"type": "Android",
"model": "PC",
"locale": "en_US"}
bodyString = json.dumps(body)
headers = {'Content-Type': 'application/json; charset=UTF-8',
'Host': 'api.cloudflareclient.com',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/3.12.1',
"CF-Client-Version": "a-6.30-3596"
}
r = requests.post(url, data=bodyString, headers=headers)
return r
def bind_keys():
priv_bytes = generate_private_key()
priv_string = byte_to_base64(priv_bytes)
pub_bytes = generate_public_key(priv_bytes)
pub_string = byte_to_base64(pub_bytes)
result = register_key_on_CF(pub_string)
if result.status_code == 200:
try:
z = json.loads(result.content)
client_id = z['config']["client_id"]
cid_byte = base64.b64decode(client_id)
reserved = [int(j) for j in cid_byte]
return '2606:4700:110:846c:e510:bfa1:ea9f:5247/128',priv_string,reserved, 'bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo='
except Exception as e:
print('Something went wronge with api')
exit()
def fetch_config_from_api():
global api
if api=='':
which_api=input_p('Which Api \n', {'1':'First api', '2' :'Second api(need vpn just for install lib)'})
api=which_api
else:
which_api=api
if which_api == '2':
try:
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
from cryptography.hazmat.primitives import serialization
except Exception:
try:
print("cryptography module not installed. Installing now...")
os.system('pkg install python3 rust binutils-is-llvm -y')
os.system('export CXXFLAGS="-Wno-register"')
os.system('export CFLAGS="-Wno-register"')
os.system('python3 -m pip install cryptography ')
except Exception:
os.system("wget https://github.com/pyca/cryptography/archive/refs/tags/43.0.0.tar.gz")
os.system("tar -zxvf 43.0.0.tar.gz")
os.chdir("cryptography-43.0.0")
os.system("pip install .")
try:
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
except Exception:
print('somthing wemt wrong with cryptography')
exit()
keys=bind_keys()
keys=list(keys)
return {
'PrivateKey': keys[1],
'PublicKey': keys[3],
'Reserved': keys[2],
'Address': keys[0]
}
@retry(stop_max_attempt_number=3, wait_fixed=2000, retry_on_exception=lambda x: isinstance(x, ConnectionError))
def file_o():
try:
response = urllib.request.urlopen("http://s9.serv00.com:1074/arshiacomplus/api/wirekey", timeout=30).read().decode('utf-8')
return response
except Exception:
response = requests.get("http://s9.serv00.com:1074/arshiacomplus/api/wirekey", timeout=30)
return response.text
b = file_o()
b=b.split("\n")
Address_key=b[0][b[0].index(":")+2:]
private_key=b[1][b[1].index(":")+2:]
reserved=b[2][b[2].index(":")+2:].split(" ")
reserved.pop(3)
reserved = [int(item) for item in reserved]
pub_key=b[3][b[3].index(":")+2:]
return {
'PrivateKey': private_key,
'PublicKey': pub_key,
'Reserved':reserved,
'Address': Address_key
}
def free_cloudflare_account():
global api
if api=='':
which_api=input_p('Which Api \n', {'1':'First api', '2' :'Second api(need vpn just for install lib)'})
api=which_api
else:
which_api=api
if which_api == '2':
try:
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
from cryptography.hazmat.primitives import serialization
except Exception:
try:
print("cryptography module not installed. Installing now...")
os.system('pkg install python3 rust binutils-is-llvm -y')
os.system('export CXXFLAGS="-Wno-register"')
os.system('export CFLAGS="-Wno-register"')
os.system('python3 -m pip install cryptography ')
except Exception:
os.system("wget https://github.com/pyca/cryptography/archive/refs/tags/43.0.0.tar.gz")
os.system("tar -zxvf 43.0.0.tar.gz")
os.chdir("cryptography-43.0.0")
os.system("pip install .")
try:
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
except Exception:
print('somthing wemt wrong with cryptography')
exit()
keys=bind_keys()
keys=list(keys)
return keys
@retry(stop_max_attempt_number=3, wait_fixed=2000, retry_on_exception=lambda x: isinstance(x, ConnectionError))
def file_o():
try:
response = urllib.request.urlopen("http://s9.serv00.com:1074/arshiacomplus/api/wirekey", timeout=30).read().decode('utf-8')
return response
except Exception:
response = requests.get("http://s9.serv00.com:1074/arshiacomplus/api/wirekey", timeout=30)
return response.text
try:
b = file_o()
except ConnectionError:
console.print("[bold red]Failed to connect to API after 6 attempts.[/bold red]")
b=b.split("\n")
Address_key=b[0][b[0].index(":")+2:]
private_key=b[1][b[1].index(":")+2:]
reserved=b[2][b[2].index(":")+2:].split(" ")
reserved.pop(3)
reserved = [str(item) for item in reserved]
pub_key=b[3][b[3].index(":")+2:]
all_key=[Address_key , private_key , reserved, "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo="]
return all_key
def upload_to_bashupload(config_data):
@retry(stop_max_attempt_number=3, wait_fixed=2000, retry_on_exception=lambda x: isinstance(x, ConnectionError))
def file_o():
files = {'file': ('output.json', config_data)}
try:
response = requests.post('https://bashupload.com/', files=files, timeout=30)
except Exception:
response = requests.post('https://bashupload.com/', files=files, timeout=50)
return response
try:
response = file_o()
if response.ok:
download_link = response.text.strip()
download_link_with_query = download_link[59:len(download_link)-27] + "?download=1"
console.print(f'[green]Your link: {download_link_with_query}[/green]')
else:
console.print("[red]Something happened with creating the link[/red]", style="bold red")
except Exception as e:
console.print(f"[red]An error occurred: {e}[/red]", style="bold red")
def create_ip_range(start_ip, end_ip):
start = list(map(int, start_ip.split('.')))
end = list(map(int, end_ip.split('.')))
temp = start[:]
ip_range = []
while temp != end:
ip_range.append('.'.join(map(str, temp)))
temp[3] += 1
for i2 in (3, 2, 1):
if temp[i2] == 256:
temp[i2] = 0
temp[i2-1] += 1
ip_range.append(end_ip)
return ip_range
def scan_ip_port(ip, results :list):
port=ports[random.randint(0,3)]
icmp=pinging(ip, count=4, interval=1, timeout=5,privileged=False)
if icmp.is_alive:
results.append((ip, port, float(icmp.avg_rtt), icmp.packet_loss, icmp.jitter))
def main_v6():
global which
global ping_range
global save_best
global resultss
global which
resultss=[]
def generate_ipv6():
return f"2606:4700:d{random.randint(0, 1)}::{random.randint(0, 65535):x}:{random.randint(0, 65535):x}:{random.randint(0, 65535):x}:{random.randint(0, 65535):x}"
def ping_ip(ip, port):
global do_you_save
global resultss
icmp=pinging(ip, count=4, interval=1, timeout=5,privileged=False, family='ipv6')
if icmp.is_alive:
resultss.append((ip, port, float(icmp.avg_rtt), icmp.packet_loss, icmp.jitter))
console = Console()
ports_to_check = [1074 , 864]
random_ip=generate_ipv6()
best_ping=1000
best_ip=""
table = Table(show_header=True, title="IP Scan Results", header_style="bold blue")
table.add_column("IP", style="dim",width=15) # Set no_wrap to False to allow text wrapping
table.add_column("Port", justify="right")
table.add_column("Ping (ms)", justify="right")
table.add_column("Packet Loss (%)", justify="right")
table.add_column("Jitter (ms)", justify="right")
table.add_column("Score", justify="right")
executor= ThreadPoolExecutor(max_workers=800)
try:
print("\033[1;35m")
futures = [executor.submit(ping_ip, generate_ipv6(), ports_to_check[random.randint(0,1)]) for _ in range(101)]
none=gt_resolution()
bar_size=min( none-40, 20)
if bar_size<3:
bar_size=3
elif bar_size>1000:
bar_size=1000
with alive_bar(total=len(futures), length=bar_size) as bar: # Length is in characters
for future in futures:
time.sleep(0.01)
result = future.result()
bar()
except Exception as E:
rprint('[bold red]An Error: [/bold red]', E)
finally:
executor.shutdown(wait=True)
print("\033[0m")
extended_results=[]
for result in resultss:
ip, port, ping ,loss_rate,jitter= result
if ping ==0.0:
ping=1000
if float(jitter)==0.0:
jitter=1000
if loss_rate ==1.0 :
loss_rate=1000
loss_rate=loss_rate*100
combined_score = 0.5 * ping + 0.3 * loss_rate + 0.2 * jitter
extended_results.append((ip, port, ping, loss_rate,jitter, combined_score))
# Sort the results based on ping time
sorted_results=sorted(extended_results, key=lambda x: x[5])
for ip, port,ping,loss_rate,jitter, combined_score in sorted_results:
if which !='3' and do_you_save=='1':
if loss_rate == 0.0 and ping !=0.0:
if ping<=int(ping_range):
if which =="1" or which=="2" :
if need_port=="1":
if which=='2':
save_best.append("\n")
save_best.append('['+str(ip)+']'+":"+str(port))
elif which=='1':
save_best.append('['+str(ip)+']'+":"+str(port)+",")
else:
if which=='2':
save_best.append("\n")
save_best.append('['+str(ip)+']')
elif which=='1':
save_best.append('['+str(ip)+'],')
if which =='3' and do_you_save=='1':
if need_port=="2":
save_best.append('['+ip+']'+' | '+'ping: '+str(ping)+'packet_lose: '+str(loss_rate)+'jitter: '+str(jitter)+'\n')
else:
save_best.append('['+ip+']'+port+' | '+'ping: '+str(ping)+'packet_lose: '+str(loss_rate)+'jitter: '+str(jitter)+'\n')
table.add_row(ip, str(port) if port else "878", f"{ping:.2f}" if ping else "None", f"{loss_rate:.2f}%",f"{jitter}", f"{combined_score:.2f}")
if ping < best_ping:
best_ping = ping
best_ip = ip
os.system("clear")
console.print(table)
port_random = ports_to_check[random.randint(0, len(ports_to_check) - 1)]
if do_you_save=='1':
if which!='2':
save_best[len(save_best)-1]=save_best[len(save_best)-1][:len(save_best[len(save_best)-1])-1]
with open('/storage/emulated/0/result.csv' , "w") as f:
for j in save_best:
f.write(j)
print(' saved in /storage/emulated/0/result.csv !')
best_ip_mix = [1] * 2
if best_ip:
console.print(f"\n[bold green]Best IP : [{best_ip}]:{port_random} with ping time: {best_ping} ms[/bold green]")
best_ip_mix[0] = "[" + best_ip + "]"
best_ip_mix[1] = port_random
else:
console.print(f"\n[bold green]Best IP : [{random_ip}]:{port_random} with ping time: {best_ping} ms[/bold green]")
best_ip_mix[0] = "[" + random_ip + "]"
best_ip_mix[1] = port_random
return best_ip_mix
def main():
global which
global max_workers_number
global ping_range
ping_range=''
results=[]
if do_you_save=='1':
ping_range=input('\nping range(zero to what)[defual= n]: ')
if ping_range=='n' or ping_range=='N':
ping_range='300'
if what!='0':
which_v=input_p('Choose an ip version\n ', {"1": 'ipv4' ,
"2": 'ipv6'})
if which_v=="2":
console.clear()
best_result=main_v6()
return best_result
Cpu_speed=input_p('scan power', {"1" : "Faster" , "2" : "Slower"})
if Cpu_speed == "1": max_workers_number=1000
elif Cpu_speed == "2": max_workers_number=500
console.clear()
console.print("Please wait, scanning IP ...\n\n", style="blue")
start_ips = ["188.114.96.0", "162.159.192.0", "162.159.195.0"]
end_ips = ["188.114.99.224", "162.159.193.224", "162.159.195.224"]
ports = [1074, 894, 908, 878]
for start_ip, end_ip in zip(start_ips, end_ips):
ip_range = create_ip_range(start_ip, end_ip)
executor=ThreadPoolExecutor(max_workers=max_workers_number)
print("\033[1;35m")
try:
futures = [executor.submit(scan_ip_port, ip, results) for ip in ip_range]
none=gt_resolution()
bar_size=min( none-40, 20)
if bar_size<3:
bar_size=3
elif bar_size>1000:
bar_size=1000
with alive_bar(total=len(futures), length=bar_size) as bar: # Length is in characters
for future in futures:
time.sleep(0.01)
result = future.result()
bar()
except Exception as E:
print("Error :",E)
finally:
executor.shutdown(wait=True)
print("\033[0m")
extended_results = []
for result in results:
ip, port, ping ,loss_rate,jitter= result
if ping ==0.0:
ping=1000
if float(jitter)==0.0:
jitter=1000
if loss_rate ==1.0 :
loss_rate=1000
loss_rate=loss_rate*100
combined_score = 0.5 * ping + 0.3 * loss_rate + 0.2 * jitter
extended_results.append((ip, port, ping, loss_rate,jitter, combined_score))
sorted_results = sorted(extended_results, key=lambda x: x[5])
for ip, port, ping, loss_rate,jitter, combined_score in sorted_results:
if which !='3' and do_you_save=='1':
if loss_rate == 0.0 and ping !=0.0:
if which =="1" or which=="2" :
if need_port=="2":
try:
if ping<=int(ping_range):
save_result.index(str(ip))
except Exception:
if ping<=int(ping_range):
save_result.append("\n")
save_result.append(str(ip))
else:
try:
if ping<=int(ping_range):
save_result.index(str(ip)+":"+str(port))
except Exception:
if ping<=int(ping_range):
save_result.append("\n")
save_result.append(str(ip)+":"+str(port))
if which =='3' and do_you_save=='1':
if need_port=="2":
save_result.append(ip+' | '+'ping: '+str(ping)+'packet_lose: '+str(loss_rate)+'jitter: '+str(jitter)+'\n')
else:
save_result.append(ip+port+' | '+'ping: '+str(ping)+'packet_lose: '+str(loss_rate)+'jitter: '+str(jitter)+'\n')
console.clear()
table = Table(show_header=True,title="IP Scan Results", header_style="bold blue")
table.add_column("IP", style="dim", width=15)
table.add_column("Port", justify="right")
table.add_column("Ping (ms)", justify="right")
table.add_column("Packet Loss (%)", justify="right")
table.add_column("Jitter (ms)", justify="right")
table.add_column("Score", justify="right")
for ip, port, ping, loss_rate,jitter, combined_score in sorted_results[:10]:
table.add_row(ip, str(port) if port else "878", f"{ping:.2f}" if ping else "None", f"{loss_rate:.2f}%",f"{jitter}", f"{combined_score:.2f}")
console.print(table)
best_result = sorted_results[0] if sorted_results else None
if best_result and best_result[0] != "No IP":
ip, port, ping, loss_rate,jitter, combined_score = best_result
try:
console.print(f"The best IP: {ip}:{port if port else 'N/A'} , ping: {ping:.2f} ms, packet loss: {loss_rate:.2f}%, {jitter:.2f} ms ,score: {combined_score:.2f}", style="green")
except TypeError:
console.print(f"The best IP: {ip}:{port if port else '878'} , ping: None, packet loss: {loss_rate:.2f}% ,{jitter:.2f} ms , score: {combined_score:.2f}", style="green")
best_result=2*[1]
best_result[0]=f"{ip}"
best_result[1]=port
else:
console.print("Nothing was found", style="red")
t=False
if what == '1':
if do_you_save=='1':
if which =="1":
with open('/storage/emulated/0/result.csv' , "w") as f:
for j in save_result[1:]:
if j != "\n":
f.write(j)
t=False
else:
# if j != save_result[len(save_result)-1]:
if t==False:
f.write(",")
t=True
else:
with open('/storage/emulated/0/result.csv' , "w") as f:
for j in save_result:
f.write(j)
print(' saved in /storage/emulated/0/result.csv !')
return best_result
def main2():
global best_result
def main2_2():
global WoW_v2
try:
all_key3=free_cloudflare_account()
except Exception as E:
print(' Try again Error =', E)
exit()
try:
all_key2=free_cloudflare_account()
except Exception as E:
print(' Try again Error =', E)
exit()
os.system('clear')
print(f'Make Wireguard ')
time.sleep(10)
WoW_v2+=f'''
{{
"remarks": "Tel= arshiacomplus - WoW",
"log": {{
"loglevel": "warning"
}},
"dns": {{
"hosts": {{
"geosite:category-ads-all": "127.0.0.1",
"geosite:category-ads-ir": "127.0.0.1"'''
if polrn_block=='1' :WoW_v2+=f''',
"geosite:category-porn": "127.0.0.1"'''
WoW_v2+=f'''
}},
"servers": [
"https://94.140.14.14/dns-query",
{{
"address": "8.8.8.8",
"domains": [
"geosite:category-ir",
"domain:.ir"
],
"expectIPs": [
"geoip:ir"
],
"port": 53
}}
],
"tag": "dns"
}},
"inbounds": [
{{
"port": 10808,
"protocol": "socks",
"settings": {{
"auth": "noauth",
"udp": true,
"userLevel": 8
}},
"sniffing": {{
"destOverride": [
"http",
"tls"
],
"enabled": true,
"routeOnly": true
}},
"tag": "socks-in"
}},
{{
"port": 10809,
"protocol": "http",
"settings": {{
"auth": "noauth",
"udp": true,
"userLevel": 8
}},
"sniffing": {{
"destOverride": [
"http",
"tls"
],
"enabled": true,
"routeOnly": true
}},
"tag": "http-in"
}},
{{
"listen": "127.0.0.1",
"port": 10853,
"protocol": "dokodemo-door",
"settings": {{
"address": "1.1.1.1",
"network": "tcp,udp",
"port": 53
}},
"tag": "dns-in"
}}
],
"outbounds": [
{{
"protocol": "wireguard",
"settings": {{
"address": [
"172.16.0.2/32",
"{all_key3[0]}"
],
"mtu": 1280,
"peers": [
{{
"endpoint": "{best_result[0]}:{best_result[1]}",
"publicKey": "{all_key3[3]}"
}}
],
"reserved": {all_key3[2]},
"secretKey": "{all_key3[1]}"'''
if what== '14':WoW_v2+=''',
"keepAlive": 10,
"wnoise": "quic",
"wnoisecount": "10-15",
"wpayloadsize": "1-8",
"wnoisedelay": "1-3"'''
WoW_v2+=f'''
}},
"streamSettings": {{
"sockopt": {{
"dialerProxy": "warp-ir"
}}
}},
"tag": "warp-out"
}},
{{
"protocol": "wireguard",
"settings": {{
"address": [
"172.16.0.2/32",
"{all_key2[0]}"
],
"mtu": 1280,
"peers": [
{{
"endpoint": "162.159.192.115:864",
"publicKey": "{all_key2[3]}"
}}
],
"reserved": {all_key2[2]},
"secretKey": "{all_key2[1]}"'''
if what== '14':WoW_v2+=''',
"keepAlive": 10,
"wnoise": "quic",
"wnoisecount": "10-15",
"wpayloadsize": "1-8",
"wnoisedelay": "1-3"'''
WoW_v2+=f'''
}},
"tag": "warp-ir"
}},
{{
"protocol": "dns",
"tag": "dns-out"
}},
{{
"protocol": "freedom",
"settings": {{}},
"tag": "direct"
}},
{{
"protocol": "blackhole",
"settings": {{
"response": {{
"type": "http"
}}
}},
"tag": "block"
}}
],
"policy": {{
"levels": {{
"8": {{
"connIdle": 300,
"downlinkOnly": 1,
"handshake": 4,
"uplinkOnly": 1
}}
}},
"system": {{
"statsOutboundUplink": true,
"statsOutboundDownlink": true
}}
}},
"routing": {{
"domainStrategy": "IPIfNonMatch",
"rules": [
{{
"inboundTag": [
"dns-in"
],
"outboundTag": "dns-out",
"type": "field"
}},
{{
"ip": [
"8.8.8.8"
],
"outboundTag": "direct",
"port": "53",
"type": "field"
}},
{{
"domain": [
"geosite:category-ir",
"domain:.ir"
],
"outboundTag": "direct",
"type": "field"
}},
{{
"ip": [
"geoip:ir",
"geoip:private"
],
"outboundTag": "direct",
"type": "field"
}},
{{
"domain": [
"geosite:category-ads-all",
"geosite:category-ads-ir"'''
if polrn_block=='1' :WoW_v2+=f''',
"geosite:category-porn"'''
WoW_v2+=f'''
],
"outboundTag": "block",
"type": "field"
}},
{{
"outboundTag": "warp-out",
"type": "field",