.htaccessã§Torçµç±ã®ã¢ã¯ã»ã¹ãé®æãã
Tor使ã£ã¦ã¦ãªãã¨ãªãTorããã®ã¢ã¯ã»ã¹é®æããããªã£ãã®ã§æ¸ãã¦ã¿ãï¼ç¹ã«æå³ã¯ç¡ãï¼ Torã®åºå£ãã¼ãã.htaccessã§é®æããã ããªã®ã§
åºå£ãã¼ãä¸è¦§ã¯ããã«ããã¾ã
http://torstatus.blutmagie.de/ip_list_exit.php/Tor_ip_list_EXIT.csv
ä¸è¦§æ´æ°ãå®æçã«è¡ãããã£ã½ãã®ã§.htaccessããã®é½åº¦æ´æ°ãã¾ã
# -*- coding: utf-8 -*- import time import datetime from subprocess import call, PIPE, DEVNULL while True: # download Tor list cmd = "wget -nc http://torstatus.blutmagie.de/ip_list_exit.php/Tor_ip_list_EXIT.csv" ret = call(cmd.split(), stdout=DEVNULL, stdin=DEVNULL, stderr=DEVNULL) if ret != 0: print("download error") else: with open('/var/www/.htaccess', 'w') as fp: fp.write('Order allow,deny\n') fp.write('Allow from all\n') fp.write('<IfModule mod_rewrite.c>\n') fp.write(' RewriteEngine on\n') with open('Tor_ip_list_EXIT.csv', 'r') as torfp: list = torfp.readlines() for l in list: ip = l.replace('.', '\\.').replace('\n', '') + '$' fp.write(' RewriteCond %{REMOTE_ADDR} ^' + ip) tail = '\n' if l == list[-1] else ' [OR]\n' fp.write(tail) fp.write(' RewriteRule ^(.*) torpage.html [L]\n') fp.write('</IfModule>\n') print(datetime.datetime.now().isoformat(' '), "done") time.sleep(60 * 60 * 12) # 12ããããã
python3ã§æ¸ãã¦ã¾ãã
12æéããã«Torã®åºå£ãã¼ãä¸è¦§ããã§ãã¯ãã/var/www/.htaccessãä¸æ¸ããã¾ããå 容ã¯Torããã®ã¢ã¯ã»ã¹ãtorpage.htmlã«æ¸ãæãã¦è¿ãã ãã§ãï¼ä»¥åã®htaccessã¯å¤±ãããã®ã§æ³¨æï¼
å®è¡ï¼å¸¸é§
$ screen $ python3 torlimit_htaccess.py [Ctrl + A + D]ã§ãã¿ãã
åºå
Order allow,deny Allow from all <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REMOTE_ADDR} ^2\.98\.200\.182$ [OR] RewriteCond %{REMOTE_ADDR} ^2\.111\.64\.26$ [OR] (ç¥) RewriteCond %{REMOTE_ADDR} ^217\.172\.190\.19$ [OR] RewriteCond %{REMOTE_ADDR} ^217\.210\.165\.43$ RewriteRule ^(.*) torpage.html [L] </IfModule>
http://zipsan.pw/ ã«Torã§ã¢ã¯ã»ã¹ãã¦ã¿ãã¨ãã£ããé®æãã¦ãããã®ã§ä¸å¿åãã¦ãã£ã½ãã
ä»ã«ãã¾ãæ¹æ³ããããï¼