Advertisement
teknisiazza

autosquidstep2.sh

Oct 26th, 2016
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.33 KB | None | 0 0
  1. #!/bin/bash
  2. apt-get update
  3. apt-get install build-essential devscripts libcppunit-dev openssl libssl-dev libcap-dev libsasl2-dev ccze pkg-config libkrb5-dev -y
  4. wget http://www.measurement-factory.com/tmp/ecap/libecap-1.0.0.tar.gz
  5. tar xzvf libecap-1.0.0.tar.gz
  6. cd libecap-1.0.0
  7. ./configure && make && make install
  8. echo '/usr/local/lib' >> /etc/ld.so.conf
  9. ldconfig
  10. cd
  11. wget --no-check-certificate -O ecap_adapter_DSI.tgz https://www.dropbox.com/s/z4levwr2frun3c9/ecap_adapter_DSI.tgz?dl=0
  12. tar xzvf ecap_adapter_DSI.tgz
  13. cd ecap_adapter_sample-1.0.0
  14. ./configure && make && make install
  15. cd
  16. wget http://www.squid-cache.org/Versions/v3/3.5/squid-3.5.24.tar.gz
  17. tar xzvf squid-3.5.24.tar.gz
  18. wget -O squid_forgery.patch http://www.squid-cache.org/mail-archive/squid-users/201404/att-0240/squid_forgery.patch.txt
  19. cd squid-3.5.24
  20. patch -p0 <../squid_forgery.patch
  21. ./configure --prefix=/usr \
  22. --bindir=/usr/bin \
  23. --sbindir=/usr/sbin \
  24. --libexecdir=/usr/lib/squid \
  25. --sysconfdir=/etc/squid \
  26. --localstatedir=/var \
  27. --libdir=/usr/lib \
  28. --includedir=/usr/include \
  29. --datadir=/usr/share/squid \
  30. --mandir=/usr/share/man \
  31. --enable-storeio=ufs,aufs,diskd,rock \
  32. --enable-removal-policies=lru,heap \
  33. --enable-stacktrace \
  34. --enable-zph=qos \
  35. --enable-ssl-crtd \
  36. --enable-ecap \
  37. --disable-ident-lookup \
  38. --disable-auth \
  39. --disable-auth-basic \
  40. --disable-auth-digest \
  41. --disable-auth-negotiate \
  42. --disable-auth-ntlm \
  43. --disable-url-rewriter-helpers \
  44. --disable-storeid-rewrite-helpers \
  45. --with-logdir=/var/log/squid \
  46. --with-pid-file=/var/run/squid.pid \
  47. --with-swap-dir=/var/spool/squid \
  48. --with-large-files \
  49. --with-openssl
  50. make
  51. make install
  52. chown -R nobody /var/log/squid
  53. chown -R nobody /var/spool/squid
  54. mkdir -p /etc/squid/ssl_cert
  55. openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout /etc/squid/ssl_cert/warnet.pem -out /etc/squid/ssl_cert/warnet.pem -subj "/C=ID/ST=Sumatera Utara/L=Medan/O=DSI/CN=Dokter Squid Indonesia"
  56. openssl x509 -in /etc/squid/ssl_cert/warnet.pem -outform DER -out /etc/squid/ssl_cert/warnet.der
  57. openssl x509 -in /etc/squid/ssl_cert/warnet.pem -outform DER -out /etc/squid/ssl_cert/warnet.crt
  58. /usr/lib/squid/ssl_crtd -c -s /var/lib/ssl_db
  59. chown -R nobody /var/lib/ssl_db
  60. echo '#
  61. # Recommended minimum configuration:
  62. #
  63.  
  64. # Example rule allowing access from your local networks.
  65. # Adapt to list your (internal) IP networks from where browsing
  66. # should be allowed
  67. acl localnet src 10.0.0.0/8
  68. acl localnet src 172.16.0.0/12
  69. acl localnet src 192.168.0.0/16
  70. acl localnet src fc00::/7
  71. acl localnet src fe80::/10
  72.  
  73. acl SSL_ports port 443
  74. acl Safe_ports port 80
  75. acl Safe_ports port 21
  76. acl Safe_ports port 443
  77. acl Safe_ports port 70
  78. acl Safe_ports port 210
  79. acl Safe_ports port 1025-65535
  80. acl Safe_ports port 280
  81. acl Safe_ports port 488
  82. acl Safe_ports port 591
  83. acl Safe_ports port 777
  84. acl CONNECT method CONNECT
  85.  
  86. acl step1 at_step SslBump1
  87. acl step2 at_step SslBump2
  88. acl step3 at_step SslBump3
  89.  
  90. acl PURGE method PURGE
  91.  
  92. #http://empire.goodgamestudios.com/
  93. #acl bypass_ssl dst 37.48.88.132
  94.  
  95. #BBM-http://bgp.he.net/search?search%5Bsearch%5D=blackberry+messenger&commit=Search
  96. #acl bypass_ssl dst 68.171.224.0/19 #BBM
  97. #acl bypass_ssl dst 74.82.64.0/19 #BBM
  98.  
  99.  
  100.  
  101. #
  102. # Recommended minimum Access Permission configuration:
  103. #
  104. # Deny requests to certain unsafe ports
  105. http_access deny !Safe_ports
  106.  
  107. # Deny CONNECT to other than secure SSL ports
  108. http_access deny CONNECT !SSL_ports
  109.  
  110. # Only allow cachemgr access from localhost
  111. http_access allow localhost manager
  112. http_access deny manager
  113.  
  114. # We strongly recommend the following be uncommented to protect innocent
  115. # web applications running on the proxy server who think the only
  116. # one who can access services on "localhost" is a local user
  117. #http_access deny to_localhost
  118.  
  119. http_access allow localhost purge
  120. http_access deny purge
  121.  
  122. #
  123. # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
  124. #
  125.  
  126. # Example rule allowing access from your local networks.
  127. # Adapt localnet in the ACL section to list your (internal) IP networks
  128. # from where browsing should be allowed
  129. http_access allow localnet
  130. http_access allow localhost
  131.  
  132. # And finally deny all other access to this proxy
  133. http_access deny all
  134.  
  135. # Squid normally listens to port 3128 (forward proxy)
  136. http_port 3128
  137.  
  138. #SSL Tunnel
  139. http_port 3127 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/warnet.pem
  140.  
  141. #transparent proxy intercept
  142. #http_port 3129 intercept
  143. #https_port 3127 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/warnet.pem
  144.  
  145. #transparent proxy tproxy
  146. #http_port 3129 tproxy
  147. #https_port 3127 tproxy ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/warnet.pem
  148.  
  149. #caching konten https
  150. #ssl_bump splice bypass_ssl
  151. ssl_bump peek step1 all
  152. ssl_bump bump all
  153.  
  154. #opsi caching konten https
  155. sslproxy_cert_error allow all
  156. sslproxy_flags DONT_VERIFY_PEER
  157. sslproxy_options NO_SSLv2,NO_SSLv3,SINGLE_ECDH_USE #Jika menggunakan versi setelah squid-3.5.12-20151222-r13967
  158. sslproxy_cipher EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:HIGH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS
  159.  
  160. # Uncomment and adjust the following to add a disk cache directory.
  161. cache_dir aufs /var/spool/squid 1000 16 256
  162. cache_mem 16 MB
  163.  
  164. cache_swap_low 97
  165. cache_swap_high 98
  166. cache_replacement_policy heap LFUDA
  167. memory_replacement_policy heap GDSF
  168.  
  169. #Maximum Object Size
  170. maximum_object_size 1024 MB
  171. maximum_object_size_in_memory 1024 KB
  172.  
  173. #partial 206
  174. #range_offset_limit 1 MB
  175. #atau (pilih salah satu)
  176. #request_header_access Range deny all
  177.  
  178. #Administrative
  179. cache_mgr admin_squid@dokter-squid.com
  180. visible_hostname s-proxy1-dsi
  181.  
  182. # Leave coredumps in the first cache dir
  183. coredump_dir /var/log/squid
  184.  
  185. #debugging
  186. strip_query_terms off
  187. #debug_options 11,2 22,3
  188. logfile_rotate 1
  189. #cache_store_log /var/log/squid/store.log
  190.  
  191.  
  192. #ecap
  193. #yt_quality: tiny = 144px small = 240px medium = 360px large = 480px HD720 = Hd720px
  194. acl youtube_240 dstdomain .youtube.com
  195. request_header_access Accept-Encoding deny youtube_240
  196. loadable_modules /usr/local/lib/ecap_adapter_modifying.so
  197. ecap_enable on
  198. ecap_service ecapModifier respmod_precache uri=ecap://dokter-squid.com/ecap yt_quality=small
  199. adaptation_access ecapModifier allow youtube_240
  200. adaptation_access ecapModifier deny all
  201.  
  202. #storeid
  203. acl getmethod method GET
  204. acl loop_302 http_status 302
  205.  
  206.  
  207. acl youtube url_regex -i ^http.*\.googlevideo\.com\/videoplayback\?
  208.  
  209. send_hit deny loop_302
  210.  
  211. store_id_program /etc/squid/storeid.pl
  212. store_id_children 50 startup=5 idle=2 concurrency=200
  213. store_id_access deny !getmethod
  214. store_id_access allow youtube
  215. store_id_access deny all
  216.  
  217. store_id_extras "%{Referer}>h %>a/%>A %un %>rm myip=%la myport=%lp"
  218. refresh_pattern -i ^http.*\.internal 43200 0% 0 override-expire ignore-private
  219.  
  220. refresh_pattern -i \.(htm|html|xml|css|chm|txt|dll|dat)(\?.*)?$ 1440 100% 4320
  221. refresh_pattern -i \.(3gp|7z|ace|asx|bin|deb|divx|dvr-ms|ram|rpm|exe|inc|cab|qt)(\?.*)?$ 4320 100% 43200
  222. refresh_pattern -i \.(rar|jar|gz|tgz|bz2|iso|m1v|m2(v|p)|mo(d|v)|arj|lha|lzh|zip|tar)(\?.*)?$ 4320 100% 43200
  223. refresh_pattern -i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|ico|swf|ad)(\?.*)?$ 43200 100% 43200
  224. refresh_pattern -i \.(avi|ac4|mp(e?g|a|e|1|2|3|4)|mk(a|v)|ms(i|u|p)|og(x|v|a|g)|rm|r(a|p)m|snd|vob)(\?.*)?$ 43200 100% 43200
  225. refresh_pattern -i \.((pp(t?x)|s|t)|pdf|rtf|wax|wm(a|v)|wmx|wpl|cb(r|z|t)|xl(s?x)|do(c?x)|flv|x-flv)(\?.*)?$ 43200 100% 43200
  226.  
  227. #
  228. # Add any of your own refresh_pattern entries above these.
  229. #
  230. refresh_pattern ^ftp: 1440 20% 10080
  231. refresh_pattern ^gopher: 1440 0% 1440
  232. refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
  233. refresh_pattern . 0 20% 4320
  234.  
  235. qos_flows local-hit=0x30 ' > /etc/squid/squid.conf
  236. echo '#!/usr/bin/perl
  237. $|=1;
  238. while (<>) {
  239. @X = split;
  240. $x = $X[1];
  241. $y = $X[0] . " ";
  242. $z = $X[2];
  243.  
  244. if ($x =~ m/^https?:\/\/.*(youtube|google).*videoplayback.*/){
  245. @itag = m/[&?](itag\=[0-9]*)/;
  246. @mime = m/[&?](mime\=[^\&\s]*)/;
  247. @range = m/[&?](range\=[^\&\s]*)/;
  248. if($z =~ m/^https?:\/\/.*\?v\=(.*)/){
  249. $id=$1;}
  250.  
  251. print $y . "OK store-id=http://video.youtube.doktersquid.internal/video-id=$id&@itag&@mime&@range\n" ;
  252.  
  253. } else {
  254. print $y . "ERR\n";
  255. }
  256. } ' > /etc/squid/storeid.pl
  257. chmod +x /etc/squid/storeid.pl
  258. squid -zN
  259. wget --no-check-certificate -O /etc/init.d/squid https://gist.githubusercontent.com/e7d/1f784339df82c57a43bf/raw/squid.sh
  260. chmod +x /etc/init.d/squid
  261. update-rc.d squid defaults
  262. service squid start
  263. echo '#tproxy
  264. #iptables -t mangle -N DIVERT
  265. #iptables -t mangle -A DIVERT -j MARK --set-mark 1
  266. #iptables -t mangle -A DIVERT -j ACCEPT
  267. #iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
  268. #iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 3129
  269. #iptables -t mangle -A PREROUTING -p tcp --dport 443 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 3127
  270. #ip rule add fwmark 1 lookup 212
  271. #ip route add local 0.0.0.0/0 dev lo table 212
  272.  
  273. #intercept
  274. #iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3129
  275. #iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3127
  276.  
  277. exit 0' > /etc/rc.local
  278. tailf /var/log/squid/access.log | ccze
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement