ssh-vpn.sh 15 KB

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