ssh-vpn.sh 14 KB

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