ssh-vpn.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. #!/bin/bash
  2. #
  3. # ==================================================
  4. # initializing var
  5. export DEBIAN_FRONTEND=noninteractive
  6. MYIP=$(wget -qO- ifconfig.me/ip);
  7. MYIP2="s/xxxxxxxxx/$MYIP/g";
  8. NET=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  9. source /etc/os-release
  10. ver=$VERSION_ID
  11. #detail nama perusahaan
  12. country=ID
  13. state=Indonesia
  14. locality=Indonesia
  15. organization=jhoy.my.id
  16. organizationalunit=www.jhoy.my.id
  17. commonname=www.sundanese.ml
  18. email=admin@jhoy.my.id
  19. # simple password minimal
  20. wget -O /etc/pam.d/common-password "https://raw.githubusercontent.com/anisakansa/project1/main/password"
  21. chmod +x /etc/pam.d/common-password
  22. # go to root
  23. cd
  24. # Getting Proxy Template
  25. wget -q -O /usr/local/bin/edu-proxy https://raw.githubusercontent.com/anisakansa/project1/main/cdn.py
  26. chmod +x /usr/local/bin/edu-proxy
  27. # Installing Service
  28. cat > /etc/systemd/system/edu-proxy.service << END
  29. [Unit]
  30. Description=Python Edu Proxy By Liu Yifey
  31. Documentation=liuuuuufey.my.id
  32. After=network.target nss-lookup.target
  33. [Service]
  34. Type=simple
  35. User=root
  36. CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
  37. AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
  38. NoNewPrivileges=true
  39. ExecStart=/usr/bin/python -O /usr/local/bin/edu-proxy 2095
  40. Restart=on-failure
  41. [Install]
  42. WantedBy=multi-user.target
  43. END
  44. systemctl daemon-reload
  45. systemctl enable edu-proxy
  46. systemctl restart edu-proxy
  47. # Edit file /etc/systemd/system/rc-local.service
  48. cat > /etc/systemd/system/rc-local.service <<-END
  49. [Unit]
  50. Description=/etc/rc.local
  51. ConditionPathExists=/etc/rc.local
  52. [Service]
  53. Type=forking
  54. ExecStart=/etc/rc.local start
  55. TimeoutSec=0
  56. StandardOutput=tty
  57. RemainAfterExit=yes
  58. SysVStartPriority=99
  59. [Install]
  60. WantedBy=multi-user.target
  61. END
  62. # nano /etc/rc.local
  63. cat > /etc/rc.local <<-END
  64. #!/bin/sh -e
  65. # rc.local
  66. # By default this script does nothing.
  67. exit 0
  68. END
  69. # Ubah izin akses
  70. chmod +x /etc/rc.local
  71. # enable rc local
  72. systemctl enable rc-local
  73. systemctl start rc-local.service
  74. # disable ipv6
  75. echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  76. sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
  77. #update
  78. apt update -y
  79. apt upgrade -y
  80. apt dist-upgrade -y
  81. apt-get remove --purge ufw firewalld -y
  82. apt-get remove --purge exim4 -y
  83. # install wget and curl
  84. apt -y install wget curl
  85. # set time GMT +7
  86. ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
  87. # set locale
  88. sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
  89. # install
  90. apt-get --reinstall --fix-missing install -y bzip2 gzip coreutils wget screen rsyslog iftop htop net-tools zip unzip wget net-tools curl nano sed screen gnupg gnupg1 bc apt-transport-https build-essential dirmngr libxml-parser-perl neofetch git lsof
  91. echo "clear" >> .profile
  92. echo "neofetch" >> .profile
  93. echo "echo commant : menu" >> .profile
  94. # install webserver
  95. apt -y install nginx
  96. cd
  97. rm /etc/nginx/sites-enabled/default
  98. rm /etc/nginx/sites-available/default
  99. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/anisakansa/project1/main/nginx.conf"
  100. mkdir -p /home/vps/public_html
  101. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/anisakansa/project1/main/vps.conf"
  102. /etc/init.d/nginx restart
  103. # install badvpn
  104. cd
  105. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/anisakansa/project1/main/badvpn-udpgw64"
  106. chmod +x /usr/bin/badvpn-udpgw
  107. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7100 --max-clients 500' /etc/rc.local
  108. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7200 --max-clients 500' /etc/rc.local
  109. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 500' /etc/rc.local
  110. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7900 --max-clients 500' /etc/bin/wstunnel
  111. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7100 --max-clients 500
  112. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7200 --max-clients 500
  113. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 500
  114. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7400 --max-clients 500
  115. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7500 --max-clients 500
  116. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7600 --max-clients 500
  117. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7700 --max-clients 500
  118. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7800 --max-clients 500
  119. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7900 --max-clients 500
  120. # setting port ssh
  121. sed -i 's/Port 22/Port 22/g' /etc/ssh/sshd_config
  122. # install dropbear
  123. apt -y install dropbear
  124. sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
  125. sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=143/g' /etc/default/dropbear
  126. sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-p 109"/g' /etc/default/dropbear
  127. echo "/bin/false" >> /etc/shells
  128. echo "/usr/sbin/nologin" >> /etc/shells
  129. /etc/init.d/dropbear restart
  130. # install squid
  131. cd
  132. apt -y install squid3
  133. wget -O /etc/squid/squid.conf "https://raw.githubusercontent.com/anisakansa/project1/main/squid3.conf"
  134. sed -i $MYIP2 /etc/squid/squid.conf
  135. # setting vnstat
  136. apt -y install vnstat
  137. /etc/init.d/vnstat restart
  138. apt -y install libsqlite3-dev
  139. wget https://humdi.net/vnstat/vnstat-2.6.tar.gz
  140. tar zxvf vnstat-2.6.tar.gz
  141. cd vnstat-2.6
  142. ./configure --prefix=/usr --sysconfdir=/etc && make && make install
  143. cd
  144. vnstat -u -i $NET
  145. sed -i 's/Interface "'""eth0""'"/Interface "'""$NET""'"/g' /etc/vnstat.conf
  146. chown vnstat:vnstat /var/lib/vnstat -R
  147. systemctl enable vnstat
  148. /etc/init.d/vnstat restart
  149. rm -f /root/vnstat-2.6.tar.gz
  150. rm -rf /root/vnstat-2.6
  151. # install stunnel
  152. apt install stunnel4 -y
  153. cat > /etc/stunnel/stunnel.conf <<-END
  154. cert = /etc/stunnel/stunnel.pem
  155. client = no
  156. socket = a:SO_REUSEADDR=1
  157. socket = l:TCP_NODELAY=1
  158. socket = r:TCP_NODELAY=1
  159. [dropbear]
  160. accept = 443
  161. connect = 127.0.0.1:109
  162. [dropbear]
  163. accept = 777
  164. connect = 127.0.0.1:22
  165. [openvpn]
  166. accept = 442
  167. connect = 127.0.0.1:1194
  168. END
  169. # make a certificate
  170. openssl genrsa -out key.pem 2048
  171. openssl req -new -x509 -key key.pem -out cert.pem -days 1095 \
  172. -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
  173. cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
  174. # konfigurasi stunnel
  175. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
  176. /etc/init.d/stunnel4 restart
  177. #install python
  178. apt -y install python
  179. apt -y install tmux
  180. apt -y install ruby
  181. gem install lolcat
  182. apt -y install figlet
  183. wget -q -O /usr/local/bin/cdn https://raw.githubusercontent.com/anisakansa/project1/main/cdn.py
  184. chmod +x /usr/local/bin/cdn
  185. #OpenVPN
  186. wget https://raw.githubusercontent.com/anisakansa/project1/main/vpn.sh && chmod +x vpn.sh && ./vpn.sh
  187. # install fail2ban
  188. apt -y install fail2ban
  189. # Instal DDOS Flate
  190. if [ -d '/usr/local/ddos' ]; then
  191. echo; echo; echo "Please un-install the previous version first"
  192. exit 0
  193. else
  194. mkdir /usr/local/ddos
  195. fi
  196. clear
  197. echo; echo 'Installing DOS-Deflate 0.6'; echo
  198. echo; echo -n 'Downloading source files...'
  199. wget -q -O /usr/local/ddos/ddos.conf http://www.inetbase.com/scripts/ddos/ddos.conf
  200. echo -n '.'
  201. wget -q -O /usr/local/ddos/LICENSE http://www.inetbase.com/scripts/ddos/LICENSE
  202. echo -n '.'
  203. wget -q -O /usr/local/ddos/ignore.ip.list http://www.inetbase.com/scripts/ddos/ignore.ip.list
  204. echo -n '.'
  205. wget -q -O /usr/local/ddos/ddos.sh http://www.inetbase.com/scripts/ddos/ddos.sh
  206. chmod 0755 /usr/local/ddos/ddos.sh
  207. cp -s /usr/local/ddos/ddos.sh /usr/local/sbin/ddos
  208. echo '...done'
  209. echo; echo -n 'Creating cron to run script every minute.....(Default setting)'
  210. /usr/local/ddos/ddos.sh --cron > /dev/null 2>&1
  211. echo '.....done'
  212. echo; echo 'Installation has completed.'
  213. echo 'Config file is at /usr/local/ddos/ddos.conf'
  214. echo 'Please send in your comments and/or suggestions to zaf@vsnl.com'
  215. # banner /etc/issue.net
  216. wget -O /etc/issue.net "https://raw.githubusercontent.com/anisakansa/project1/main/banner.conf"
  217. echo "Banner /etc/issue.net" >>/etc/ssh/sshd_config
  218. sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
  219. # blockir torrent
  220. iptables -A FORWARD -m string --string "get_peers" --algo bm -j DROP
  221. iptables -A FORWARD -m string --string "announce_peer" --algo bm -j DROP
  222. iptables -A FORWARD -m string --string "find_node" --algo bm -j DROP
  223. iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j DROP
  224. iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP
  225. iptables -A FORWARD -m string --algo bm --string "peer_id=" -j DROP
  226. iptables -A FORWARD -m string --algo bm --string ".torrent" -j DROP
  227. iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP
  228. iptables -A FORWARD -m string --algo bm --string "torrent" -j DROP
  229. iptables -A FORWARD -m string --algo bm --string "announce" -j DROP
  230. iptables -A FORWARD -m string --algo bm --string "info_hash" -j DROP
  231. iptables-save > /etc/iptables.up.rules
  232. iptables-restore -t < /etc/iptables.up.rules
  233. netfilter-persistent save
  234. netfilter-persistent reload
  235. # download script
  236. cd /usr/bin
  237. wget -O add-host "https://raw.githubusercontent.com/anisakansa/project1/main/add-host.sh"
  238. wget -O about "https://raw.githubusercontent.com/anisakansa/project1/main/about.sh"
  239. wget -O usernew "https://raw.githubusercontent.com/anisakansa/project1/main/usernew.sh"
  240. wget -O trial "https://raw.githubusercontent.com/anisakansa/project1/main/trial.sh"
  241. wget -O hapus "https://raw.githubusercontent.com/anisakansa/project1/main/hapus.sh"
  242. wget -O member "https://raw.githubusercontent.com/anisakansa/project1/main/member.sh"
  243. wget -O delete "https://raw.githubusercontent.com/anisakansa/project1/main/delete.sh"
  244. wget -O cek "https://raw.githubusercontent.com/anisakansa/project1/main/cek.sh"
  245. wget -O restart "https://raw.githubusercontent.com/anisakansa/project1/main/restart.sh"
  246. wget -O speedtest "https://raw.githubusercontent.com/anisakansa/project1/main/speedtest_cli.py"
  247. wget -O info "https://raw.githubusercontent.com/anisakansa/project1/main/info.sh"
  248. wget -O ram "https://raw.githubusercontent.com/anisakansa/project1/main/ram.sh"
  249. wget -O renew "https://raw.githubusercontent.com/anisakansa/project1/main/renew.sh"
  250. wget -O autokill "https://raw.githubusercontent.com/anisakansa/project1/main/autokill.sh"
  251. wget -O ceklim "https://raw.githubusercontent.com/anisakansa/project1/main/ceklim.sh"
  252. wget -O tendang "https://raw.githubusercontent.com/anisakansa/project1/main/tendang.sh"
  253. wget -O clear-log "https://raw.githubusercontent.com/anisakansa/project1/main/clear-log.sh"
  254. wget -O change-port "https://raw.githubusercontent.com/anisakansa/project1/main/change.sh"
  255. wget -O port-ovpn "https://raw.githubusercontent.com/anisakansa/project1/main/port-ovpn.sh"
  256. wget -O port-ssl "https://raw.githubusercontent.com/anisakansa/project1/main/port-ssl.sh"
  257. wget -O port-wg "https://raw.githubusercontent.com/anisakansa/project1/main/port-wg.sh"
  258. wget -O port-tr "https://raw.githubusercontent.com/anisakansa/project1/main/port-tr.sh"
  259. wget -O port-sstp "https://raw.githubusercontent.com/anisakansa/project1/main/port-sstp.sh"
  260. wget -O port-squid "https://raw.githubusercontent.com/anisakansa/project1/main/port-squid.sh"
  261. wget -O port-ws "https://raw.githubusercontent.com/anisakansa/project1/main/port-ws.sh"
  262. wget -O port-vless "https://raw.githubusercontent.com/anisakansa/project1/main/port-vless.sh"
  263. wget -O wbmn "https://raw.githubusercontent.com/anisakansa/project1/main/webmin.sh"
  264. wget -O xp "https://raw.githubusercontent.com/anisakansa/project1/main/xp.sh"
  265. wget -O swap "https://raw.githubusercontent.com/anisakansa/project1/main/swapkvm.sh"
  266. wget -O menu "https://raw.githubusercontent.com/anisakansa/project1/main/menu.sh"
  267. wget -O l2tp "https://raw.githubusercontent.com/anisakansa/project1/main/update/l2tp.sh"
  268. wget -O ssh "https://raw.githubusercontent.com/anisakansa/project1/main/update/ssh.sh"
  269. wget -O ssssr "https://raw.githubusercontent.com/anisakansa/project1/main/update/ssssr.sh"
  270. wget -O sstpp "https://raw.githubusercontent.com/anisakansa/project1/main/update/sstpp.sh"
  271. wget -O trojaan "https://raw.githubusercontent.com/anisakansa/project1/main/update/trojaan.sh"
  272. wget -O v2raay "https://raw.githubusercontent.com/anisakansa/project1/main/update/v2raay.sh"
  273. wget -O wgr "https://raw.githubusercontent.com/anisakansa/project1/main/update/wgr.sh"
  274. wget -O vleess "https://raw.githubusercontent.com/anisakansa/project1/main/update/vleess.sh"
  275. wget -O bbr "https://raw.githubusercontent.com/anisakansa/project1/main/update/bbr.sh"
  276. wget -O bannerku "https://raw.githubusercontent.com/anisakansa/project1/main/bannerku"
  277. wget -O update "https://raw.githubusercontent.com/anisakansa/project1/main/update.sh"
  278. wget -O /usr/bin/user-limit https://raw.githubusercontent.com/anisakansa/project1/main/user-limit.sh && chmod +x /usr/bin/user-limit
  279. chmod +x add-host
  280. chmod +x usernew
  281. chmod +x trial
  282. chmod +x hapus
  283. chmod +x member
  284. chmod +x delete
  285. chmod +x cek
  286. chmod +x restart
  287. chmod +x speedtest
  288. chmod +x info
  289. chmod +x about
  290. chmod +x autokill
  291. chmod +x tendang
  292. chmod +x ceklim
  293. chmod +x ram
  294. chmod +x renew
  295. chmod +x clear-log
  296. chmod +x change-port
  297. chmod +x port-ovpn
  298. chmod +x port-ssl
  299. chmod +x port-wg
  300. chmod +x port-sstp
  301. chmod +x port-tr
  302. chmod +x port-squid
  303. chmod +x port-ws
  304. chmod +x port-vless
  305. chmod +x wbmn
  306. chmod +x xp
  307. chmod +x swap
  308. chmod +x menu
  309. chmod +x l2tp
  310. chmod +x ssh
  311. chmod +x vleess
  312. chmod +x ssssr
  313. chmod +x sstpp
  314. chmod +x trojaan
  315. chmod +x v2raay
  316. chmod +x wgr
  317. chmod +x bbr
  318. chmod +x bannerku
  319. chmod +x update
  320. echo "0 5 * * * root clear-log" >> /etc/crontab
  321. echo "0 0 * * * root xp" >> /etc/crontab
  322. # remove unnecessary files
  323. cd
  324. apt autoclean -y
  325. apt -y remove --purge unscd
  326. apt-get -y --purge remove samba*;
  327. apt-get -y --purge remove apache2*;
  328. apt-get -y --purge remove bind9*;
  329. apt-get -y remove sendmail*
  330. apt autoremove -y
  331. # finishing
  332. cd
  333. chown -R www-data:www-data /home/vps/public_html
  334. /etc/init.d/nginx restart
  335. /etc/init.d/openvpn restart
  336. /etc/init.d/cron restart
  337. /etc/init.d/ssh restart
  338. /etc/init.d/dropbear restart
  339. /etc/init.d/fail2ban restart
  340. /etc/init.d/stunnel4 restart
  341. /etc/init.d/vnstat restart
  342. /etc/init.d/squid restart
  343. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7100 --max-clients 500
  344. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7200 --max-clients 500
  345. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 500
  346. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7400 --max-clients 500
  347. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7500 --max-clients 500
  348. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7600 --max-clients 500
  349. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7700 --max-clients 500
  350. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7800 --max-clients 500
  351. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7900 --max-clients 500
  352. history -c
  353. echo "unset HISTFILE" >> /etc/profile
  354. cd
  355. rm -f /root/key.pem
  356. rm -f /root/cert.pem
  357. rm -f /root/ssh-vpn.sh
  358. # finihsing
  359. clear