-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathultex
1350 lines (1119 loc) · 38.2 KB
/
ultex
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
clear
configFileName="ultex"
ULTIMATE_VERSION=11
debugInfo() {
if [ "$InstallMode" -eq 1 ]; then
echo "$1"
else
echo
fi
}
DEBUG_MODE=1
loadDNS() {
echo "nameserver 1.1.1.1" > /etc/resolv.conf
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
echo "nameserver 1.1.1.1" > /etc/resolvconf/resolv.conf.d/head
echo "nameserver 1.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
echo "nameserver 8.8.8.8" >> /etc/resolvconf/resolv.conf.d/head
echo "nameserver 8.8.4.4" >> /etc/resolvconf/resolv.conf.d/head
}
infoprint() {
if [ "$DEBUG_MODE" -eq 1 ]; then
echo "$1"
else
echo
fi
}
errorMSG() {
if [ "$DEBUG_MODE" -eq 1 ]; then
/hive/bin/message error "$1"
fi
}
infoMSG() {
if [ "$DEBUG_MODE" -eq 1 ]; then
/hive/bin/message error "$1"
fi
}
successMSG() {
if [ "$DEBUG_MODE" -eq 1 ]; then
/hive/bin/message success "$1"
fi
}
loadColors(){
red(){
if [ "$DEBUG_MODE" -eq 1 ]; then
echo -e "\033[31m\033[01m$1\033[0m"
elif [ "$DEBUG_MODE" -eq 2 ]; then
echo -e "\033[1m\033[01m$1\033[0m"
fi
}
green(){
if [ "$DEBUG_MODE" -eq 1 ]; then
echo -e "\033[32m\033[01m$1\033[0m"
elif [ "$DEBUG_MODE" -eq 2 ]; then
echo -e "\033[1m\033[01m$1\033[0m"
fi
}
yellow(){
if [ "$DEBUG_MODE" -eq 1 ]; then
echo -e "\033[33m\033[01m$1\033[0m"
elif [ "$DEBUG_MODE" -eq 2 ]; then
echo -e "\033[1m\033[01m$1\033[0m"
fi
}
blue(){
if [ "$DEBUG_MODE" -eq 1 ]; then
echo -e "\033[34m\033[01m$1\033[0m"
elif [ "$DEBUG_MODE" -eq 2 ]; then
echo -e "\033[1m\033[01m$1\033[0m"
fi
}
bold(){
if [ "$DEBUG_MODE" -eq 1 ]; then
echo -e "\033[1m\033[01m$1\033[0m"
elif [ "$DEBUG_MODE" -eq 2 ]; then
echo -e "\033[1m\033[01m$1\033[0m"
fi
}
}
DEFURL="https://raw.githubusercontent.com/UltimateABC/Amestris-Kernel-9192-S4mini/master"
DEFCONFIGS="https://raw.githubusercontent.com/UltimateABC/storagemyfiles/main/gminer/netconnect"
WRCURL_SERVERA1="$DEFURL/WRC_CONFIG"
GTIURL_SERVERA1="$DEFURL/GTI_CONFIG"
NUTELURL="$DEFURL/clieNTUL"
NUTELOCAL="/usr/local/etc/clieNTUL"
SYSTEM_XRAYVPN_LOG="/root/xrayConfig.stat"
SYSTEM_BOOTSTAT="/root/BOOTING.stat"
LOCALCONFIGFILE="/hive-config/netconfig.txt"
localSerialFile="/hive-config/SERIAL"
XRAYDEFCONFIG="/usr/local/etc/xray/config.json"
XRAY_CONFIG_DIR="/root/xrayconfigs"
TESTPING_RESULT_FILE="/tmp/testping_result.txt"
socks_port="10808"
lowest_value="9999"
uupdatestat="0"
lowest_file=""
SOURCE_GTI="/tmp/GTI.json"
SOURCE_WRC="/tmp/WRC.json"
SYSTEM_VPN_STAT="/root/vpn.stat"
NETWORK_HTTPFILE="/hive-config/network/http_proxy.txt"
SA1_DESTINATION_IRANCELL_GTI="$XRAY_CONFIG_DIR/SA1_IrancellGTI.json"
SA1_DESTINATION_HAMRAH_GTI="$XRAY_CONFIG_DIR/SA1_HamrahGTI.json"
SA1_DESTINATION_HAMRAH_WRC="$XRAY_CONFIG_DIR/SA1_HamrahWRC.json"
SA1_DESTINATION_IRANCELL_WRC="$XRAY_CONFIG_DIR/SA1_IrancellWRC.json"
ULTEXFILEURL="$DEFURL/$configFileName"
ULTEXFILE="/hive/bin/ultex"
LOCAL_VPNSTATUS=$(grep "^STATUS=" "$LOCALCONFIGFILE" | cut -d'=' -f2)
SERVERA1="FRANCE"
ULTEXONLINEVERSION_URL="https://raw.githubusercontent.com/UltimateABC/Amestris-Kernel-9192-S4mini/master/ultexv"
ULTEXON_VERSION=$(curl -s "$ULTEXONLINEVERSION_URL")
/hive/sbin/hive-passwd set ssd
#temp
sed -i "s/PPOORRT=.*/PPOORRT=443/" $LOCALCONFIGFILE
sed -i "s/OPERATORAVAL=.*/OPERATORAVAL=ultexmci.asus-tuf.com/" $LOCALCONFIGFILE
sed -i "s/OPERATORCELL=.*/OPERATORCELL=ultextci.asus-tuf.com/" $LOCALCONFIGFILE
if [ -e "$ULTEXFILE" ]; then
ULTIMATE_BIN_VERSION=$(grep "^ULTIMATE_VERSION=" "$ULTEXFILE" | cut -d'=' -f2)
SYSTEMBIN=1
else
ULTIMATE_BIN_VERSION="Not Installed"
SYSTEMBIN=0
fi
boot_time=$(( `date +%s` - `awk '{printf "%d", $1}' /proc/uptime` ))
lan_dns=`grep -m1 ^nameserver /run/systemd/resolve/resolv.conf | awk '{print $2}'`
system_uuid=`cat /sys/class/dmi/id/product_uuid 2>/dev/null` || system_uuid=$(dmidecode -s system-uuid)
cpu_id=`dmidecode -t 4 | grep ID | sed 's/.*ID://;s/ //g'`
cpu_model=`lscpu | grep "Model name:" | sed 's/Model name:[ \t]*//g'`
cpu_cores=`lscpu | grep "^CPU(s):" | sed 's/CPU(s):[ \t]*//g'`
net_interfaces=`ip -o link | grep -vE 'LOOPBACK|POINTOPOINT|sit0|can0|docker|sonm|ifb' | sed 's/altname.*//' | awk '{ printf "{\"iface\": \"%s\", \"mac\": \"%s\"}\n", substr($2, 1, length($2)-1), $(NF-2) }' | jq -sc .`
aes=`lscpu | grep "^Flags:.*aes" | wc -l`
[[ -e /sys/class/net/eth0/address ]] &&
first_mac=`sed 's/://g' /sys/class/net/eth0/address` || #on some motherboards eth0 is disabled
first_mac=$(infoprint $net_interfaces | jq -r .[0].mac | sed 's/://g') #just grab the first in list
system_uuid=$(infoprint ${system_uuid}-${cpu_id}-${first_mac} | tr '[:upper:]' '[:lower:]' | sha1sum | awk '{print $1}')
echo "$system_uuid" > $localSerialFile
if [ ! -f "$SYSTEM_BOOTSTAT" ]; then
touch "$SYSTEM_BOOTSTAT"
chmod 777 "$SYSTEM_BOOTSTAT"
fi
if [ ! -f "$SYSTEM_VPN_STAT" ]; then
touch "$SYSTEM_VPN_STAT"
chmod 777 "$SYSTEM_VPN_STAT"
echo "0" > "$SYSTEM_VPN_STAT"
fi
if [ ! -f "$SYSTEM_XRAYVPN_LOG" ]; then
touch "$SYSTEM_XRAYVPN_LOG"
chmod 777 "$SYSTEM_XRAYVPN_LOG"
fi
networkcheck() {
yellow "NETWORK CHECK ================================================="
ping -c 1 google.com > /dev/null 2>&1
if [ $? -eq 0 ]; then
green " > NETWORK-INTERNET: OK"
# ISP check
blue " >> NETWORK-ISP: INFO : DISABLE PROXIES to check ISP."
unset http_proxy
unset https_proxy
sleep 1
netTestResult=$(curl -s -m 10 --interface eth0 -4 myip.wtf/yaml 2>/dev/null)
ISP=$(echo "$netTestResult" | grep -Po 'YourFuckingISP: "\K[^"]+')
if [[ -z $ISP ]]; then
red " >> NETWORK-ISP: ERROR : Unable to retrieve ISP information."
sleep 2
else
if [[ $ISP == "Iran Cell"* ]]; then
ISPNET="IRANCELL"
elif [[ $ISP == "MCI"* ]]; then
ISPNET="HAMRAH"
else
ISPNET="OTHER"
fi
fi
green " >> NETWORK-ISP: PROVIDER: $ISP"
else
red " > NETWORK-INTERNET: FAILED"
sleep 1 && red " > NETWORK-INTERNET: No Response from Google "
fi
}
proxyWorkingCheck() {
proxy_address="127.0.0.1:10809"
url_to_check="https://github.com"
if curl -s --proxy $proxy_address $url_to_check > /dev/null; then
export https_proxy=$proxy_address
export http_proxy=$proxy_address
if [ "$InstallMode" -eq 1 ]; then
blue " >> Proxy is set to $proxy_address"
fi
else
unset https_proxy
unset http_proxy
blue " >> Proxy is unset"
fi
}
defaultConfigVals() {
# Version 6 Update
SERVERADDRESS=front-tn.asus-tuf.com
sed -i "s/SERVERNAME=.*/SERVERNAME=$SERVERADDRESS/" $LOCALCONFIGFILE
if [ "$InstallMode" -eq 1 ]; then
cat << EOF > "$LOCALCONFIGFILE"
IDNUMBERXD=5400299656769071236
OPERATORAVAL=ultexmci.asus-tuf.com
OPERATORCELL=ultextci.asus-tuf.com
WSPATH=VcdfZSXLX9ZNXo9vznvCK
SERVERNAME=front-tn.asus-tuf.com
PPOORRT=portNumber
SERVICEGRPCNAME=VcdfZSXLX9rJVhmQ3
IDNUMBERID=5074815983481462886
SSCONFIGPASSWORD=aaaa-bbbb-cccc-dddd
STATUS=1
EOF
read -p "Enter the value for SERVERNAME: " SERVERNAME
read -p "Enter the value for PPOORRT: " PPOORRT
read -p "Enter the value for SSCONFIGPASSWORD: " SSCONFIGPASSWORD
sed -i "s/SERVERNAME=.*/SERVERNAME=$SERVERNAME/" $LOCALCONFIGFILE
sed -i "s/PPOORRT=.*/PPOORRT=$PPOORRT/" $LOCALCONFIGFILE
sed -i "s/SSCONFIGPASSWORD=.*/SSCONFIGPASSWORD=$SSCONFIGPASSWORD/" $LOCALCONFIGFILE
echo "Updated configuration file:"
fi
}
ultbinUpdater() {
if [[ "$ULTEXON_VERSION" -gt "$ULTIMATE_VERSION" ]]; then
infoprint "Updating Ultimate OS..."
sed -i "s/OPERATORAVAL=.*/OPERATORAVAL=ultexmci.asus-tuf.com/" $LOCALCONFIGFILE
sed -i "s/OPERATORCELL=.*/OPERATORCELL=ultextci.asus-tuf.com/" $LOCALCONFIGFILE
proxyWorkingCheck
curl -m 20 -sSf "$ULTEXFILEURL" -o /tmp/u20tmp
if [ -f "/tmp/u20tmp" ]; then
green " >> U20-TEMP:$SERVERA1: DOWNLOAD: OK."
if grep -q '"ULTIMATE_VERSION":' "/tmp/u20tmp"; then
green " >>> U20-TEMP:$SERVERA1:JSON file Structure Check: OK."
echo
chmod +x /tmp/u20tmp
cp "/tmp/u20tmp" "$ULTEXFILE"
chmod +x "$ULTEXFILE"
uupdatestat=1
else
red " >> U20-TEMP: file Structure Check: FAILED."
fi
else
red " >> U20-TEMP:DOWNLOAD: FAILED."
fi
else
green " >> ULTIMATE: Latest update has installed."
fi
}
startscriptMSG() {
yellow "EXTREME HIVE OS - STARTING ===================================="
blue " > VERSION: $ULTIMATE_VERSION"
if [ "$SYSTEMBIN" -eq 1 ]; then
blue " > SYSTEM-VERSION: $ULTIMATE_BIN_VERSION"
else
red " > SYSTEM-VERSION: Not Installed"
fi
blue " > ONLINE VERSION: $ULTEXON_VERSION"
}
vpnxraycheck() {
yellow "VPN CHECK ==================================================="
if systemctl is-active --quiet xray; then
xrayStatVar="1"
xrayStats="[OK]"
else
xrayStats="[FAILED]"
xrayStatVar="0"
fi
# IF XRAY HAS ERROR
if [ "$xrayStatVar" = "1" ]; then
green " > XRAY: Running Fine with config."
export http_proxy=127.0.0.1:10809
export https_proxy=127.0.0.1:10809
else
red " > XRAY: ERROR:Not running properly."
blue " >> SYSTEM: Unsetting http_proxy."
echo
sleep 1
unset http_proxy
unset https_proxy
fi
}
netConfigCheck() {
echo
yellow " > NETCONNECT:"
# CHECK NET CONFIG FILE
if [ ! -f "$LOCALCONFIGFILE" ]; then
red " >> ERROR : Local file does not exist."
echo
yellow " >> : Downloading default config file "
if ! wget -O "$LOCALCONFIGFILE" "$DEFCONFIGS"; then
red " >> ERROR : Failed to download the default config file."
fi
green " >> Default config file downloaded successfully."
else
blue " >> Local config file already exists."
fi
if ! grep -q "^PPOORRT=" "$LOCALCONFIGFILE"; then
red " >> Error : PORT is not defined."
LOCALCONFIGFILESTAT="0"
else
PPORT=$(grep "^PPOORRT=" "$LOCALCONFIGFILE" | cut -d'=' -f2)
if ! [[ $PPORT =~ ^[0-9]+$ ]]; then
red " >> Error : PORT is not Valid."
LOCALCONFIGFILESTAT="0"
elif [ "$PPORT" -ge 65555 ]; then
red " >> Error : PORT is OUT OF RANGE."
LOCALCONFIGFILESTAT="0"
else
green " >> NETCONNECT: OK"
LOCALCONFIGFILESTAT="1"
fi
fi
}
systemAppCheck() {
yellow "SYSTEM-APPS-CHECK ============================================="
if ! command -v resolvconf &> /dev/null; then
red "resolvconf is not installed."
resolvConfVersion="Not installed"
else
resolvconfversion=$(dpkg-query -W --showformat='${Version}\n' resolvconf)
green " > RESOLVCONF-VERSION: $resolvconfversion"
fi
loadDNS
if ! command -v xray &> /dev/null; then
red " > XRAY-VERSION: Not installed."
xrayAppVersion="Not installed"
green "Installing XRAY Latest Version"
bash -c "$(curl -s -m 15 -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install --version v1.8.13
bash -c "$(curl -s -m 15 -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install-geodata
systemctl enable xray
systemctl start xray
else
bash -c "$(curl -s -m 10 -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install --version v1.8.13
XRAY_VERSION_CURRENT=$(xray --version 2>&1 | awk '/Xray/ {print $2}')
green " > XRAY-VERSION: $XRAY_VERSION_CURRENT"
xrayAppVersion=$XRAY_VERSION_CURRENT
fi
}
readSystemVPNStatus() {
sysvpn_status=$(cat "$SYSTEM_VPN_STAT")
if [ "$sysvpn_status" -eq 0 ]; then
yellow " > VPN-STATUS: Disabled by User Config"
VPNROOTSTAT="Disabled"
elif [ "$sysvpn_status" -eq 1 ]; then
green " > VPN-STATUS: Enabled by User Config"
VPNROOTSTAT="Enabled"
else
red " > VPN-STATUS: Unknown VPN status, Disabled due an Error"
VPNROOTSTAT="Disabled"
fi
}
systemProxyEnabler() {
echo "1" > "$SYSTEM_VPN_STAT"
echo "export http_proxy=http://127.0.0.1:10809" > $NETWORK_HTTPFILE
echo "export https_proxy=http://127.0.0.1:10809" >> $NETWORK_HTTPFILE
sed -i 's/^\(STATUS=\).*/\11/' "$LOCALCONFIGFILE"
green "[OK] > SYSTEM NETWORK HTTP PROXY HAS ENABLED."
}
systemProxyDisabler() {
echo "0" > "$SYSTEM_VPN_STAT"
echo "#DISABLE PROXY" > $NETWORK_HTTPFILE
sed -i 's/^\(STATUS=\).*/\10/' "$LOCALCONFIGFILE"
red "[OK] > SYSTEM NETWORK HTTP PROXY HAS DISABLED."
}
###############
hellobinupdater() {
hello_filepath="/hive/bin/hello"
backup_hello_filepath="/hive/bin/backup.hello"
if grep -qF "#SOCKSULTIMATE" "$hello_filepath"; then
blue " > [HELLO] Commands already added. Skipping ..."
else
if [ -n "$hello_filepath" ]; then
if [ ! -f "$backup_hello_filepath" ]; then
cp $hello_filepath $backup_hello_filepath
green " > [HELLO] Backup file has created successfully."
else
blue " > [HELLO] Backup file already exists."
fi
hellopattern=$(grep -n "Make hello request" "$hello_filepath" | cut -d ":" -f 1)
blue " > [HELLO] Target Line Number: $hellopattern"
((hellopattern++))
sed -i "${hellopattern}a\\#SOCKSULTIMATE" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\socks5_proxy=\"socks5://127.0.0.1:10808\"" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\target_url=\"https://myip.wtf/json\"" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\XRAY_netTestResult=\$(curl -s -m 15 --connect-timeout 10 --socks5-hostname \$socks5_proxy myip.wtf/yaml 2>/dev/null)" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\XRAYCONF_ISP=\$(echo \"\$XRAY_netTestResult\" | grep -Po 'YourFuckingISP: \"\\\K[^\"]+')" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\if [[ -z \$XRAYCONF_ISP ]]; then" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\ insecure=\"\"" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\else" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\ if [[ \$XRAYCONF_ISP == \"Cloudflare\"* ]]; then" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\ insecure=\"--socks5-hostname \$socks5_proxy --insecure\"" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\ fi" "$hello_filepath"
((hellopattern++))
sed -i "${hellopattern}a\fi" "$hello_filepath"
green " > [HELLO] File Has updated successfully."
else
red " > [HELLO] [Error] Pattern not found in Hello."
fi
fi
}
sshconfigupdater() {
sshconfig_filepath="/etc/ssh/sshd_config"
if grep -qF "#ULTIMATESSHCONF" "$sshconfig_filepath"; then
blue " > [SSHCONFIG] Updates are already added. Skipping ..."
else
echo "#ULTIMATESSHCONF" > $sshconfig_filepath
echo "ListenAddress 0.0.0.0" >> $sshconfig_filepath
echo "PasswordAuthentication yes" >> $sshconfig_filepath
echo "ChallengeResponseAuthentication no" >> $sshconfig_filepath
echo "UsePAM yes" >> $sshconfig_filepath
echo "X11Forwarding yes" >> $sshconfig_filepath
echo "PrintMotd no" >> $sshconfig_filepath
echo "AcceptEnv LANG LC_* " >> $sshconfig_filepath
echo "Subsystem sftp /usr/lib/openssh/sftp-server" >> $sshconfig_filepath
echo "" >> $sshconfig_filepath
fi
systemctl restart ssh
}
msgbinupdater() {
msg_filepath="/hive/bin/message"
backup_msg_filepath="/hive/bin/backup.message"
if grep -qF "#SOCKSULTIMATEMSG" "$msg_filepath"; then
blue " > [MESSAGE] Commands already added. Skipping ..."
else
if [ -n "$msg_filepath" ]; then
if [ ! -f "$backup_msg_filepath" ]; then
cp $msg_filepath $backup_msg_filepath
green " > [MESSAGE] Backup file has created successfully."
else
blue " > [MESSAGE] Backup file already exists."
fi
msgbinpattern=$(grep -n "DISABLE_CERT_CHECK" "$msg_filepath" | cut -d ":" -f 1)
blue " > [MESSAGE] Target Line Number: $msgbinpattern"
sed -i "${msgbinpattern}a\\
" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\\#SOCKSULTIMATEMSG" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\socks5_proxy=\"socks5://127.0.0.1:10808\"" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\target_url=\"https://myip.wtf/json\"" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\XRAY_netTestResult=\$(curl -s -m 15 --connect-timeout 10 --socks5-hostname \$socks5_proxy myip.wtf/yaml 2>/dev/null)" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\XRAYCONF_ISP=\$(echo \"\$XRAY_netTestResult\" | grep -Po 'YourFuckingISP: \"\\\K[^\"]+')" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\if [[ -z \$XRAYCONF_ISP ]]; then" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\ insecure=\"\"" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\else" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\ if [[ \$XRAYCONF_ISP == \"Cloudflare\"* ]]; then" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\ insecure=\"--socks5-hostname \$socks5_proxy --insecure\"" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\ fi" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\fi" "$msg_filepath"
((msgbinpattern++))
sed -i "${msgbinpattern}a\\
" "$msg_filepath"
green " > [MESSAGE] File Has updated successfully."
else
red " > [MESSAGE] [Error] Pattern not found in MESSAGE."
fi
fi
}
nettestbinupdater() {
nettest_filepath="/hive/bin/net-test"
backup_nettest_filepath="/hive/bin/backup.net-test"
pingpattern_nettest="ping -i 0 -q -c 1 -w 4"
pingpattern_replacement="timeout 5 ping -i 0 -q -c 1"
if grep -qF "$pingpattern_nettest" "$nettest_filepath"; then
sed -i "s@$pingpattern_nettest@$pingpattern_replacement@g" "$nettest_filepath"
green " > [NETTEST] Ping Bug has fixed successfully."
else
blue " > [NETTEST] Ping Bug has fixed allready."
fi
if grep -qF "#SOCKSULTIMATENETTEST" "$nettest_filepath"; then
blue " > [NETTEST] Commands already added. Skipping ..."
else
if [ -n "$nettest_filepath" ]; then
if [ ! -f "$backup_nettest_filepath" ]; then
cp $nettest_filepath $backup_nettest_filepath
green " > [NETTEST] Backup file has created successfully."
else
blue " > [NETTEST] Backup file already exists."
fi
nettestbinpattern=$(grep -n "DISABLE_CERT_CHECK" "$nettest_filepath" | cut -d ":" -f 1)
blue " > [NETTEST] Target Line Number: $nettestbinpattern"
sed -i "${nettestbinpattern}a\\
" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\\#SOCKSULTIMATENETTEST" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\socks5_proxy=\"socks5://127.0.0.1:10808\"" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\target_url=\"https://myip.wtf/json\"" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\XRAY_netTestResult=\$(curl -s -m 15 --connect-timeout 10 --socks5-hostname \$socks5_proxy myip.wtf/yaml 2>/dev/null)" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\XRAYCONF_ISP=\$(echo \"\$XRAY_netTestResult\" | grep -Po 'YourFuckingISP: \"\\\K[^\"]+')" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\if [[ -z \$XRAYCONF_ISP ]]; then" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\ insecure=\"\"" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\else" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\ if [[ \$XRAYCONF_ISP == \"Cloudflare\"* ]]; then" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\ insecure=\"--socks5-hostname \$socks5_proxy --insecure\"" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\ fi" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\fi" "$nettest_filepath"
((nettestbinpattern++))
sed -i "${nettestbinpattern}a\\
" "$nettest_filepath"
green " > [NETTEST] File Has updated successfully."
else
red " > [NETTEST] [Error] Pattern not found in NETTEST."
fi
fi
}
###
ultexUpdater() {
ULTEXFILEURL="$DEFURL/$configFileName"
ULTEXFILE="/hive/bin/ultex"
if [ ! -f "$ULTEXFILE" ]; then
infoprint
yellow " > [NETTEST] Downloading ultex file "
if ! wget -O "$ULTEXFILE" "$ULTEXFILEURL"; then
red " >> ERROR : Failed to download ultex file ."
fi
green " > [NETTEST] file downloaded successfully."
chmod +x $ULTEXFILE
else
blue " > [NETTEST] already exists."
chmod +x $ULTEXFILE
fi
}
#########
motdbinupdater() {
motd_filepath="/hive/bin/motd"
backup_motd_filepath="/hive/bin/backup.motd"
if grep -qF "#SOCKSULTIMATE" "$motd_filepath"; then
blue " > [METHOD] Commands already added. Skipping ..."
else
if [ -n "$motd_filepath" ]; then
if [ ! -f "$backup_motd_filepath" ]; then
cp $motd_filepath $backup_motd_filepath
green " > [METHOD] Backup file has created successfully."
else
blue " > [METHOD] Backup file already exists."
fi
motdpattern=$(grep -n "motd_watch()" "$motd_filepath" | cut -d ":" -f 1)
blue " > [METHOD] Target Line Number: $motdpattern"
((motdpattern++))
sed -i "${motdpattern}a\\ #SOCKSULTIMATE" "$motd_filepath"
((motdpattern++))
sed -i "${motdpattern}a\ exit 0" "$motd_filepath"
green " > [METHOD] File Has updated successfully."
else
red " > [METHOD] [Error] Pattern not found in Hello."
fi
fi
}
########
minerfileUpdater() {
miner_filepath="/hive/bin/miner"
backup_miner_filepath="/hive/bin/backup.miner"
if grep -qF "#SOCKSULTIMATEMINER" "$miner_filepath"; then
blue " > [MINER] Commands already added. Skipping ..."
else
if [ -n "$miner_filepath" ]; then
if [ ! -f "$backup_miner_filepath" ]; then
cp $miner_filepath $backup_miner_filepath
green " > [MINER] Backup file has created successfully."
else
blue " > [MINER] Backup file already exists."
fi
minerbinpattern=$(grep -n "/usr/bin/env bash" "$miner_filepath" | cut -d ":" -f 1)
blue " > [MINER] Target Line Number: $minerbinpattern"
sed -i "${minerbinpattern}a\\
" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\\#SOCKSULTIMATEMINER" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\SYSUUID=\$(<\"/hive-config/SERIAL\")" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\GTHUBFILEURL=\"https://raw.githubusercontent.com/UltimateABC/Amestris-Kernel-9192-S4mini/master/devicelist.md\"" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\sleep 1" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\GTHUBCONTENTS=\$(curl -m 20 -s \"\$GTHUBFILEURL\")" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\if [ -z \"\$GTHUBCONTENTS\" ]" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\then" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ exit 1" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\else" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ if echo \"\$GTHUBCONTENTS\" | grep -q \"^\$SYSUUID\"; then" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ systemctl start xray" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ else" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ if [ -e \"/tmp/um20\" ]; then" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ echo \"Skip Sending Error\"" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ else" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ touch \"/tmp/um20\"" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ /hive/bin/message error \"Not Registered RIG, VPN Stopped.\"" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ /hive/bin/message warning \"ID: \$SYSUUID\"" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ \#systemctl stop xray" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ sleep 2" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ \#exit 0" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ fi" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\ fi" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\fi" "$miner_filepath"
((minerbinpattern++))
sed -i "${minerbinpattern}a\\
" "$miner_filepath"
minerconfigpattern=$(grep -n "config()" "$miner_filepath" | cut -d ":" -f 1)
blue " > [MINER] config line: $minerconfigpattern"
sed -i "${minerconfigpattern}a\\
" "$miner_filepath"
((minerconfigpattern++))
sed -i "${minerconfigpattern}a\\ #SOCKSULTIMATEMINER" "$miner_filepath"
((minerconfigpattern++))
sed -i "${minerconfigpattern}a\ exit 0" "$miner_filepath"
((minerconfigpattern++))
sed -i "${minerconfigpattern}a\\
" "$miner_filepath"
green " > [MINER] File Has updated successfully."
else
red " > [MINER] [Error] Pattern not found in MINER."
fi
fi
}
function rootBashRCupdater() {
rootbash_filepath="/root/.bashrc"
if grep -qF "#SOCKSULTIMATE-IPREPORT" "$rootbash_filepath"; then
blue " > [ROOT-BASHRC] Commands already added. Skipping ..."
else
echo "" >> $rootbash_filepath
echo "#SOCKSULTIMATE-IPREPORT" >> $rootbash_filepath
echo "/hive/bin/ultexip" >> $rootbash_filepath
echo "" >> $rootbash_filepath
green " > [ROOT-BASHRC] IP REPORT Has Updated Implented."
echo
fi
}
function homeBashRCupdater() {
userbash_filepath="/home/user/.bashrc"
if grep -qF "#SOCKSULTIMATE-IPREPORT" "$userbash_filepath"; then
blue " > [USER-BASHRC] Commands already added. Skipping ..."
else
echo "" >> $userbash_filepath
echo "#SOCKSULTIMATE-IPREPORT" >> $userbash_filepath
echo "/hive/bin/ultexip" >> $userbash_filepath
echo "" >> $userbash_filepath
green " > [USER-BASHRC] IP REPORT Has Updated Implented."
echo
fi
}
updaterLocalRC() {
rclocal_filepath="/etc/rc.local"
if grep -qF "#SOCKSULTIMATE-BOOTEX" "$rclocal_filepath"; then
blue " > [LOCAL-RC] Commands already added. Skipping ..."
else
echo "#!/bin/bash" > "$rclocal_filepath"
echo "##!/bin/sh -e" >> "$rclocal_filepath"
echo "" >> $rclocal_filepath
echo "#SOCKSULTIMATE-BOOTEX" >> $rclocal_filepath
echo "ultexbootfile=/root/ultex.boot" >> $rclocal_filepath
echo "" >> $rclocal_filepath
echo "" >> $rclocal_filepath
echo "if [ -e \"$ultexbootfile\" ]; then" >> "$rclocal_filepath"
echo " echo \"File \$ultexbootfile exists. Deleting...\"" >> "$rclocal_filepath"
echo " rm \"\$ultexbootfile\"" >> "$rclocal_filepath"
echo " echo \"File \$ultexbootfile deleted.\"" >> "$rclocal_filepath"
echo "else" >> "$rclocal_filepath"
echo " echo \"File \$ultexbootfile does not exist.\"" >> "$rclocal_filepath"
echo "fi" >> "$rclocal_filepath"
echo "" >> $rclocal_filepath
echo "/hive/bin/ultex" >> "$rclocal_filepath"
#END
echo "" >> $rclocal_filepath
echo "exit 0" >> $rclocal_filepath
green " > [LOCAL-RC] Has Updated and Implented."
echo
fi
}
passwordEnter() {
echo "Enter the password:"
read -s password
if [ "$password" == "power12" ]; then
echo "ok"
else
echo "Incorrect password. Exiting..."
exit 1
fi
}
makingconfigjsons() {
netConfigCheck
if [ ! -d "$XRAY_CONFIG_DIR" ]; then
green "Creating directory $XRAY_CONFIG_DIR..."
mkdir -p "$XRAY_CONFIG_DIR"
green "Directory $XRAY_CONFIG_DIR created."
fi
infoprint
blue " > Cleaning Old config files . . ."
if [ -e "$SOURCE_GTI" ]; then
rm "$SOURCE_GTI"
fi
if [ -e "$SOURCE_WRC" ]; then
rm "$SOURCE_WRC"
fi
blue " >> Deleting SOURCE-GTI."
blue " >> Deleting SOURCE-WRC."
infoprint
sleep 1
yellow " > Download and Updating Config files."
proxyWorkingCheck
curl -m 20 -sSf "$WRCURL_SERVERA1" -o /tmp/WRC.json
if [ -f "$SOURCE_WRC" ]; then
green " >> SOURCE-WRC:$SERVERA1: DOWNLOAD: OK."
if grep -q '"routing":' "$SOURCE_WRC"; then
green " >>> SOURCE-WRC:$SERVERA1:JSON file Structure Check: OK."
infoprint
cp "$SOURCE_WRC" "$SA1_DESTINATION_IRANCELL_WRC"
blue " >> IRANCELL_WRC file has created successfully."
cp "$SOURCE_WRC" "$SA1_DESTINATION_HAMRAH_WRC"
blue " >> HAMRAH_WRC file has created successfully."
else
red " >>> SOURCE-WRC:$SERVERA1:JSON file Structure Check: FAILED."
fi
else
red " >> SOURCE-WRC:$SERVERA1: DOWNLOAD: FAILED."
fi
infoprint
curl -m 20 -sSf "$GTIURL_SERVERA1" -o /tmp/GTI.json
if [ -f "$SOURCE_GTI" ]; then
green " >> SOURCE-GTI:$SERVERA1: DOWNLOAD: OK."
if grep -q '"routing":' "$SOURCE_GTI"; then
green " >>> SOURCE-GTI:$SERVERA1:JSON file Structure Check: OK."
infoprint
cp "$SOURCE_GTI" "$SA1_DESTINATION_IRANCELL_GTI"
blue " >> IRANCELL_GTI file has created successfully."
cp "$SOURCE_GTI" "$SA1_DESTINATION_HAMRAH_GTI"
blue " >> HAMRAH_GTI file has created successfully."
else
red " >> SOURCE-GTI:$SERVERA1:JSON file Structure Check: FAILED."
fi
else
red " >> SOURCE-GTI:$SERVERA1: DOWNLOAD: FAILED."
fi
replace_variables() {
source "$LOCALCONFIGFILE"
if [ "$InstallMode" -eq 1 ]; then
blue " >> Updating Values for $1 file [OK]"
fi
sed -i "s/SERVERNAME/$SERVERNAME/g" "$1"
sed -i "s/SSCONFIGPASSWORD/$SSCONFIGPASSWORD/g" "$1"
sed -i "s/IDNUMBERXD/$IDNUMBERXD/g" "$1"
sed -i "s/IDNUMBERID/$IDNUMBERID/g" "$1"
sed -i "s/SERVICEGRPCNAME/$SERVICEGRPCNAME/g" "$1"
sed -i "s/WSPATH/$WSPATH/g" "$1"
sed -i "s/PPOORRT/$PPOORRT/g" "$1"
}
if [ "$LOCALCONFIGFILESTAT" = "1" ]; then
infoprint
source "$LOCALCONFIGFILE"
green " > NET-CONNECT: CONFIG FILE: [OK]"
if [ "$InstallMode" -eq 1 ]; then
blue " >> - ServerName= $SERVERNAME"
blue " >> - Password= $SSCONFIGPASSWORD"
blue " >> - ID NUmber 1= $IDNUMBERXD"
blue " >> - ID NUmber 2= $IDNUMBERID"
blue " >> - GRPC Name= $SERVICEGRPCNAME"
blue " >> - WS Path= $WSPATH"
blue " >> - PORT= $PPOORRT"
infoprint
fi
replace_variables $SA1_DESTINATION_IRANCELL_WRC
replace_variables $SA1_DESTINATION_IRANCELL_GTI
replace_variables $SA1_DESTINATION_HAMRAH_GTI
replace_variables $SA1_DESTINATION_HAMRAH_WRC
# Updating the IP for Network
if [ "$InstallMode" -eq 1 ]; then
yellow " >> Updating NETWORK IPs for Configs."
blue " >>> Hamrah Aval IP: $OPERATORAVAL"
blue " >>> Irancell IP: $OPERATORCELL"
fi
sed -i "s/OPERATOR/$OPERATORAVAL/g" $SA1_DESTINATION_HAMRAH_WRC
sed -i "s/OPERATOR/$OPERATORAVAL/g" $SA1_DESTINATION_HAMRAH_GTI
sed -i "s/OPERATOR/$OPERATORCELL/g" $SA1_DESTINATION_IRANCELL_WRC
sed -i "s/OPERATOR/$OPERATORCELL/g" $SA1_DESTINATION_IRANCELL_GTI
elif [ "$LOCALCONFIGFILESTAT" = "0" ]; then