123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- #!/bin/bash
- # Created by https://t.me/badboy897
- # Script by Badboy
- # requirement
- apt-get -y update && apt-get -y upgrade
- apt-get -y install curl wget
- # initializing IP
- export DEBIAN_FRONTEND=noninteractive
- OS=`uname -m`;
- MYIP=$(wget -qO- ipv4.icanhazip.com);
- MYIP2="s/xxxxxxxxx/$MYIP/g";
- # configure rc.local
- cat <<EOF >/etc/rc.local
- #!/bin/sh -e
- exit 0
- EOF
- chmod +x /etc/rc.local
- systemctl daemon-reload
- systemctl start rc-local
- # disable ipv6
- echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
- sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
- # add DNS server ipv4
- echo "nameserver 1.1.1.1" > /etc/resolv.conf
- echo "nameserver 1.0.0.1" >> /etc/resolv.conf
- sed -i '$ i\echo "nameserver 1.1.1.1" > /etc/resolv.conf' /etc/rc.local
- sed -i '$ i\echo "nameserver 1.0.0.1" >> /etc/resolv.conf' /etc/rc.local
- # remove unused
- apt-get -y --purge remove samba*;
- apt-get -y --purge remove apache2*;
- apt-get -y --purge remove sendmail*;
- apt-get -y --purge remove bind9*;
- # set repo
- echo 'deb http://download.webmin.com/download/repository sarge contrib' >> /etc/apt/sources.list.d/webmin.list
- wget "http://www.dotdeb.org/dotdeb.gpg"
- cat dotdeb.gpg | apt-key add -;rm dotdeb.gpg
- wget -qO - http://www.webmin.com/jcameron-key.asc | apt-key add -
- # set time GMT +2
- ln -fs /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime
- # set locale
- sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
- # update
- apt-get update; apt-get -y upgrade;
- # install webserver extensions
- apt-get -y install nginx
- apt-get -y install php7.0-fpm php7.0-cli libssh2-1 php-ssh2 php7.0
- # install essential package
- apt-get -y install nano iptables-persistent dnsutils screen whois ngrep unzip unrar tar unzip zip certbot
- apt-get -y install build-essential
- apt-get -y install libio-pty-perl libauthen-pam-perl apt-show-versions libnet-ssleay-perl
- # install screenfetch
- cd
- wget -O /usr/bin/screenfetch "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Screenfetch/screenfetch"
- chmod +x /usr/bin/screenfetch
- echo "clear" >> .profile
- echo "screenfetch" >> .profile
- # install webserver
- cd
- rm /etc/nginx/sites-enabled/default
- rm /etc/nginx/sites-available/default
- wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/nginx.conf"
- wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/vps.conf"
- wget -O /etc/nginx/conf.d/monitoring.conf "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/monitoring.conf"
- mkdir -p /home/vps/public_html
- wget -O /home/vps/public_html/index.php "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Panel/index.php"
- sed -i 's/listen = \/run\/php\/php7.3-fpm.sock/listen = 127.0.0.1:9000/g' /etc/php/7.3/fpm/pool.d/www.conf
- sed -i $MYIP2 /home/vps/public_html/index.php;
- service php7.3-fpm restart
- service nginx restart
- # install openvpn
- apt-get -y install openvpn
- wget -O /etc/openvpn/openvpn.tar "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/OpenVPN/openvpn-debian.tar"
- cd /etc/openvpn/
- tar xf openvpn.tar
- sed -i $MYIP2 /etc/openvpn/server.conf
- # openvpn config
- cat > /home/vps/public_html/black.ovpn <<-END
- # OpenVPN Configuration By Black
- client
- dev tun
- proto tcp
- setenv FRIENDLY_NAME "BlackVPN"
- remote $MYIP 443
- http-proxy $MYIP 8080
- remote-cert-tls server
- resolv-retry infinite
- nobind
- tun-mtu 1500
- mssfix 1500
- persist-key
- persist-tun
- ping-restart 0
- ping-timer-rem
- reneg-sec 0
- comp-lzo
- auth SHA512
- auth-user-pass
- auth-nocache
- cipher AES-128-CBC
- verb 3
- pull
- END
- echo '<ca>' >> /home/vps/public_html/black.ovpn
- cat /etc/openvpn/keys/ca.crt >> /home/vps/public_html/black.ovpn
- echo '</ca>' >> /home/vps/public_html/black.ovpn
- cd /home/vps/public_html/
- tar -czf /home/vps/public_html/blackVPN.tar.gz black.ovpn
- tar -czf /home/vps/public_html/black.tar.gz black.ovpn
- cd
- # Deb9 OVPN Bug Workaround
- mkdir -p /dev/net
- mknod /dev/net/tun c 10 200
- chmod 600 /dev/net/tun
- # Deb9 OVPN Bug2 Workaround
- sed -i 's@LimitNPROC=10@@g' /lib/systemd/system/openvpn@.service
- # Restart openvpn
- systemctl daemon-reload
- systemctl start openvpn@server
- systemctl enable openvpn@server
- systemctl status --no-pager openvpn@server
- # Setting UFW
- apt-get install ufw
- ufw allow ssh
- ufw allow 443/tcp
- sed -i 's|DEFAULT_INPUT_POLICY="DROP"|DEFAULT_INPUT_POLICY="ACCEPT"|' /etc/default/ufw
- sed -i 's|DEFAULT_FORWARD_POLICY="DROP"|DEFAULT_FORWARD_POLICY="ACCEPT"|' /etc/default/ufw
- cat > /etc/ufw/before.rules <<-END
- # START OPENVPN RULES
- # NAT table rules
- *nat
- :POSTROUTING ACCEPT [0:0]
- # Allow traffic from OpenVPN client to eth0
- -A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
- COMMIT
- # END OPENVPN RULES
- END
- ufw status
- ufw disable
- # set ipv4 forward
- echo 1 > /proc/sys/net/ipv4/ip_forward
- sed -i 's|#net.ipv4.ip_forward=1|net.ipv4.ip_forward=1|' /etc/sysctl.conf
- # OpenVPN monitoring
- apt -y install git gcc nginx uwsgi uwsgi-plugin-python3 virtualenv python3-dev libgeoip-dev geoip-database geoip-database-extra
- wget -O /srv/openvpn-monitor.tar "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Panel/openvpn-monitor.tar"
- cd /srv
- tar xf openvpn-monitor.tar
- cd openvpn-monitor
- virtualenv -p python3 .
- . bin/activate
- pip install -r requirements.txt
- wget -O /etc/uwsgi/apps-available/openvpn-monitor.ini "https://raw.githubusercontent.com/dopekid30/AutoScriptDebian9/main/Res/Panel/openvpn-monitor.ini"
- ln -s /etc/uwsgi/apps-available/openvpn-monitor.ini /etc/uwsgi/apps-enabled/
- # GeoIP For OpenVPN Monitor
- mkdir -p /var/lib/GeoIP
- wget -O /var/lib/GeoIP/GeoLite2-City.mmdb.gz "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Panel/GeoLite2-City.mmdb.gz"
- gzip -d /var/lib/GeoIP/GeoLite2-City.mmdb.gz
- # install badvpn
- cd
- wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/BadVPN/badvpn-udpgw64"
- sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 1000 --max-connections-for-client 10' /etc/rc.local
- chmod +x /usr/bin/badvpn-udpgw
- screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 1000 --max-connections-for-client 10
- # setting port ssh
- sed -i '/#Port 22/a Port 143' /etc/ssh/sshd_config
- sed -i '/#Port 22/a Port 90' /etc/ssh/sshd_config
- sed -i 's/#Port 22/Port 22/g' /etc/ssh/sshd_config
- /etc/init.d/ssh restart
- # install dropbear
- apt-get -y install dropbear
- sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
- sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=442/g' /etc/default/dropbear
- sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-p 109 -p 110"/g' /etc/default/dropbear
- echo "/bin/false" >> /etc/shells
- /etc/init.d/dropbear restart
- # install squid
- apt-get -y install squid
- cat > /etc/squid/squid.conf <<-END
- acl server dst xxxxxxxxx/32 localhost
- #acl checker src 188.93.95.137
- acl ports_ port 14 22 53 21 8080 8000 1193 1194 440 441 442 443 80
- http_port 8000
- http_port 8080
- access_log none
- cache_log /dev/null
- logfile_rotate 0
- http_access allow server
- #http_access allow checker
- http_access deny all
- forwarded_for off
- via off
- request_header_access Host allow all
- request_header_access Content-Length allow all
- request_header_access Content-Type allow all
- request_header_access All deny all
- hierarchy_stoplist cgi-bin ?
- coredump_dir /var/spool/squid
- refresh_pattern ^ftp: 1440 20% 10080
- refresh_pattern ^gopher: 1440 0% 1440
- refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
- refresh_pattern . 0 20% 4320
- visible_hostname lanundarat.tk
- END
- sed -i $MYIP2 /etc/squid/squid.conf;
- service squid restart
- # V2-ui Panel Setup
- wget -O /usr/local/v2-ui-linux.tar.gz "https://www.dropbox.com/s/6yoi0gn1vcx6na9/v2-ui-linux.tar.gz"
- cd /usr/local/
- tar zxvf v2-ui-linux.tar.gz
- rm v2-ui-linux.tar.gz -f
- cd v2-ui
- chmod +x v2-ui bin/v2ray-v2-ui bin/v2ctl
- cp -f v2-ui.service /etc/systemd/system/
- cd
- # Start V2-ui
- #systemctl daemon-reload
- #systemctl start v2-ui
- #systemctl enable v2-ui
- #systemctl status --no-pager v2-ui
- # Install PPTPVPN
- wget https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/install.sh
- sudo bash install.sh
- # installing webmin
- wget "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/webmin_1.801_all.deb"
- dpkg --install webmin_1.801_all.deb;
- apt-get -y -f install;
- sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
- rm /root/webmin_1.801_all.deb
- service webmin restart
- # install stunnel
- apt-get install stunnel4 -y
- cat > /etc/stunnel/stunnel.conf <<-END
- cert = /etc/stunnel/stunnel.pem
- [dropbear]
- accept = 444
- connect = 127.0.0.1:442
- END
- # configure stunnel
- sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
- wget -O /etc/stunnel/stunnel.pem "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/stunnel.pem"
- service stunnel4 restart
- cd
- # install fail2ban
- apt-get -y install fail2ban
- # install ddos deflate
- cd
- apt-get -y install dnsutils dsniff
- wget https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/DDOS/ddos-deflate-master.zip
- unzip ddos-deflate-master.zip
- cd ddos-deflate-master
- ./install.sh
- rm -rf /root/ddos-deflate-master.zip
- # banner /etc/banner
- wget -O /etc/banner "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Other/banner"
- sed -i 's@#Banner none@Banner /etc/banner@g' /etc/ssh/sshd_config
- sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/banner"@g' /etc/default/dropbear
- # Webmin Configuration
- sed -i '$ i\dope: acl adsl-client ajaxterm apache at backup-config bacula-backup bandwidth bind8 burner change-user cluster-copy cluster-cron cluster-passwd cluster-shell cluster-software cluster-useradmin cluster-usermin cluster-webmin cpan cron custom dfsadmin dhcpd dovecot exim exports fail2ban fdisk fetchmail file filemin filter firewall firewalld fsdump grub heartbeat htaccess-htpasswd idmapd inetd init inittab ipfilter ipfw ipsec iscsi-client iscsi-server iscsi-target iscsi-tgtd jabber krb5 ldap-client ldap-server ldap-useradmin logrotate lpadmin lvm mailboxes mailcap man mon mount mysql net nis openslp package-updates pam pap passwd phpini postfix postgresql ppp-client pptp-client pptp-server proc procmail proftpd qmailadmin quota raid samba sarg sendmail servers shell shorewall shorewall6 smart-status smf software spam squid sshd status stunnel syslog-ng syslog system-status tcpwrappers telnet time tunnel updown useradmin usermin vgetty webalizer webmin webmincron webminlog wuftpd xinetd' /etc/webmin/webmin.acl
- sed -i '$ i\dope:x:0' /etc/webmin/miniserv.users
- /usr/share/webmin/changepass.pl /etc/webmin badboy 12345
- # Setting IPtables
- cat > /etc/iptables.up.rules <<-END
- *nat
- :PREROUTING ACCEPT [0:0]
- :OUTPUT ACCEPT [0:0]
- :POSTROUTING ACCEPT [0:0]
- -A POSTROUTING -j SNAT --to-source xxxxxxxxx
- -A POSTROUTING -o eth0 -j MASQUERADE
- -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
- -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
- COMMIT
- *filter
- :INPUT ACCEPT [19406:27313311]
- :FORWARD ACCEPT [0:0]
- :OUTPUT ACCEPT [9393:434129]
- :fail2ban-ssh - [0:0]
- -A FORWARD -i eth0 -o ppp0 -m state --state RELATED,ESTABLISHED -j ACCEPT
- -A FORWARD -i ppp0 -o eth0 -j ACCEPT
- -A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
- -A INPUT -p ICMP --icmp-type 8 -j ACCEPT
- -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
- -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 8888 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 8888 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 142 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 143 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 109 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 110 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 1194 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 1194 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 1732 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 1732 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 3128 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 3128 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 7300 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 7300 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 8000 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 8000 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 8080 -m state --state NEW -j ACCEPT
- -A INPUT -p udp --dport 8080 -m state --state NEW -j ACCEPT
- -A INPUT -p tcp --dport 10000 -m state --state NEW -j ACCEPT
- -A fail2ban-ssh -j RETURN
- COMMIT
- *raw
- :PREROUTING ACCEPT [158575:227800758]
- :OUTPUT ACCEPT [46145:2312668]
- COMMIT
- *mangle
- :PREROUTING ACCEPT [158575:227800758]
- :INPUT ACCEPT [158575:227800758]
- :FORWARD ACCEPT [0:0]
- :OUTPUT ACCEPT [46145:2312668]
- :POSTROUTING ACCEPT [46145:2312668]
- COMMIT
- END
- sed -i '$ i\iptables-restore < /etc/iptables.up.rules' /etc/rc.local
- sed -i $MYIP2 /etc/iptables.up.rules;
- iptables-restore < /etc/iptables.up.rules
- # xml parser
- cd
- apt-get install -y libxml-parser-perl
- #import menu
- apt-get install unzip
- cd /usr/bin/
- wget "https://raw.githubusercontent.com/lanundarat87/xxx/main/Res/Menu/bashmenu.zip"
- unzip bashmenu.zip
- chmod +x /usr/bin/*
- sed -i $MYIP2 /usr/bin/user-add-pptp;
- rm bashmenu.zip
- # finishing
- cd
- chown -R www-data:www-data /home/vps/public_html
- /etc/init.d/nginx restart
- /etc/init.d/openvpn restart
- /etc/init.d/cron restart
- /etc/init.d/ssh restart
- /etc/init.d/dropbear restart
- /etc/init.d/fail2ban restart
- /etc/init.d/stunnel4 restart
- service php7.3-fpm restart
- service uwsgi restart
- systemctl daemon-reload
- systemctl restart v2-ui
- service squid restart
- service pptpd restart
- /etc/init.d/webmin restart
- # clearing history
- rm -rf ~/.bash_history && history -c
- echo "unset HISTFILE" >> /etc/profile
- # remove unnecessary files
- apt -y autoremove
- apt -y autoclean
- apt -y clean
- # info
- clear
- echo " "
- echo "INSTALLATION COMPLETE!"
- echo " "
- echo "------------------------- Configuration Setup Server ------------------------"
- echo " Copyright https://t.me/badboy897 "
- echo " Created By Black "
- echo "-----------------------------------------------------------------------------"
- echo "" | tee -a log-install.txt
- echo "Server Information" | tee -a log-install.txt
- echo " - Timezone : Asia/Kuala Lumpur (GMT +8)" | tee -a log-install.txt
- echo " - Fail2Ban : [ON]" | tee -a log-install.txt
- echo " - Dflate : [ON]" | tee -a log-install.txt
- echo " - IPtables : [ON]" | tee -a log-install.txt
- echo " - Auto-Reboot : [OFF]" | tee -a log-install.txt
- echo " - IPv6 : [OFF]" | tee -a log-install.txt
- echo "" | tee -a log-install.txt
- echo "Application & Port Information" | tee -a log-install.txt
- echo " - OpenVPN : TCP 443" | tee -a log-install.txt
- echo " - OpenSSH : 22, 90, 143" | tee -a log-install.txt
- echo " - Stunnel4 : 444" | tee -a log-install.txt
- echo " - Dropbear : 109, 110, 442" | tee -a log-install.txt
- echo " - Squid Proxy : 3128, 8000, 8080, 8888" | tee -a log-install.txt
- echo " - Badvpn : 7300" | tee -a log-install.txt
- echo " - Nginx : 80" | tee -a log-install.txt
- echo "" | tee -a log-install.txt
- echo "Server Tools" | tee -a log-install.txt
- echo " - htop" | tee -a log-install.txt
- echo " - iftop" | tee -a log-install.txt
- echo " - mtr" | tee -a log-install.txt
- echo " - nethogs" | tee -a log-install.txt
- echo " - screenfetch" | tee -a log-install.txt
- echo "" | tee -a log-install.txt
- echo "Premium Script Information" | tee -a log-install.txt
- echo " To display list of commands: menu" | tee -a log-install.txt
- echo " V2ray panel password and username: admin" | tee -a log-install.txt
- echo "" | tee -a log-install.txt
- echo " Explanation of scripts and VPS setup" | tee -a log-install.txt
- echo " follow this link: https://t.me/badboy897/" | tee -a log-install.txt
- echo "" | tee -a log-install.txt
- echo "Important Information" | tee -a log-install.txt
- echo " - Download Config OpenVPN : http://$MYIP/black.ovpn" | tee -a log-install.txt
- echo " - Mirror (*.tar.gz) : http://$MYIP/blackVPN.tar.gz" | tee -a log-install.txt
- echo " - Simple Panel : http://$MYIP/" | tee -a log-install.txt
- echo " - Openvpn Monitor : http://$MYIP:89/" | tee -a log-install.txt
- echo " - V2ray Panel : http://$MYIP:65432/" | tee -a log-install.txt
- echo " - Webmin : http://$MYIP:10000/" | tee -a log-install.txt
- echo " - Installation Log : cat /root/log-install.txt" | tee -a log-install.txt
- echo "" | tee -a log-install.txt
- echo "----------------- Script By Black(https://t.me/badboy897) -----------------"
- echo " Script By Black "
- echo "-----------------------------------------------------------------------------"
|