-
Notifications
You must be signed in to change notification settings - Fork 2
/
PIA
1608 lines (1365 loc) · 43 KB
/
PIA
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
#!/bin/bash
#
# World Wide Servers by ip
# wget -q https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]' | while read host ;do host $host ;done | awk '{print $NF}' | sort -u | xargs sudo netselect -v -s 20
#
# Some Speed Test File Locations
# http://support.smartdnsproxy.com/customer/portal/articles/1907772-vpn-server-locations-addresses
# http://speedtest.sea01.softlayer.com/downloads/test100.zip
# http://proof.ovh.ca/files/100Mio.dat
# http://793343545.r.cdn77.net/design/swf/testfile100.bin
# http://speedtest.atlanta.linode.com/100MB-atlanta.bin
# http://speedtest.dallas.linode.com/100MB-dallas.bin
# http://speedtest.wdc01.softlayer.com/downloads/test100.zip
# http://mirror.us.leaseweb.net/speedtest/100mb.bin
# http://speedtest.sjc01.softlayer.com/downloads/test100.zip
#http://mirror.sfo12.us.leaseweb.net/speedtest/1000mb.bin
# U.S Servers by ip
# wget -q https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]' | grep us- | while read host ;do host $host ;done | awk '{print $NF}' | sort -u | xargs sudo netselect -v -s 20
#
# tput is used to move the cursor and change colors
# This script is only verified with Ubuntu and distros based on Ubuntu
# sudo and apt are used to offer user to install an unmet dependancy that is package installable
# Outside of package manager Dependency requires manual install
#
# Get IP Source
# curl -s 'https://api.ipify.org'
#
#
# json output for geolocation
# curl -s https://ipapi.co/${MYIP}/json/ | jq -r '"IP : " + .ip, "City: " + .city, "State: " + .region, "Country: " + .country_name, "Location: " + "\(.latitude)\(.longitude)"' | column -s: -t
#
# curl_or_wget=$(if hash curl 2>/dev/null; then echo curl; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi)
# if [ -z "$curl_or_wget" ]; then
# echo "Neither curl nor wget found. Cannot use http method." >&2
# exit 1
#fi
#----------------------------------------------------------------------------------------------------
trap ctrl_c SIGHUP SIGINT SIGTERM
if [[ $EUID -ne 0 ]]; then
printf "%b\n" "This script requires root privileges for Netselect (Fastest Server Check),
installing required tools with apt and MAC Address Changing"
printf "%b\n"
printf "%b\n" "Example sudo "$0" "
exit 1
fi
CHECKMARK="$(tput sgr0)[$(tput setaf 2)✔$(tput sgr0)]"
XMARK="$(tput sgr0)[$(tput setaf 1)X$(tput sgr0)]"
if command -v resize >/dev/null 2>&1 ; then
resize -s 50 90
clear
tput cup 0 0
else
printf '\e[8;50;105t'
clear
tput rc
fi
tput sgr0 # Reset Terminal Colors
if command -v netselect >/dev/null 2>&1 ; then
printf "%b\n"
else
if command -v resize >/dev/null 2>&1 ; then
resize -s 50 105
clear
tput cup 0 0
else
printf '\e[8;50;105t'
clear
tput rc
fi
clear
printf "%b\n\n"
tput setaf 1 # Red Text
printf "%b\n" "Netselect is required but not found. You can download it from"
tput sgr0 # Reset Terminal Colors
tput setaf 3 # Magenta Text
cat <<"EOF"
http://ftp.us.debian.org/debian/pool/main/n/netselect/
http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_i386.deb i386
http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_arm64.deb ARM64
http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_armhf.deb ARMHF
http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_amd64.deb AMD64
EOF
if command -v wget >/dev/null 2>&1 ; then
Downloader="wget"
elif
command -v curl >/dev/null 2>&1 ; then
Downloader="curl"
fi
tput sgr0 # Reset Terminal Colors
printf "%b\n" "Your Architecture (i386, x86_64, etc.) Is"
tput setaf 2 # Green Text
arch=$(dpkg --print-architecture);printf "%b\n\t"; tput blink; printf "%b\n" "${arch}"
tput sgr0 # Reset Terminal Colors
printf "%b\n"
tput sgr0 # Reset Terminal Colors
tput setaf 2 # Green Text
if [ "${arch}" = "arm64" ]; then
printf "%b\n\n" "Suggested Download is"
printf "%b\n" "http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_arm64.deb"
targetDL="http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_arm64.deb"
elif [ "${arch}" = "amd64" ]; then
printf "%b\n\n" "Suggested Download is"
printf "%b\n" "http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_amd64.deb"
targetDL="http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_amd64.deb"
elif [ "${arch}" = "i386" ]; then
printf "%b\n\n" "Suggested Download is"
printf "%b\n" "http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_i386.deb"
targetDL="http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_i386.deb"
elif [ "${arch}" = "armhf" ]; then
printf "%b\n\n" "Suggested Download is"
printf "%b\n" "http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_armhf.deb"
targetDL="http://ftp.us.debian.org/debian/pool/main/n/netselect/netselect_0.3.ds1-28+b1_armhf.deb"
else
printf "%b\n"
fi
tput setaf 3 # Yellow Text
printf "%b\n"
if [ -z "${targetDL}" ]
then
printf "%b\n" "Unknown"
printf "%b\n" "Cant Determine Your Architecture, Manual Download and Install "
printf "%b\n"
tput sgr0 # Reset Terminal Colors
printf "%b\n" "After Download install with"
tput setaf 6 # Cyan Text
cat <<"EOF"
dpkg -i netselect_0.3.ds1-28+b1_*.deb
EOF
exit
else
read -r -n 1 -p "Would you like to attempt download and install now? [y/n] " response
tput sgr0 # Reset Terminal Colors
case "${response}" in
[yY])
if [ "${Downloader}" = curl ]; then
$(curl -O "${targetDL}")
else
"${Downloader}" "${targetDL}"
fi
dpkg -i "$(basename "${targetDL}")"
exec $(readlink -f "$0")
;;
*)
exit
;;
esac
fi
fi
#----------------------------------------------------
# Dependencies Check
CheckScriptDependencies ()
{
declare -a ARRAY
ARRAY=()
Packages=( "$@" )
Package=
printf "%b\n"
for Package in ${Packages[@]}; do
hash $Package 2> /dev/null
if (( $? > 0 )); then
printf "%b" "${XMARK} ${Package} Not Found But Required" "\n"
ARRAY=(${ARRAY[@]} ${Package})
fi
done
#ToInstall=$(printf "%s " ${ARRAY[@]})
if [[ -z "${ARRAY[@]}" ]]; then
Connection_Check
fi
if dig -V >/dev/null 2>&1 ; then
printf " "
else
ARRAY=( ${ARRAY[@]/dig} )
ARRAY=(${ARRAY[@]} dnsutils ncurses-bin)
#ToInstall=$(printf "%s " ${ARRAY[@]})
printf "%b\n"
printf "%b\n" "Missing Dependencies" "\n"
#printf "%b\n" ${ARRAY[@]}
printf "%b\n" "Would you like to try to install them now?"
printf "%b\n"
read -r -n 1 -p "[Y/n] " response
case "${response}" in
[nN])
printf "\n"
exit
;;
*)
apt install ${ARRAY[@]} && exec $(readlink -f "$0")
;;
esac
fi
}
#ProgressBar
spin()
{
printf "["
tput setaf 2
while kill -0 "$SPIN_PID" 2> /dev/null; do
printf "✴ "
sleep "${PBint}"
done
tput sgr0
printf "]"
}
# Check for Internet Access with max retries of 3 then print message
#clear
#tput cup 0 0 # Move cursor to line 0 column 0
#tput ed # Clear all text below cursor
#tput cup 5 0
Connection_Check() {
printf "%b\n" "Checking For Internet Access"; printf "%b\n" "Pinging Google.com"; tput blink; printf "%b\n" ".";tput cup 0 0;tput sgr0 # Reset Terminal Colors
tput civis
if ping -q -c 2 -W 1 google.com >/dev/null; then
Banner
Main_Menu
else
n=0
until [ $n -gt 2 ]
do
ping -q -c 2 -W 1 google.com >/dev/null
if [ $? -eq 0 ]; then
break
fi
n=$(($n+1))
done
tput cup 0 0 # Move cursor to line 0 column 0
tput ed # Clear all text below cursor
tput cup 5 0
printf "%b\n" "Retried 3 Times\n"
printf "%b\n" "Network appears to be down. Unable to reach google.com for network connectivity test\n"
printf "%b\n" "This script is pretty useless without Network access" "\n"
tput cnorm
printf "%b\n" "Continuing to Main Menu in 10 seconds"
sleep 10
clear
Banner
Main_Menu
fi
}
# Main script starts here
Banner() {
#tput rc
tput cup 0 0 # Move cursor to line 0 column 0
#tput ed # Clear all text below cursor
tput setaf 2 # Green Text
cat <<"EOF"
https://github.com/optio50/PIA-Server-Check
____ _ _
| _ \ _ __ (_) __ __ __ _ | |_ ___
| |_) | | '__| | | \ \ / / / _` | | __| / _ \
| __/ | | | | \ V / | (_| | | |_ | __/
|_|_ |_| |_| \_/ \__,_| \__| \___| _
|_ _| _ __ | |_ ___ _ __ _ __ ___ | |_
| | | '_ \ | __| / _ \ | '__| | '_ \ / _ \ | __|
| | | | | | | |_ | __/ | | | | | | | __/ | |_
|___| |_| |_| \__| \___| |_| |_| |_| \___| \__|
/ \ ___ ___ ___ ___ ___ ___ ___ _ __ ___
/ _ \ / __| / __| / _ \ / __| / __| / __| / _ \ | '_ ` _ \
/ ___ \ | (__ | (__ | __/ \__ \ \__ \ | (__ | (_) | | | | | | |
/_/ \_\ \___| \___| \___| |___/ |___/ ✴ \___| \___/ |_| |_| |_|
EOF
tput sgr0 # Reset Terminal Colors
printf "%b\n"
}
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
# if dependency and network check is confirmed. Banner function runs then Main_Menu
Main_Menu() {
#Banner
printf "%b\n"
tput cup 16 0 # Move cursor to line 16 column 0
tput ed # Clear all text below cursor
tput civis # invisible cursor
# Begin Print Main Menu Selections
cat <<"EOF"
Select Option
1. Check For PIA's Fastest Server
2. Speed Test Your Current Connection Speed
3. PIA Links
4. Whats My IP & Location
5. Show PIA Server Location Names
6. DNS Leak Test
7. Change MAC Address
8. Exit / Quit
EOF
# End Print Main Menu Selections
tput cup 35 0 # Move cursor to line 26 column 0
tput ed # Clear all text below cursor
read -r -n 1 option # Wait and read menu selection then continue with a single key press
case "${option}" in
1)
PIA_Menu
;;
2)
Speed_Test
;;
3)
Links
;;
4)
Location_Check
;;
5)
Server_Names
;;
6)
LeakTest
;;
7)
Change_Mac_Menu
;;
8)
#tput cup 25 0
#tput ed
tput cnorm
#tput rmcup
tput el1
printf "%b\n"
exit
;;
*)
#tput cup 16 0
#tput ed
Main_Menu
;;
esac
}
# Romans Chapter 10 Verse 9-10 https://www.biblegateway.com/passage/?search=Romans+10%3A9-10&version=NIV
# 1 John Chapter 5 Verse 13 https://www.biblegateway.com/passage/?search=1+John+5%3A13&version=NIV
Server_Check() {
tput cup 17 0 # Move cursor to line 15 column 0
tput ed # Delete text below cursor
#printf "%b\n" " "
#printf "%b" "Checking For PIA's Fastest Server...Please Wait." "\n\n"
# Checks ALL PIA Worldwide Servers
#------------------------------------------------------------------------------------------------------
if [ "${selection}" -eq 0 ]; then # Zero from PIA_Menu. All servers PIA has
tput setaf 3 # Yellow Text
printf "%b" "Checking All Servers Takes More Time....Be Patient" "\n" # warning that this worldwide server check takes longer
server=$(wget -q https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]' | uniq) # Gets ALL servers
serverCount=$(printf "%b\n" "${server}" | wc -l) # Counts the servers being selected
countries=$(printf "%b\n" "${server}" | cut -c 1-2 | uniq | wc -l) # Counts the countries PIA has servers in
tput setaf 2 # Green Text
printf "%b\n" "Checking "${serverCount}" Locations From "${countries}" Countries" # Prints the amount of worldwide servers and countries
tput sgr0 # Reset Terminal Colors
else
# Checks Selected PIA Servers
#------------------------------------------------------------------------------------------------------
server=$(wget -q https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]' | grep "${LOCATION}") # Only check selected country
serverCount=$(printf "%b\n" "${server}" | wc -l) # Count the servers in selected country
tput setaf 3 # Green Text
printf "%b\n" "Checking "${serverCount}" Locations in Selected Country" # Print the number of server locations in selected country
tput sgr0
fi
if [ "${selection}" -ne 0 ]; then
printf "%b\n" "${server}" # Prints the selected server locations
fi
#-----------------------------------------------------------------
#tput cup 0 15
tput setaf 2 # Green Text
printf "%b" "Checking For PIA's Fastest Server...Please Wait." "\n\n"
tput sgr0 # Reset Terminal Colors
printf "%b\n" "${server}" | xargs netselect -s 1 > file1 & SPIN_PID=$! # Pipes each of the servers into Netselect and selects fastest
PBint=2 # Progressbar Speed
spin
wait
disown $SPIN_PID
kill -9 $SPIN_PID
tput sgr0 # Reset Terminal Colors
tput cup 17 0 # Move cursor to line 15 column 0
tput ed # Delete text below cursor
fhostname=$(awk '{print $2}' file1) # Save fastest hostname
printf "%b" "Fastest Hostname ";tput setaf 1; printf "%b" "${fhostname}" "\n"
printf "%b\n"
host "${fhostname}" > file2 # Pipe fastest hostname into the command 'host' to find all IP's for hostname'
IPs=$(awk '{print $4}' file2) # Save IP addresses
cAddresses=$(wc -l file2 | awk '{print $1}') # Count IP addresses
tput sgr0
printf "%b" "${fhostname}";tput setaf 3;printf "%b" " Has "${cAddresses}" Servers For That Hostname" "\n\n" # Print the number of IP addresses
tput sgr0 # Reset Terminal Colors
printf "%b\n" "${IPs}" # Print IP addresses
printf "%b\n"
printf "%b" "Checking For The Fastest IP Address To";tput setaf 2; printf "%b" " "${fhostname}" " "\n\n"
tput setaf 2 # Green Text
printf "%b\n" "${IPs}" | xargs netselect -s 1 > file3 & SPIN_PID=$! # Pipe the saved IP's in Netselect and select fastest IP
PBint=1 # Progressbar Speed
spin
wait
FinalIP=$(awk '{print $2}' file3)
disown $SPIN_PID
kill -9 $SPIN_PID
tput cup 18 0 # Move cursor to line 20 column 0
tput ed # Delete text below cursor
ping -c 10 "${FinalIP}" > file4 & SPIN_PID=$! # Save the average ping time of the fastest IP
printf "%b\n" "Measuring Response Time For The Fastest IP Address"
PBint=.5 # Progressbar Speed
spin
wait
disown $SPIN_PID
kill -9 $SPIN_PID
resptime=$(tail -1 file4 | awk -F '/' '{print $5 "ms"}')
tput cup 18 0 # Move cursor to line 20 column 0
tput ed # Delete text below cursor
printf "%b\n" "==========================================================================="
tput setaf 3 # Yellow Text
printf "%b\n\n" "${FinalIP}" "Is The Fastest IP Address and Has an Avg Response Time Of "${resptime}"" # Print fastest IP and average ping time
tput sgr0
printf "%b\n" "==========================================================================="
printf "%b" "PIA Speed Test Link "; printf "%b\n" http://"${fhostname}":8888/speedtest/
rm file1 file2 file3 file4 2> /dev/null # remove the temporary files
cat <<"EOF"
Select Option:
1. Back To Main Menu
Or
Any Key To Exit / Quit
EOF
read -r -n 1 continue
case "${continue}" in
1)
Main_Menu
;;
*)
tput ech 1
printf "%b\n"
tput cnorm
exit
;;
esac
}
Links(){
tput el1
tput setaf 2 # Green Text
tput cup 16 0 # Move cursor to line 16 column 0
tput ed # Clear all text below cursor
cat <<"EOF"
https://www.privateinternetaccess.com/ PIA Homepage
https://www.privateinternetaccess.com/blog/ PIA News
https://www.privateinternetaccess.com/pages/network/ Server Locations
https://www.privateinternetaccess.com/pages/download Download PIA Client
https://www.privateinternetaccess.com/helpdesk/ Support / Help
https://www.privateinternetaccess.com/pages/how-it-works/ How VPN Packages Work
https://www.facebook.com/privateinternetaccess FACEBOOK
https://twitter.com/buyvpnservice TWITTER
https://www.reddit.com/r/PrivateInternetAccess/ REDDIT
https://www.youtube.com/user/vpnservice/videos YOUTUBE
EOF
tput sgr0 # Reset Terminal Colors
#tput civis
read -r -n 1 -p " Press Any Key To Continue " continue
Main_Menu
}
PIA_Menu() {
tput cup 24 0 # Move cursor to line 22 column 0
tput ed # Delete text below cursor
printf "%b\n"
printf "%b\n" "Checking For VPN Connection"
ValuePIA=$(curl -m 10 -s https://www.privateinternetaccess.com/pages/whats-my-ip/ | grep -c "You are protected") #Check if already connected PIA
if (( "${ValuePIA}" > 0 ))
then
tput cup 17 0 # Move cursor to line 15 column 0
tput ed # Delete text below cursor
tput setaf 3 # Yellow Text
# Warning about slower ping times while being connected to PIA
printf "%b" "You are currently connected to PIA's VPN service.
More realistic results can be achived if you are not connected
to PIA for the \"Fastest Server Check\""
tput sgr0 # reset terminal colors
else
tput cup 17 0 # Move cursor to line 15 column 0
tput ed # Delete text below cursor
fi
# Print PIA country select
printf "%b\n"
cat <<"EOF"
Select Country
1. USA
2. UK
3. Canada
4. Australia
5. New Zealand
6. Germany
7. Hong Kong
8. Japan
9. Israel
0. ALL SERVERS PIA OFFERS
Any Other Key To Main Menu
EOF
# read country selection and wait for a single key press
read -r -n 1 selection
case "${selection}" in
0)
LOCATION=""
;;
1)
LOCATION="us-";;
2)
LOCATION="uk-";;
3)
LOCATION="ca-";;
4)
LOCATION="au-";;
5)
LOCATION="nz.";;
6)
LOCATION="de-";;
7)
LOCATION="hk.";;
8)
LOCATION="japan.";;
9)
LOCATION="israel";;
*)
#clear
#Banner
Main_Menu
tput cup 16 0
tput ed
;;
esac
Server_Check
}
Server_Names() {
# Print PIA country select
tput cup 16 0
tput ed
printf "%b\n"
cat <<"EOF"
Select Country
1. USA
2. UK
3. Canada
4. Australia
5. New Zealand
6. Germany
7. Hong Kong
8. Japan
9. Israel
0. ALL SERVERS PIA OFFERS
Any Other Key To Main Menu
EOF
# read country selection and wait for a single key press
read -r -n 1 selection
case "${selection}" in
0)
LOCATION=""
ActBanner=Yes
;;
1)
LOCATION="us-";;
2)
LOCATION="uk-";;
3)
LOCATION="ca-";;
4)
LOCATION="au-";;
5)
LOCATION="nz.";;
6)
LOCATION="de-";;
7)
LOCATION="hk.";;
8)
LOCATION="japan.";;
9)
LOCATION="israel";;
*)
#clear
#Banner
Main_Menu
tput cup 16 0
tput ed
;;
esac
List_Names
}
List_Names() {
tput cup 16 0
tput ed
if [ "${selection}" -eq 0 ]; then # Zero from PIA_Menu. All servers PIA has
tput sc
tput setaf 3 # Yellow Text
server=$(wget -q https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]' | uniq) # Gets ALL servers
serverCount=$(printf "%b\n" "${server}" | wc -l) # Counts the servers being selected
countries=$(printf "%b\n" "${server}" | cut -c 1-2 | uniq | wc -l) # Counts the countries PIA has servers in
tput setaf 2 # Green Text
printf "%b\n" "Listing "${serverCount}" Locations From "${countries}" Countries" # Prints the amount of worldwide servers and countries
tput sgr0 # Reset Terminal Colors
else
# Checks Selected PIA Servers
#------------------------------------------------------------------------------------------------------
server=$(wget -q https://www.privateinternetaccess.com/pages/network/ -O - | grep -E -o '>[^.]+\.privateinternetaccess\.com<' | tr -d '[<>]' | grep "${LOCATION}") # Only check selected country
serverCount=$(printf "%b\n" "${server}" | wc -l) # Count the servers in selected country
tput setaf 3 # Green Text
printf "%b\n" "Listing "${serverCount}" Locations in Selected Country" # Print the number of server locations in selected country
tput sgr0
fi
if [ "${selection}" -eq 0 ]; then
printf "%b\n\n" "${server}" | pr -ts" " --columns 2 | column -t # Prints the selected server locations
else
printf "%b\n\n" "${server}" # Prints the selected server locations
fi
printf "%b\n\n"
read -r -n 1 -p " Press Any Key To Continue " continue
if [ "${ActBanner}" = Yes ]; then
tput rc
Banner
fi
Main_Menu
}
Speed_Test() {
tput cup 16 0
tput ed
PIAconnect=$(curl -m 5 -s https://www.privateinternetaccess.com/pages/whats-my-ip/ | grep -c "You are protected")
if (( "${PIAconnect}" > 0 )) ; then
printf "%b\n" "${CHECKMARK}$(tput setaf 2) This Speed Test is with PIA VPN Active"
else
printf "%b\n" "${XMARK}$(tput setaf 1) This Speed Test is with PIA VPN Inactive"
fi
tput sgr0 # Reset Terminal Colors
cat <<"EOF"
Select Download Size
1. 10 MB
2. 20 MB
3. 50 MB
4. 100 MB
5. 200 MB
6. 400 MB
7. Main Menu
EOF
read -r -n 1 size
case "${size}" in
1)
FileSize="10"
;;
2)
FileSize="20"
;;
3)
FileSize="50"
;;
4)
FileSize="100"
;;
5)
FileSize="200"
;;
6)
FileSize="400"
;;
*)
Main_Menu
;;
esac
tput cup 17 0
tput ed
printf "%b" "Download "${FileSize}"MB File From?" "\n"
cat <<"EOF"
1. USA
2. UK
3. Germany
4. Netherlands
5. Canada
6. Singapore
7. Italy
8. Japan
9. Australia
0. Auto Select Fastest Location
EOF
printf "%b\n\n"
read -r -n 1 location
case "${location}" in
1)
URL="http://cachefly.cachefly.net/200mb.test"
#URL="http://mirror.sfo12.us.leaseweb.net/speedtest/1000mb.bin"
LOC="USA"
;;
2)
URL="http://ipv4.download.thinkbroadband.com/512MB.zip"
LOC="United Kingdom"
;;
3)
URL="https://speed.hetzner.de/1GB.bin"
LOC="Germany"
;;
4)
URL="https://iperf.worldstream.nl/1000mb.bin"
LOC="Netherlands"
;;
5)
URL="http://ca-mr2-smart.serverlocation.co:82/1Gio.dat"
LOC="Canada"
;;
6)
URL="http://sg-smart.serverlocation.co:82/1Gio.dat"
LOC="Singapore"
;;
7)
URL="http://it-ml-smart.serverlocation.co:82/1Gio.dat"
LOC="Italy"
;;
8)
URL="http://jp-tk-smart.serverlocation.co:82/1Gio.dat"
LOC="Japan"
;;
9)
URL="http://au-sy.serverlocation.co:82/1Gio.dat"
LOC="Australia"
;;
0)
Autoselect
URL=${BestDL}
;;
*)
Main_Menu
;;
esac
#tput cup 41 0
tput cup 17 0
tput ed
tput sgr0
printf "%s\n" "Downloading "${FileSize}"MB's From ${LOC} "
#tput cup 43 0
tput cup 19 0
tput ed
printf "%b\n" $(dirname "${URL}")
tput setaf 3
DLspeed=$(printf "%b" "scale=2; " && curl --progress-bar --connect-timeout 10 -o /dev/null -r 0-"${FileSize}"000000 "${URL}" -w "%{speed_download}" | sed "s/\,/\./g" && echo "/1048576");
tput setaf 5
printf "%b\n" "${DLspeed}" | bc -q | sed "s/$/ MB\/sec/;s/^/\tDownload Speed\: /";
tput sgr0
printf "%b\n"
read -r -n 1 -p " Press Any Key To Continue " continue
Main_Menu
}
# Auto select the fastest speed test file download site
Autoselect() {
tput cup 17 0
tput ed
printf "%b\n" "Auto Selecting Fastest Location....Please wait"
declare -a arr=(
http://ipv4.download.thinkbroadband.com/512MB.zip
https://speed.hetzner.de/1GB.bin
http://cachefly.cachefly.net/400mb.test
https://iperf.worldstream.nl/1000mb.bin
http://ca-mr2-smart.serverlocation.co:82/1Gio.dat
http://sg-smart.serverlocation.co:82/1Gio.dat
http://it-ml-smart.serverlocation.co:82/1Gio.dat
http://jp-tk-smart.serverlocation.co:82/1Gio.dat
http://au-sy.serverlocation.co:82/1Gio.dat
)
#-----------------------------------------------------------------
netselect "${arr[@]}" | awk '{print $2}' > file5 & SPIN_PID=$!
PBint=1
spin
wait
disown $SPIN_PID
kill -9 $SPIN_PID
BestDL=$(cat file5)
rm file5 2> /dev/null
if
[ "${BestDL}" = http://ipv4.download.thinkbroadband.com/512MB.zip ]; then
LOC="United Kingdom"
elif
[ "${BestDL}" = http://cachefly.cachefly.net/400mb.test ]; then
LOC="USA"
elif
[ "${BestDL}" = https://speed.hetzner.de/1GB.bin ]; then
LOC="Germany"
elif
[ "${BestDL}" = https://iperf.worldstream.nl/1000mb.bin ]; then
LOC="Netherlands"
elif
[ "${BestDL}" = http://ca-mr2-smart.serverlocation.co:82/1Gio.dat ]; then
LOC="Canada"
elif
[ "${BestDL}" = http://sg-smart.serverlocation.co:82/1Gio.dat ]; then
LOC="Singapore"
elif
[ "${BestDL}" = http://it-ml-smart.serverlocation.co:82/1Gio.dat ]; then
LOC="Italy"
elif
[ "${BestDL}" = http://jp-tk-smart.serverlocation.co:82/1Gio.dat ]; then
LOC="Japan"
elif
[ "${BestDL}" = http://au-sy.serverlocation.co:82/1Gio.dat ]; then
LOC="Australia"
else
tput setaf 1 # Red Text
printf "%b\n\n" "Unable to determine the fastest location. Manual Selection Required"
tput sgr0
rm file5 2> /dev/null
read -r -n 1 -p " Press Any Key To Continue " continue
Speed_Test
fi
}
Location_Check(){
tput cup 16 0
tput el1
tput ed
printf "%b\n"
printf "%b\n" "Checking IP & Location Information"
PIAconnect=$(curl -m 5 -s https://www.privateinternetaccess.com/pages/whats-my-ip/ | grep -c "You are protected")
if (( "${PIAconnect}" > 0 )) ; then
tput setaf 2 # Green Text
printf "%b\n" "✔ You are Protected With PIA ✔"
else
tput setaf 1 # Red Text
printf "%b\n" "❌ You are NOT Protected With PIA ❌"
fi
tput sgr0 # Reset Terminal Colors
MYIP=$(curl -s -4 https://icanhazip.com)
if [[ "${MYIP}" =~ ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
MYIP="${MYIP}"
fi
if [[ "${MYIP}" =~ ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
MYIP="${MYIP}"
else
MYIP=$(curl -s ifconfig.me)
fi
if [[ "${MYIP}" =~ ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
MYIP="${MYIP}"
else
MYIP=$(curl -s https://ipinfo.io/ip)
fi
if [[ "${MYIP}" =~ ^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
MYIP="${MYIP}"
else
printf "%b\n" "Unable to Find Valid Information"
#printf "%b\n" "${MYIP}"
read -r -n 1 -p " Press Any Key To Continue " continue
Main_Menu
fi
curl -s http://ip-api.com/json/${MYIP} | jq -r . | tr -d '"{},' | column -t -s : | tail -n+2
#curl -s https://ipx.ac/json | jq -r '"IP Address : " + .ip,"IP Type: " + .geo.usage, "Network: " + .p0f.network_link, "Domain Name: " + .geo.domainName, "City: " + .geo.cityName, "State: " + .geo.regionName, "Country: " + .geo.countryName, "UTC Offset: " + .timezone, "Lat / Lon: " + "\(.geo.latitude)" + "," + "\(.geo.longitude)", "Provider: " + .geo.isp, "Hostname: " + .ptr, "ASN: " + .asn' | column -s: -t
#curl -s https://ipapi.co/${MYIP}/json/ | jq -r '"IP : " + .ip, "City: " + .city, "State: " + .region, "Country: " + .country_name, "TimeZone: " + .timezone, "UTC Offset: " + .utc_offset, "Location: " + "\(.latitude)" + "," + "\(.longitude)", "Provider: " + .org' | column -s: -t
# curl https://ipapi.co/${MYIP}/json/
# curl -s "http://ipinfo.io/" | awk -F\" '{print $2":",$4}' | sed 's/[",]//g' | sed '1d;$d' | sed -e "s/\b\(.\)/\u\1/g" | column -s: -t
# curl -s http://ip-api.com/#"${MYIP}" | sed 's/[",{}]//g'
# MYIP=$(curl -s "http://ipinfo.io/" | awk -F\" '{print $4}' | head -n2 | tail -n1)
# LATLON=$(curl -s https://ipapi.co/ | grep 'Latitude / Longitude' | sed 's/.*\-text="//;s/">.*//' | tr -d ' ')
# MAP1=$(curl -m 5 -s http://ping.pe/"${MYIP}" | grep -E "https:\/\/www\.google\.com\/maps\/place\/" | sed 's/.*href=\(.*\)>MAP<\/a><\/b><br><br>/\1/' | tr -d \'\")
# MAP3='https://www.geolocation.com/?ip='${MYIP}''
LATLON=$(curl -s https://ipapi.co/latlong/)
LATLON2=$(printf ${LATLON} | sed 's/,/\//g') # Replace the , with a / for use with OpenStreetMaps
MAP4='www.google.com/maps/@'${LATLON}',10z'
MAP5='https://www.whatsmyip.org/ip-geo-location/?ip='${MYIP}
MAP6='https://www.openstreetmap.org/#map=12/'${LATLON2}
printf "%b\n"
tput sgr0
printf "%b" "Location Map ";tput setaf 2; printf "%b" ${MAP4} "\n"
tput sgr0
printf "%b" "Location Map ";tput setaf 2; printf "%b" ${MAP5} "\n"
tput sgr0
printf "%b" "Location Map ";tput setaf 2; printf "%b" ${MAP6} "\n"
printf "%b\n\n"
tput setaf 3
printf "%b\n" "Is the Server Really where you think it is?
Open the link below and wait for the lowest ping times.
If your server is near that location you can be reasonably
sure its not a \"Virtual Server\" but real hardware in that area.
"
tput setaf 2
printf "%b" 'http://ping.pe/'${MYIP} "\n\n\n"
tput sgr0
read -r -n 1 -p " Press Any Key To Continue " continue
tput cup 16 0
tput el1
tput ed
Main_Menu
}
LeakTest(){
tput cup 16 0
tput el1
tput ed
#printf "%b\n"
printf "%b" "Scanning For DNS Leaks." "\n"
for run in {1..20}
do
dig +short txt whoami.ds.akahelp.net | tr -d '[ ] [ns] ["] [ecs] [ip] []' >> DNS.txt