forked from Soroushnk/Astro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAstro.sh
1129 lines (961 loc) · 52.9 KB
/
Astro.sh
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
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
NC='\033[0m' # No Color
# Check if user is root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
sleep .5
sudo "$0" "$@"
exit 1
fi
echo "Running as root..."
sleep .5
clear
while true; do
clear
echo -e "${YELLOW}####################################################${NC}"
echo -e "${GREEN}# #${NC}"
echo -e "${BLUE}#${GREEN} ______ _____ ${BLUE}#${NC}"
echo -e "${BLUE}#${GREEN} ___ |________ /_____________ ${BLUE}#${NC}"
echo -e "${BLUE}#${GREEN} __ /| |_ ___/ __/_ ___/ __ \ ${BLUE}#${NC}"
echo -e "${BLUE}#${GREEN} _ ___ |(__ )/ / _ _ / / /_/ / ${BLUE}#${NC}"
echo -e "${BLUE}#${GREEN} /_/ |_/____/ \__/ /_/ \____/ ${BLUE}#${NC}"
echo -e "${BLUE}# #${NC}"
echo -e "${BLUE}#${NC} B Y ${BLUE}#${NC}"
echo -e "${BLUE}#${NC} A T O M I C B O Y S ${BLUE}#${NC}"
echo -e "${BLUE}# #${NC}"
echo -e "${BLUE}# ${GREEN}Main Menu${BLUE} #${NC}"
echo -e "${GREEN}# #${NC}"
echo -e "${YELLOW}####################################################${NC}"
echo -e "\n"
echo -e "${GREEN}Please choose an option:${NC}"
echo ""
echo -e "${YELLOW} 1.${NC} ${CYAN}Update server and install dependences${NC}"
echo -e "${YELLOW} 2.${NC} ${GRAY}Install curl/socat${NC}"
echo -e "${YELLOW} 3.${NC} ${GRAY}Install panel${NC}"
echo -e "${YELLOW} 4.${NC} ${CYAN}Install and config ssl ${NC}"
echo -e "${YELLOW} 5.${NC} ${CYAN}Cisco anyconnect${NC}"
echo -e "${YELLOW} 6.${NC} ${GRAY}Change SSH port${NC}"
echo -e "${YELLOW} 7.${NC} ${GRAY}Google Recapcha Fix${NC}"
echo -e "${YELLOW} 8.${NC} ${CYAN}Install Mtproto proxy${NC}"
echo -e "${YELLOW} 9.${NC} ${CYAN}Add user (for SSH)${NC}"
echo -e "${YELLOW}10.${NC} ${GRAY}Install OpenVPN${NC}"
echo -e "${YELLOW}11.${NC} ${CYAN}Install and config WordPress${NC}"
echo -e "${YELLOW}12.${NC} ${GRAY}Speedtest${NC}"
echo -e "${YELLOW}13.${NC} ${CYAN}Tunnel two server using IPtables${NC}"
echo -e "${YELLOW}14.${NC} ${GRAY}Cloudflare white IP scanner${NC}"
echo -e "${YELLOW}15.${NC} ${CYAN}reverse proxy(UNDER development)${NC}"
echo -e "${YELLOW}16.${NC} ${GRAY}set up wiregaurd${NC}"
echo -e "${YELLOW}17.${NC} ${GREEN}CREDITS${NC}"
echo -e "${YELLOW}18.${NC} ${RED}QUIT${NC}"
echo -e ""
read -p "Enter option number: " choice
case $choice in
#UPDATE SEVER
1)
echo -e "${GREEN}Updating server...${NC}"
echo ""
apt update && apt upgrade -y
sudo apt install git wget curl ufw
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
2)
echo -e "${GREEN}Installing curl/socat...${NC}"
echo ""
apt install curl socat -y
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# INSTALL X-UI PANEL
3)
echo "Please choose a panel to install:"
echo -e "${YELLOW}1.${NC} ${GRAY}hossein assadi's x-ui${NC}"
echo -e "${YELLOW}2.${NC} ${GREEN}vaxilu (original)${NC}"
echo -e "${YELLOW}3.${NC} ${GRAY}hiddify${NC}"
echo -e "${YELLOW}4.${NC} ${GRAY}alireza0 x-ui${NC}"
echo -e "${YELLOW}5.${NC} ${GRAY}3x-ui (MHSanaei)${NC}"
echo -e "${YELLOW}6.${NC} ${GRAY}kafka x-ui${NC}"
echo -e "${YELLOW}7.${NC} ${GRAY}alireza0 x-ui${NC}"
echo -e "${YELLOW}8.${NC} ${RED}Back to Main Menu${NC}"
echo -e""
read -p "Enter option number: " panel_choice
case $panel_choice in
1)
echo -e "${GREEN}Installing panel...${NC}"
echo ""
bash <(curl -Ls https://raw.githubusercontent.com/hossinasaadi/x-ui/master/install.sh)
;;
2)
echo -e "${GREEN}Installing panel...${NC}"
echo ""
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
;;
3)
echo -e "${GREEN}Installing panel...${NC}"
echo ""
bash -c "$(curl -Lfo- https://raw.githubusercontent.com/hiddify/hiddify-config/main/common/download_install.sh)"
;;
4)
echo -e "${GREEN}Installing panel...${NC}"
echo ""
bash <(curl -Ls https://raw.githubusercontent.com/alireza0/x-ui/master/install.sh)
;;
5)
echo -e "${GREEN}Installing panel...${NC}"
echo ""
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)
;;
6)
echo -e "${GREEN}Installing panel...${NC}"
echo ""
bash <(curl -Ls https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh)
;;
7)
echo -e "${GREEN}Installing docker and downloading panel...${NC}"
# Download and install Docker
curl -fsSL https://get.docker.com | sh
# Download and extract the Marzban examples archive
wget -qO- https://github.com/Gozargah/Marzban-examples/releases/latest/download/fully-single-port.tar.gz | tar xz --xform 's/fully-single-port/marzban/' && cd marzban
# Start the Docker Compose environment
docker-compose up -d
# Stop and restart the Docker Compose environment
cd marzban
docker-compose down
docker-compose up -d
;;
8)
break
;;
*)
echo "Invalid panel choice"
;;
esac
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# DOWNLOADS ACME
4)
echo -e "${GREEN}Installing Acme Script...${NC}"
echo ""
curl https://get.acme.sh | sh
echo ""
echo -e "${GREEN}Configuring Acme...${NC}"
echo ""
sleep 1
echo "Configuring Acme Script..."
echo ""
# GET CERTIFICATE FOR DOMAIN
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
echo ""
read -p "Enter email address: " email
~/.acme.sh/acme.sh --register-account -m $email
echo ""
read -p "Enter domain name: " domain
~/.acme.sh/acme.sh --issue -d $domain --standalone
~/.acme.sh/acme.sh --installcert -d $domain --key-file /root/private.key --fullchain-file /root/cert.crt
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# cisco open connect (oscerv)
5)
echo -e "${YELLOW}1.${NC} ${GRAY}Install ocserv${NC}"
echo -e "${YELLOW}2.${NC} ${GRAY}Run ocserv${NC}"
echo -e "${YELLOW}3.${NC} ${GRAY}Change ocserv port${NC}"
echo -e "${YELLOW}4.${NC} ${RED}Back to Main Menu${NC}"
read -e -p "Enter choice [1-4]: " choice
case $choice in
1)
wget -N --no-check-certificate https://raw.githubusercontent.com/sfc9982/AnyConnect-Server/main/ocserv-en.sh
chmod +x ocserv-en.sh
bash ocserv-en.sh
;;
2)
sudo systemctl start ocserv
;;
3)
read -p "Enter new TCP port number: " port
sudo sed -i "s/tcp-port = [0-9]*/tcp-port = $port/" /etc/ocserv/ocserv.conf
echo "TCP port set to $port"
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
4)
break
;;
*)
echo "Invalid choice. Please enter a valid option."
;;
esac
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
#CHANGE SSH PORT
6)
echo -e "${GREEN}Changing SSH port...${NC}"
echo ""
read -p "Enter a new port number: " new_port
sed -i "s/#Port 22/Port $new_port/" /etc/ssh/sshd_config
sed -i "s/#Port/Port/" /etc/ssh/sshd_config
systemctl restart sshd.service
ufw allow $new_port/tcp
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# GOOGLE RECAPCHA FIX
7)
echo -e "${GREEN}Fixing Google Recapcha...${NC}"
echo ""
curl -O https://raw.githubusercontent.com/jinwyp/one_click_script/master/install_kernel.sh && chmod +x ./install_kernel.sh && ./install_kernel.sh
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# install Mtproto
8)
# Prompt user for input
echo "Please enter the following information:"
read -p "Port number (default is 443): " port
echo "for secret you you can use http://seriyps.ru/mtpgen.html "
read -p "Secret key (should be a string of 32 hexadecimal characters): " secret_key
echo "to get the server tag you should use telegram bot https://t.me/MTProxybot "
read -p "Server tag (should be a string of 32 hexadecimal characters): " server_tag
read -p "List of authentication methods - place empty for default - (should be a comma-separated list): " auth_methods
read -p "MTProto domain (should be a valid domain name): " mtproto_domain
# Set default values if user input is empty
port=${port:-443}
auth_methods=${auth_methods:-"dd,tls"}
# Download and run MTProto installation script
curl -L -o mtp_install.sh https://git.io/fj5ru && \
bash mtp_install.sh -p $port -s $secret_key -t $server_tag -a $auth_methods -d $mtproto_domain
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# Make user for ssh connection
9)
echo -e "${GREEN}Adding user...${NC}"
echo ""
read -p "Enter username: " username
adduser $username
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# Install OPENVPN
10)
echo -e "${GREEN}Installing OpenVPN...${NC}"
echo ""
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh
./openvpn-install.sh
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
# Install WordPress and connect to SQL
11)
echo -e "${GREEN}Installing WordPress and connecting to SQL...${NC}"
echo ""
# Update package index and install required packages
sudo apt update
sudo apt install apache2 ghostscript mysql-server php php-bcmath libapache2-mod-php php-mysql php-curl php-json php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
# install wordpress
sudo mkdir -p /srv/www
sudo chown www-data: /srv/www
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www
# Define the file path and content
FILE_PATH="/etc/apache2/sites-available/wordpress.conf"
FILE_CONTENT="<VirtualHost *:80>\n\tDocumentRoot /srv/www/wordpress\n\t<Directory /srv/www/wordpress>\n\t\tOptions FollowSymLinks\n\t\tAllowOverride Limit Options FileInfo\n\t\tDirectoryIndex index.php\n\t\tRequire all granted\n\t</Directory>\n\t<Directory /srv/www/wordpress/wp-content>\n\t\tOptions FollowSymLinks\n\t\tRequire all granted\n\t</Directory>\n</VirtualHost>"
# Write the file
echo -e $FILE_CONTENT | sudo tee $FILE_PATH > /dev/null
# Enable the site
sudo a2ensite wordpress.conf
sudo a2ensite wordpress
sudo a2enmod rewrite
sudo a2dissite 000-default
# Restart Apache
sudo systemctl restart apache2
# Prompt the user for their MySQL root password
echo ""
read -sp "Enter MySQL root password: " mysql_password
echo
read -s -p "Enter your WordPress password: " wordpress_password
echo
# Run the SQL commands
echo "CREATE DATABASE wordpress;" | sudo mysql -u root -p$mysql_password
echo "CREATE USER wordpress@localhost IDENTIFIED BY '$wordpress_password';" | sudo mysql -u root -p$mysql_password
echo "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost;" | sudo mysql -u root -p$mysql_password
echo "FLUSH PRIVILEGES;" | sudo mysql -u root -p$mysql_password
echo "quit" | sudo mysql -u root -p$mysql_password
sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php
# Define the database settings
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD="$wordpress_password"
DB_HOST="localhost"
DB_CHARSET="utf8"
DB_COLLATE=""
# Get the secret keys
SECRET_KEYS=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/)
# Define the table prefix and debugging mode
TABLE_PREFIX="wp_"
WP_DEBUG=false
# Define the file path
FILE_PATH="/srv/www/wordpress/wp-config.php"
# Create the wp-config.php file
echo "<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to 'wp-config.php'
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/documentation/article/editing-wp-config-php/
*
* @package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', '$DB_NAME' );
/** Database username */
define( 'DB_USER', '$DB_USER' );
/** Database password */
define( 'DB_PASSWORD', '$DB_PASSWORD' );
/** Database hostname */
define( 'DB_HOST', '$DB_HOST' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', '$DB_CHARSET' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '$DB_COLLATE' );
/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
$SECRET_KEYS
/**#@-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
\$table_prefix = '$TABLE_PREFIX';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/documentation/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', $WP_DEBUG );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
" > "$FILE_PATH"
echo "New values have been added to the wp-config.php file."
sleep 1.33
echo "WordPress has been installed and configured!"
sleep 1.33
echo ""
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
#Saaspeedtest menu
12)
while true; do
echo ""
echo "===================="
echo "VPS Speed Test Menu"
echo "===================="
echo "1. Install speedtest-cli"
echo "1. complete test"
echo "3. complete test"
echo "4. Test Download Speed"
echo "5. Test Upload Speed"
echo "6. Choose Server and Test"
echo "7. Exit"
echo ""
read -p "Enter your choice: " choice
case $choice in
1)
echo "Installing speedtest-cli..."
sudo apt-get update
sudo apt-get install speedtest-cli -y
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
2)
if ! command -v speedtest-cli &> /dev/null
then
echo "speedtest-cli not found, installing..."
sudo apt-get install speedtest-cli -y
fi
# Ask the user whether to test by byte or bit
read -p "Do you want to test by byte? [y/n]: " byte_test
# Ask the user whether to use HTTP or HTTPS
read -p "Do you want to use HTTPS? [y/n]: " use_https
# Ask the user whether to run a download test, an upload test, or both
read -p "Do you want to run a download test, an upload test, or both? [d/u/b]: " test_type
# Determine the appropriate command based on the user's input
if [[ $byte_test =~ ^[Yy]$ && $use_https =~ ^[Yy]$ && $test_type =~ ^[Dd]$ ]]; then
speedtest-cli --secure --bytes --no-upload --share
elif [[ $byte_test =~ ^[Yy]$ && $use_https =~ ^[Yy]$ && $test_type =~ ^[Uu]$ ]]; then
speedtest-cli --secure --bytes --no-download --share
elif [[ $byte_test =~ ^[Yy]$ && $use_https =~ ^[Yy]$ && $test_type =~ ^[Bb]$ ]]; then
speedtest-cli --secure --bytes --share
elif [[ $byte_test =~ ^[Yy]$ && $test_type =~ ^[Dd]$ ]]; then
speedtest-cli --bytes --no-upload --share
elif [[ $byte_test =~ ^[Yy]$ && $test_type =~ ^[Uu]$ ]]; then
speedtest-cli --bytes --no-download --share
elif [[ $byte_test =~ ^[Yy]$ && $test_type =~ ^[Bb]$ ]]; then
speedtest-cli --bytes --share
elif [[ $use_https =~ ^[Yy]$ && $test_type =~ ^[Dd]$ ]]; then
speedtest-cli --secure --no-bytes --no-upload --share
elif [[ $use_https =~ ^[Yy]$ && $test_type =~ ^[Uu]$ ]]; then
speedtest-cli --secure --no-bytes --no-download --share
elif [[ $use_https =~ ^[Yy]$ && $test_type =~ ^[Bb]$ ]]; then
speedtest-cli --secure --no-bytes --share
elif [[ $test_type =~ ^[Dd]$ ]]; then
speedtest-cli --no-bytes --no-upload --share
elif [[ $test_type =~ ^[Uu]$ ]]; then
speedtest-cli --no-bytes --no-download --share
elif [[ $test_type =~ ^[Bb]$ ]]; then
speedtest-cli --no-bytes --share
else
speedtest-cli --no-bytes --share
fi
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
3)
if ! command -v speedtest-cli &> /dev/null
then
echo "speedtest-cli not found, installing..."
sudo apt-get install speedtest-cli -y
fi
echo "Testing download and upload speed..."
speedtest-cli
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
4)
if ! command -v speedtest-cli &> /dev/null
then
echo "speedtest-cli not found, installing..."
sudo apt-get install speedtest-cli -y
fi
echo "Testing download speed..."
speedtest-cli --no-upload
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
5)
if ! command -v speedtest-cli &> /dev/null
then
echo "speedtest-cli not found, installing..."
sudo apt-get install speedtest-cli -y
fi
echo "Testing upload speed..."
speedtest-cli --no-download
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
6)
# Install speedtest-cli if not already installed
if ! command -v speedtest-cli &> /dev/null
then
echo "speedtest-cli not found, installing..."
sudo apt-get install speedtest-cli -y
fi
# Fetch server list and create a menu
servers=$(speedtest-cli --list | awk -F') ' '/^[0-9]+\)/{print $1") " $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')
echo "Available servers:"
echo "$servers"
# Prompt user to select a server
read -p "Enter server number: " server_number
server=$(echo "$servers" | grep "^$server_number)" | cut -d " " -f 2-)
if [ -z "$server" ]
then
echo "Invalid server number"
exit 1
fi
# Run speedtest with selected server
echo "Testing speed with server: $server"
speedtest-cli --server "$server_number"
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
7)
echo "Exiting..."
break
;;
*)
echo "Invalid choice. Please try again."
;;
esac
done
;;
#Iptables
13)
while true; do
# show options to user
echo "Please choose an option:"
echo "1. Install iptables"
echo "2. Display forwarding table"
echo "3. Set up a tunnel"
echo "4. delete a tunnel"
echo "5. back to main menu"
# read user input
read choice
# run appropriate function based on user choice
case $choice in
1)
sudo apt-get update
sudo apt-get install iptables
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
2)
;;
3)
echo "Please enter the Iran IP for the tunnel:"
read iran_ip
echo "Please enter the Kharej IP for the tunnel:"
read kharej_ip
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to-destination "$iran_ip"
sudo iptables -t nat -A PREROUTING -j DNAT --to-destination "$kharej_ip"
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
4)
echo "Please enter the Iran IP for the tunnel to delete:"
read iran_ip
echo "Please enter the Kharej IP for the tunnel to delete:"
read kharej_ip
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -D PREROUTING -p tcp --dport 22 -j DNAT --to-destination "$iran_ip"
sudo iptables -t nat -D PREROUTING -j DNAT --to-destination "$kharej_ip"
sudo iptables -t nat -D POSTROUTING -j MASQUERADE
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
5)
break
;;
*)
echo "Invalid choice"
;;
esac
done
;;
#CFSscanner
14)
while true; do
echo "---------------------"
echo "CFSanner Menu Options:"
echo "---------------------"
echo "1. Install Dependencies"
echo "2. Set Config File"
echo "3. Scan"
echo "4. Exit"
read -p "Please select an option [1-4]: " choice
case $choice in
1)
echo "Installing dependencies..."
if ! command -v getopt &> /dev/null || ! command -v jq &> /dev/null || ! command -v git &> /dev/null || ! command -v tput &> /dev/null || ! command -v bc &> /dev/null || ! command -v curl &> /dev/null || [[ $(parallel --version | awk '{print $4}') -lt 20220515 ]]
then
# Prompt the user to install any missing packages
echo "The following packages are missing or outdated:"
if ! command -v getopt &> /dev/null; then echo " - getopt"; fi
if ! command -v jq &> /dev/null; then echo " - jq"; fi
if ! command -v git &> /dev/null; then echo " - git"; fi
if ! command -v tput &> /dev/null; then echo " - tput"; fi
if ! command -v bc &> /dev/null; then echo " - bc"; fi
if ! command -v curl &> /dev/null; then echo " - curl"; fi
if ! command -v parallel &> /dev/null || [[ $(parallel --version | awk '{print $4}') -lt 20220515 ]]; then echo " - parallel (version > 20220515)"; fi
echo "Do you want to install them? (y/n)"
read answer
if [ "$answer" = "y" ]; then
sudo apt-get install $(if ! command -v getopt &> /dev/null; then echo "getopt "; fi) \
$(if ! command -v jq &> /dev/null; then echo "jq "; fi) \
$(if ! command -v git &> /dev/null; then echo "git "; fi) \
$(if ! command -v tput &> /dev/null; then echo "ncurses-bin "; fi) \
$(if ! command -v bc &> /dev/null; then echo "bc "; fi) \
$(if ! command -v curl &> /dev/null; then echo "curl "; fi) \
$(if ! command -v parallel &> /dev/null || [[ $(parallel --version | awk '{print $4}') -lt 20220515 ]]; then echo "parallel "; fi)
fi
else
echo "All required packages are already installed and up to date."
fi
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
2)
echo "Setting config file..."
# Clone the CFScanner repository
git clone https://github.com/MortezaBashsiz/CFScanner.git
# Navigate to the bash directory
cd CFScanner/bash
# Make the bin files executable
chmod +x ../bin/*
# Prompt user to use custom config or not
read -p "Do you want to use a custom config file? (y/n) " use_custom_config
if [ $use_custom_config == "y" ]; then
# Ask user for config data and save to customconfig.real file
read -p "Enter your UUID: " uuid
read -p "Enter the host address: " host
read -p "Enter the port: " port
read -p "Enter the websocket endpoint: " path
read -p "Enter the SNI: " sni
read -p "Enter the URL for the subnet list (press Enter for default): " subnets_url
# Use default subnet list if no URL is provided
if [ -z $subnets_url ]; then
subnets_url="https://raw.githubusercontent.com/MortezaBashsiz/CFScanner/main/bash/cf.local.iplist"
fi
# Write custom config to file
echo "{" > customconfig.real
echo " \"id\": \"$uuid\"," >> customconfig.real
echo " \"Host\": \"$host\"," >> customconfig.real
echo " \"Port\": \"$port\"," >> customconfig.real
echo " \"path\": \"$path\"," >> customconfig.real
echo " \"serverName\": \"$sni\"," >> customconfig.real
echo " \"subnetsList\": \"$subnets_url\"" >> customconfig.real
echo "}" >> customconfig.real
# Use custom config file
config_file="customconfig.real"
else
# Use default config file
config_file="config.real"
fi
# Download the config file
curl -s https://raw.githubusercontent.com/MortezaBashsiz/CFScanner/main/bash/ClientConfig.json -o $config_file
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
3)
echo "Scanning..."
# Default values
vpn="NO"
mode="SUBNET"
direction="BOTH"
threshold=3
max_tries=3
config_file="config.ini"
interval=5
custom_subnet_file=""
# Read user inputs
read -p "Use VPN connection? [YES/NO] (default: $vpn): " input_vpn
if [[ ! -z $input_vpn ]]; then vpn="$input_vpn"; fi
read -p "Scan mode? [SUBNET/IP] (default: $mode): " input_mode
if [[ ! -z $input_mode ]]; then mode="$input_mode"; fi
read -p "Scan direction? [DOWN/UP/BOTH] (default: $direction): " input_direction
if [[ ! -z $input_direction ]]; then direction="$input_direction"; fi
read -p "Threshold for concurrent connections? (default: $threshold): " input_threshold
if [[ ! -z $input_threshold ]]; then threshold="$input_threshold"; fi
read -p "Max tries for failed connections? (default: $max_tries): " input_max_tries
if [[ ! -z $input_max_tries ]]; then max_tries="$input_max_tries"; fi
read -p "Config file? (default: $config_file): " input_config_file
if [[ ! -z $input_config_file ]]; then config_file="$input_config_file"; fi
read -p "Scan interval (in seconds)? (default: $interval): " input_interval
if [[ ! -z $input_interval ]]; then interval="$input_interval"; fi
read -p "Number of threads to use? (default: $threads): " input_threads
if [[ ! -z $input_threads ]]; then threads="$input_threads"; fi
read -p "Custom subnet file (if using mode=IP)? (default: $custom_subnet_file): " input_custom_subnet_file
if [[ ! -z $input_custom_subnet_file ]]; then custom_subnet_file="$input_custom_subnet_file"; fi
# Run code with the parameters
echo "Running code with the following parameters:"
echo "-vpn $vpn -m $mode -t $direction -thr $threshold -try $max_tries -c $config_file -s $interval"
if [[ ! -z $custom_subnet_file ]]; then echo "-f $custom_subnet_file"; fi
# Uncomment the following line to actually run the code with the parameters
./cfScanner.sh -vpn $vpn -m $mode -t $direction -thr $threshold -try $max_tries -c $config_file -s $interval ${custom_subnet_file:+-f "$custom_subnet_file"} | xargs -n10 | column -t -s' ' | awk '{print "\033[32m" $0 "\033[0m"}'
echo
echo -e "Press ${RED}ENTER${NC} to continue"
read -s -n 1
;;
4)
echo "Exiting..."
break
;;
*)
echo "Invalid option. Please try again."
;;
esac
done
;;
#reverse proxy
15)
apt install nginx certbot python3-certbot-nginx -y
read -p "Enter your site name: " site_name
# Define the file path
FILE_PATH="/etc/nginx/sites-available/$site_name"
ln -s /etc/nginx/sites-available/$site_name /etc/nginx/sites-enabled/
systemctl restart nginx
output=$(certbot --nginx -d $site_name --register-unsafely-without-email)
echo "$output" | grep -oP '(?<=Your certificate and chain have been saved at: )[^\n]*' | sed -e 's/^\s*//' -e 's/\s*$//'
echo "$output" | grep -oP '(?<=Your key file has been saved at: )[^\n]*' | sed -e 's/^\s*//' -e 's/\s*$//'
;;
#Wiregaurd
16)
while true
do
clear
echo "==== Main Menu ===="
echo "1. Install WireGuard"
echo "2. Update WireGuard"
echo "3. Backup Users"
echo "4. Exit"
read -p "Enter your choice [1-4]: " choice
case $choice in
1)
while true
do
clear
echo "==== Install WireGuard ===="
echo "1. Install without SSL"
echo "2. Install with SSL"
echo "3. Back to main menu"
read -p "Enter your choice [1-3]: " install_choice
case $install_choice in
1)
# Install WireGuard without SSL
echo "Installing WireGuard without SSL..."
# Add commands to install WireGuard here
if ! command -v docker &> /dev/null
then
echo "docker not found, installing..."
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $(whoami)
fi
# Prompt user for required information
read -p "Enter IP address or domain name of server running Wireguard: " WG_HOST
read -p "Enter admin password for Vase login: " PASSWORD
read -p "Enter UDP port to use for Wireguard (default: 51820): " UDP_PORT
UDP_PORT=${UDP_PORT:-51820}
read -p "Enter TCP port to use for Wireguard (default: 51821): " TCP_PORT
TCP_PORT=${TCP_PORT:-51821}
# Run docker command with specified parameters
docker run -d \
--name=wg-easy \
-e WG_HOST=$WG_HOST \
-e PASSWORD=$PASSWORD \
-v ~/.wg-easy:/etc/wireguard \
-p $UDP_PORT:$UDP_PORT/udp \
-p $TCP_PORT:$TCP_PORT/tcp \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
--sysctl="net.ipv4.conf.all.src_valid_mark=1" \
--sysctl="net.ipv4.ip_forward=1" \
--restart unless-stopped \
weejewel/wg-easy
read -p "Installation complete. Press enter to continue..."
;;
2)
# Install WireGuard with SSL
echo "Installing WireGuard with SSL..."
# Installing required dependencies
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update -y
if ! command -v docker &> /dev/null
then
echo "docker not found, installing..."
sudo apt install docker-ce -y
fi
echo"checking the docker.."
sudo systemctl status docker
sleep 1
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version
sleep 1
filepath="/root/compose-dir/docker-compose.yml"
read -p "Enter IP address or domain name of server running Wireguard: " WG_HOST
read -p "Enter admin password for Vase login: " PASSWORD
echo"version: "3.8"
services:
wg-easy:
environment:
# ?? Change the server's hostname (clients will connect to):
- WG_HOST=$WG_HOST
# ?? Change the Web UI Password:
- PASSWORD=$PASSWORD
image: weejewel/wg-easy
container_name: wg-easy
hostname: wg-easy
volumes:
- ~/.wg-easy:/etc/wireguard
ports:
- "51820:51820/udp"
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
nginx:
image: weejewel/nginx-with-certbot
container_name: nginx
hostname: nginx
ports:
- "80:80/tcp"
- "443:443/tcp"