ovpnserv.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. MYIP=$(wget -qO- ipv4.icanhazip.com);
  2. : '
  3. # check registered ip
  4. wget -q -O daftarip http://188.166.215.119:85/ocs/ip.txt
  5. if ! grep -w -q $MYIP daftarip; then
  6. echo "Sorry, only registered IPs can use this script!"
  7. if [[ $vps = "vps" ]]; then
  8. echo "Modified by Laughingc4t"
  9. else
  10. echo "Modified by Laughingc4t"
  11. fi
  12. rm -f /root/daftarip
  13. exit
  14. fi
  15. '
  16. # initialisasi var
  17. export DEBIAN_FRONTEND=noninteractive
  18. OS=`uname -m`;
  19. MYIP=$(wget -qO- ipv4.icanhazip.com);
  20. MYIP2="s/xxxxxxxxx/$MYIP/g";
  21. #detail nama perusahaan
  22. country=Malaysia
  23. state=Selangor
  24. locality=ShahAlam
  25. organization=AibotecSdnBhd
  26. organizationalunit=IT
  27. commonname=Laughingc4t
  28. email=support@aibotec.net
  29. # go to root
  30. cd
  31. # disable ipv6
  32. echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  33. sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
  34. # install wget and curl
  35. apt-get update;apt-get -y install wget curl;
  36. # set time GMT +8
  37. ln -fs /usr/share/zoneinfo/Asia/KualaLumpur /etc/localtime
  38. # set locale
  39. sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
  40. service ssh restart
  41. #set Repository
  42. sh -c 'echo "deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list'
  43. wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add -
  44. # update
  45. apt-get update
  46. # install webserver
  47. apt-get -y install nginx php5-fpm php5-cli
  48. # install essential package
  49. apt-get -y install nano iptables dnsutils openvpn screen whois ngrep unzip unrar
  50. apt-get install htop
  51. apt-get install iftop
  52. echo "clear" >> .bashrc
  53. echo 'echo -e " __ ____ _ ______ _ __ " | lolcat' >> .bashrc
  54. echo 'echo -e " _____/ /_ ___ ____ ____ / __ \ | / / __ \/ | / / " | lolcat' >> .bashrc
  55. echo 'echo -e " / ___/ __ \/ _ \/ __ \/ __ \ / / / / | / / /_/ / |/ / " | lolcat' >> .bashrc
  56. echo 'echo -e "/ /__/ / / / __/ /_/ / /_/ / / /_/ /| |/ / ____/ /| / " | lolcat' >> .bashrc
  57. echo 'echo -e "\___/_/ /_/\___/\__,_/ .___/ \____/ |___/_/ /_/ |_/ " | lolcat' >> .bashrc
  58. echo 'echo -e " /_/ " | lolcat' >> .bashrc
  59. echo 'echo -e ""' >> .bashrc
  60. echo 'echo -e "+ -- --=[ By Laughingc4t ]=-- -- +" | lolcat' >> .bashrc
  61. echo 'echo -e ""' >> .bashrc
  62. # install webserver
  63. cd
  64. rm /etc/nginx/sites-enabled/default
  65. rm /etc/nginx/sites-available/default
  66. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/nginx.conf"
  67. mkdir -p /home/vps/public_html
  68. echo "<pre>Powered By: Lauhingcat & Aibotec Sdn Bhd</pre>" > /home/vps/public_html/index.html
  69. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/vps.conf"
  70. service nginx restart
  71. # install openvpn
  72. wget -O /etc/openvpn/openvpn.tar "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/openvpn-debian.tar"
  73. cd /etc/openvpn/
  74. tar xf openvpn.tar
  75. wget -O /etc/openvpn/umo.conf "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/umo.conf"
  76. wget -O /etc/openvpn/1194.conf "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/1194.conf"
  77. service openvpn restart
  78. sysctl -w net.ipv4.ip_forward=1
  79. sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
  80. iptables -t nat -I POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
  81. iptables-save > /etc/iptables_yg_baru_dibikin.conf
  82. wget -O /etc/network/if-up.d/iptables "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/iptables"
  83. chmod +x /etc/network/if-up.d/iptables
  84. service openvpn restart
  85. # Configure openvpn
  86. cd /etc/openvpn/
  87. wget -O /etc/openvpn/client.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/client-1194.conf"
  88. wget -O /etc/openvpn/umo-db.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/umo-db.conf"
  89. wget -O /etc/openvpn/umo-ssh.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/umo-ssh.conf"
  90. wget -O /etc/openvpn/maxis-db.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/maxis-db.conf"
  91. wget -O /etc/openvpn/maxis-ssh.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/maxis-ssh.conf"
  92. wget -O /etc/openvpn/digi-db.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/digi-db.conf"
  93. wget -O /etc/openvpn/digi-ssh.ovpn "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/digi-ssh.conf"
  94. sed -i $MYIP2 /etc/openvpn/client.ovpn;
  95. cp client.ovpn,umo-db.ovpn,umo-ssh.ovpn,maxis-db.ovpn,maxis-ssh.ovpn,digi-db.ovpn,digi-ssh.ovpn /home/vps/public_html/
  96. # install badvpn
  97. cd
  98. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/badvpn-udpgw"
  99. if [ "$OS" == "x86_64" ]; then
  100. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/badvpn-udpgw64"
  101. fi
  102. sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300' /etc/rc.local
  103. chmod +x /usr/bin/badvpn-udpgw
  104. screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300
  105. # setting port ssh
  106. cd
  107. sed -i 's/Port 22/Port 22/g' /etc/ssh/sshd_config
  108. sed -i '/Port 22/a Port 444' /etc/ssh/sshd_config
  109. service ssh restart
  110. # install dropbear
  111. apt-get -y install dropbear
  112. sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
  113. sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=3128/g' /etc/default/dropbear
  114. sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-p 143"/g' /etc/default/dropbear
  115. echo "/bin/false" >> /etc/shells
  116. echo "/usr/sbin/nologin" >> /etc/shells
  117. service ssh restart
  118. service dropbear restart
  119. # install squid3
  120. cd
  121. apt-get -y install squid3
  122. wget -O /etc/squid3/squid.conf "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/squid3.conf"
  123. sed -i $MYIP2 /etc/squid3/squid.conf;
  124. service squid3 restart
  125. # install webmin
  126. cd
  127. wget "../Configuration/webmin_1.900_all.deb"
  128. dpkg --install webmin_1.900_all.deb;
  129. apt-get -y -f install;
  130. sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
  131. rm /root/webmin_1.900_all.deb
  132. service webmin restart
  133. #service vnstat restart
  134. #apt-get -y --force-yes -f install libxml-parser-perl
  135. # install stunnel4 From Premium Script
  136. apt-get -y install stunnel4
  137. wget -O /etc/stunnel/stunnel.pem "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/stunnel.pem"
  138. wget -O /etc/stunnel/stunnel.conf "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Configuration/stunnel.conf"
  139. sed -i $MYIP2 /etc/stunnel/stunnel.conf
  140. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
  141. service stunnel4 restart
  142. # Install Ruby & lolcat
  143. apt-get -y install ruby
  144. gem install lolcat
  145. # install
  146. apt-get -y install fail2ban python-pyinotify
  147. service fail2ban restart
  148. # install ddos deflate
  149. cd
  150. apt-get -y install dnsutils dsniff
  151. wget https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/ddos-deflate-master.zip
  152. unzip ddos-deflate-master.zip
  153. cd ddos-deflate-master
  154. ./install.sh
  155. rm -rf /root/ddos-deflate-master.zip
  156. # bannerrm /etc/issue.net
  157. wget -O /etc/issue.net "../issues.net"
  158. sed -i 's@#Banner@Banner@g' /etc/ssh/sshd_config
  159. sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
  160. service ssh restart
  161. service dropbear restart
  162. #xml parser
  163. cd
  164. apt-get -y --force-yes -f install libxml-parser-perl
  165. # download script
  166. cd /usr/bin
  167. #wget -O menu "https://raw.githubusercontent.com/KleKlai/VPS-OpenVPN-Autoscript/master/Components/menu.sh"
  168. wget -O menu "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/menu.sh"
  169. wget -O usernew "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/usernew.sh"
  170. wget -O trial "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/trial.sh"
  171. wget -O delete "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/hapus.sh"
  172. wget -O check "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/user-login.sh"
  173. wget -O member "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/user-list.sh"
  174. wget -O restart "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/resvis.sh"
  175. wget -O speedtest "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/speedtest_cli.py"
  176. wget -O info "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/info.sh"
  177. wget -O about "https://raw.githubusercontent.com/azfarmiskam/ovpn_autoscript/master/Components/about.sh"
  178. echo "0 0 * * * root /sbin/reboot" > /etc/cron.d/reboot
  179. # converting to executable
  180. chmod +x menu
  181. chmod +x usernew
  182. chmod +x trial
  183. chmod +x delete
  184. chmod +x check
  185. chmod +x member
  186. chmod +x restart
  187. chmod +x speedtest
  188. chmod +x info
  189. chmod +x about
  190. # Finalizing
  191. cd
  192. chown -R www-data:www-data /home/vps/public_html
  193. service nginx start
  194. service openvpn restart
  195. service cron restart
  196. service ssh restart
  197. service dropbear restart
  198. service squid3 restart
  199. service webmin restart
  200. rm -rf ~/.bash_history && history -c
  201. echo "unset HISTFILE" >> /etc/profile
  202. # Install neofetch
  203. echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
  204. curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
  205. apt-get update
  206. apt-get install neofetch
  207. echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
  208. curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
  209. apt-get update
  210. apt-get install neofetch
  211. # info
  212. clear
  213. echo 'echo -e "+ -- --=[ Your Virtual Private Server is now up and running ]=-- -- +"' >> .bashrc
  214. echo ""
  215. echo "--------------Server Configuration Details---------------"
  216. echo "Application & Ports" | tee -a log-install.txt
  217. echo ""
  218. echo " OpenSSH : 22, 444" | tee -a log-install.txt
  219. echo " Dropbear : 143, 3128" | tee -a log-install.txt
  220. echo " SSL : 443" | tee -a log-install.txt
  221. echo " Squid3 : 8000, 8080 (limit to IP SSH)" | tee -a log-install.txt
  222. echo " OpenVpn: TCP (1194)" | tee -a log-install.txt
  223. echo " Badvpn : badvpn-udpgw port (7300)" | tee -a log-install.txt
  224. echo " Nginx : 81" | tee -a log-install.txt
  225. echo ""
  226. echo "Application & Ports" | tee -a log-install.txt
  227. echo ""
  228. echo "Linux Utility" | tee -a log-install.txt
  229. echo ""
  230. echo " htop" | tee -a log-install.txt
  231. echo " iftop" | tee -a log-install.txt
  232. echo ""
  233. echo "Extended Information" | tee -a log-install.txt
  234. echo " Webmin : http://$MYIP:10000/" | tee -a log-install.txt
  235. echo " Timezone : Asia/KualaLumpur (GMT +8)" | tee -a log-install.txt
  236. echo " IPv6 : OFF" | tee -a log-install.txt
  237. echo " DDOS Protection : Enable" | tee -a log-install.txt
  238. echo " Payload Ready : Enable" | tee -a log-install.txt
  239. echo " SSH Protection : Enable" | tee -a log-install.txt
  240. echo " Installation log: /root/log-install.txt" | tee -a log-install.txt
  241. echo ""
  242. echo "---------------------- Thank You ------------------------"
  243. echo "---------------------------------------------------------"
  244. cd
  245. rm -f /root/debian7.sh