squid 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. #!/bin/bash
  2. # initializing var
  3. export DEBIAN_FRONTEND=noninteractive
  4. MYIP=$(wget -qO- ipinfo.io/ip);
  5. MYIP2="s/xxxxxxxxx/$MYIP/g";
  6. NET=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  7. source /etc/os-release
  8. ver=$VERSION_ID
  9. ServerName='Aidan-VPN'
  10. # OpenSSH Ports
  11. SSH_Port1='22'
  12. SSH_Port2='299'
  13. # Dropbear Ports
  14. Dropbear_Port1='790'
  15. Dropbear_Port2='2770'
  16. # Stunnel Ports
  17. Stunnel_Port1='446' # through Dropbear
  18. Stunnel_Port2='444' # through OpenSSH
  19. Stunnel_Port3='445' # through Openvpn
  20. # OpenVPN Ports
  21. OpenVPN_TCP_Port='1720'
  22. OpenVPN_UDP_Port='3900'
  23. # Privoxy Ports
  24. Privoxy_Port1='9880'
  25. Privoxy_Port2='3100'
  26. # Squid Ports
  27. Squid_Port1='3233'
  28. Squid_Port2='7003'
  29. Squid_Port3='9005'
  30. #detail nama perusahaan
  31. country=MY
  32. state=Selangor
  33. locality=Gombak
  34. organization=Aidan-Tech
  35. organizationalunit=Platform-Team
  36. commonname=AidanVPN
  37. email=irwanmohi@gmail.com
  38. #Server Name for openvpn config and banner
  39. ServerName='Aidan-VPN'
  40. # OpenSSH Ports
  41. SSH_Port1='22'
  42. SSH_Port2='299'
  43. # Dropbear Ports
  44. Dropbear_Port1='790'
  45. Dropbear_Port2='2770'
  46. # Stunnel Ports
  47. Stunnel_Port1='446' # through Dropbear
  48. Stunnel_Port2='444' # through OpenSSH
  49. Stunnel_Port3='445' # through Openvpn
  50. # OpenVPN Ports
  51. OpenVPN_TCP_Port='1720'
  52. OpenVPN_UDP_Port='3900'
  53. # Privoxy Ports
  54. Privoxy_Port1='9880'
  55. Privoxy_Port2='3100'
  56. # Squid Ports
  57. Squid_Port1='3233'
  58. Squid_Port2='7003'
  59. Squid_Port3='9005'
  60. # Installing some important machine essentials
  61. apt-get install nano sudo wget curl zip unzip tar psmisc build-essential gzip iptables p7zip-full bc rc openssl cron net-tools dnsutils lsof dos2unix lrzsz git qrencode libcap2-bin dbus whois ngrep screen bzip2 ccrypt curl gcc automake autoconf libxml-parser-perl make libtool ruby -y
  62. # Now installing all our wanted services
  63. apt-get install dropbear stunnel4 squid privoxy ca-certificates nginx apt-transport-https lsb-release python python-pip python3-pip python-dev python-setuptools libssl-dev -y
  64. pip install shadowsocks
  65. pip3 install shadowsocks
  66. # Installing all required packages to install Webmin
  67. apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python dbus libxml-parser-perl shared-mime-info jq fail2ban -y
  68. # Installing a text colorizer and design
  69. gem install lolcat
  70. apt-get install figlet
  71. # Removing some duplicated sshd server configs
  72. rm -f /etc/ssh/sshd_config
  73. sleep 1
  74. # Creating a SSH server config using cat eof tricks
  75. cat <<'MySSHConfig' > /etc/ssh/sshd_config
  76. # Project FOG OpenSSH Server config
  77. # -blackestsaint
  78. Port myPORT1
  79. Port myPORT2
  80. AddressFamily inet
  81. ListenAddress 0.0.0.0
  82. HostKey /etc/ssh/ssh_host_rsa_key
  83. HostKey /etc/ssh/ssh_host_ecdsa_key
  84. HostKey /etc/ssh/ssh_host_ed25519_key
  85. PermitRootLogin yes
  86. MaxSessions 1024
  87. PubkeyAuthentication yes
  88. PasswordAuthentication yes
  89. PermitEmptyPasswords no
  90. ChallengeResponseAuthentication no
  91. UsePAM yes
  92. X11Forwarding yes
  93. PrintMotd no
  94. ClientAliveInterval 300
  95. ClientAliveCountMax 2
  96. UseDNS no
  97. Banner /etc/zorro-luffy
  98. AcceptEnv LANG LC_*
  99. Subsystem sftp /usr/lib/openssh/sftp-server
  100. MySSHConfig
  101. sleep 2
  102. # Now we'll put our ssh ports inside of sshd_config
  103. sed -i "s|myPORT1|$SSH_Port1|g" /etc/ssh/sshd_config
  104. sed -i "s|myPORT2|$SSH_Port2|g" /etc/ssh/sshd_config
  105. # My workaround code to remove `BAD Password error` from passwd command, it will fix password-related error on their ssh accounts.
  106. sed -i '/password\s*requisite\s*pam_cracklib.s.*/d' /etc/pam.d/common-password
  107. sed -i 's/use_authtok //g' /etc/pam.d/common-password
  108. # Some command to identify null shells when you tunnel through SSH or using Stunnel, it will fix user/pass authentication error on HTTP Injector, KPN Tunnel, eProxy, SVI, HTTP Proxy Injector etc ssh/ssl tunneling apps.
  109. sed -i '/\/bin\/false/d' /etc/shells
  110. sed -i '/\/usr\/sbin\/nologin/d' /etc/shells
  111. echo '/bin/false' >> /etc/shells
  112. echo '/usr/sbin/nologin' >> /etc/shells
  113. # Restarting openssh service
  114. systemctl restart ssh
  115. # Removing some duplicate config file
  116. rm -rf /etc/default/dropbear*
  117. # creating dropbear config using cat eof tricks
  118. cat <<'MyDropbear' > /etc/default/dropbear
  119. # Project FOG Dropbear Config
  120. NO_START=0
  121. DROPBEAR_PORT=PORT01
  122. DROPBEAR_EXTRA_ARGS="-p PORT02"
  123. DROPBEAR_BANNER="/etc/zorro-luffy"
  124. DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key"
  125. DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key"
  126. DROPBEAR_ECDSAKEY="/etc/dropbear/dropbear_ecdsa_host_key"
  127. DROPBEAR_RECEIVE_WINDOW=65536
  128. MyDropbear
  129. # Now changing our desired dropbear ports
  130. sed -i "s|PORT01|$Dropbear_Port1|g" /etc/default/dropbear
  131. sed -i "s|PORT02|$Dropbear_Port2|g" /etc/default/dropbear
  132. # Restarting dropbear service
  133. systemctl restart dropbear
  134. # Removing Duplicate privoxy config
  135. rm -rf /etc/privoxy/config*
  136. # Creating Privoxy server config using cat eof tricks
  137. cat <<'privoxy' > /etc/privoxy/config
  138. # My Privoxy Server Config
  139. user-manual /usr/share/doc/privoxy/user-manual
  140. confdir /etc/privoxy
  141. logdir /var/log/privoxy
  142. filterfile default.filter
  143. logfile logfile
  144. listen-address 0.0.0.0:Privoxy_Port1
  145. listen-address 0.0.0.0:Privoxy_Port2
  146. toggle 1
  147. enable-remote-toggle 0
  148. enable-remote-http-toggle 0
  149. enable-edit-actions 0
  150. enforce-blocks 0
  151. buffer-limit 4096
  152. enable-proxy-authentication-forwarding 1
  153. forwarded-connect-retries 1
  154. accept-intercepted-requests 1
  155. allow-cgi-request-crunching 1
  156. split-large-forms 0
  157. keep-alive-timeout 5
  158. tolerate-pipelining 1
  159. socket-timeout 300
  160. permit-access 0.0.0.0/0 IP-ADDRESS
  161. privoxy
  162. # Setting machine's IP Address inside of our privoxy config(security that only allows this machine to use this proxy server)
  163. sed -i "s|IP-ADDRESS|$IPADDR|g" /etc/privoxy/config
  164. # Setting privoxy ports
  165. sed -i "s|Privoxy_Port1|$Privoxy_Port1|g" /etc/privoxy/config
  166. sed -i "s|Privoxy_Port2|$Privoxy_Port2|g" /etc/privoxy/config
  167. # Starting Proxy server
  168. echo -e "Restarting Privoxy Proxy server..."
  169. systemctl restart privoxy
  170. # Removing Duplicate Squid config
  171. rm -rf /etc/squid/squid.con*
  172. # My Squid Proxy Server Config
  173. acl VPN dst IP-ADDRESS/32
  174. http_access allow VPN
  175. http_access deny all
  176. http_port 0.0.0.0:Squid_Port1
  177. http_port 0.0.0.0:Squid_Port2
  178. http_port 0.0.0.0:Squid_Port3
  179. ### Allow Headers
  180. request_header_access Allow allow all
  181. request_header_access Authorization allow all
  182. request_header_access WWW-Authenticate allow all
  183. request_header_access Proxy-Authorization allow all
  184. request_header_access Proxy-Authenticate allow all
  185. request_header_access Cache-Control allow all
  186. request_header_access Content-Encoding allow all
  187. request_header_access Content-Length allow all
  188. request_header_access Content-Type allow all
  189. request_header_access Date allow all
  190. request_header_access Expires allow all
  191. request_header_access Host allow all
  192. request_header_access If-Modified-Since allow all
  193. request_header_access Last-Modified allow all
  194. request_header_access Location allow all
  195. request_header_access Pragma allow all
  196. request_header_access Accept allow all
  197. request_header_access Accept-Charset allow all
  198. request_header_access Accept-Encoding allow all
  199. request_header_access Accept-Language allow all
  200. request_header_access Content-Language allow all
  201. request_header_access Mime-Version allow all
  202. request_header_access Retry-After allow all
  203. request_header_access Title allow all
  204. request_header_access Connection allow all
  205. request_header_access Proxy-Connection allow all
  206. request_header_access User-Agent allow all
  207. request_header_access Cookie allow all
  208. request_header_access All deny all
  209. ### HTTP Anonymizer Paranoid
  210. reply_header_access Allow allow all
  211. reply_header_access Authorization allow all
  212. reply_header_access WWW-Authenticate allow all
  213. reply_header_access Proxy-Authorization allow all
  214. reply_header_access Proxy-Authenticate allow all
  215. reply_header_access Cache-Control allow all
  216. reply_header_access Content-Encoding allow all
  217. reply_header_access Content-Length allow all
  218. reply_header_access Content-Type allow all
  219. reply_header_access Date allow all
  220. reply_header_access Expires allow all
  221. reply_header_access Host allow all
  222. reply_header_access If-Modified-Since allow all
  223. reply_header_access Last-Modified allow all
  224. reply_header_access Location allow all
  225. reply_header_access Pragma allow all
  226. reply_header_access Accept allow all
  227. reply_header_access Accept-Charset allow all
  228. reply_header_access Accept-Encoding allow all
  229. reply_header_access Accept-Language allow all
  230. reply_header_access Content-Language allow all
  231. reply_header_access Mime-Version allow all
  232. reply_header_access Retry-After allow all
  233. reply_header_access Title allow all
  234. reply_header_access Connection allow all
  235. reply_header_access Proxy-Connection allow all
  236. reply_header_access User-Agent allow all
  237. reply_header_access Cookie allow all
  238. reply_header_access All deny all
  239. #Korn
  240. cache_mem 200 MB
  241. maximum_object_size_in_memory 32 KB
  242. maximum_object_size 1024 MB
  243. minimum_object_size 0 KB
  244. cache_swap_low 90
  245. cache_swap_high 95
  246. cache_dir ufs /var/spool/squid 100 16 256
  247. access_log /var/log/squid/access.log squid
  248. ### CoreDump
  249. coredump_dir /var/spool/squid
  250. dns_nameservers 1.1.1.1 1.0.0.1
  251. refresh_pattern ^ftp: 1440 20% 10080
  252. refresh_pattern ^gopher: 1440 0% 1440
  253. refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
  254. refresh_pattern . 0 20% 4320
  255. visible_hostname aidanvpn
  256. mySquid
  257. # Setting machine's IP Address inside of our Squid config(security that only allows this machine to use this proxy server)
  258. sed -i "s|IP-ADDRESS|$IPADDR|g" /etc/squid/squid.conf
  259. # Setting squid ports
  260. sed -i "s|Squid_Port1|$Squid_Port1|g" /etc/squid/squid.conf
  261. sed -i "s|Squid_Port2|$Squid_Port2|g" /etc/squid/squid.conf
  262. sed -i "s|Squid_Port3|$Squid_Port3|g" /etc/squid/squid.conf
  263. # Starting Proxy server
  264. echo -e "Restarting Squid Proxy server..."
  265. systemctl restart squid
  266. chmod +x ./*
  267. dos2unix ./* &> /dev/null
  268. sed -i 's|/etc/squid/squid.conf|/etc/privoxy/config|g' ./*
  269. sed -i 's|http_port|listen-address|g' ./*
  270. cd ~