Tor (日本語)

From ParabolaWiki
Jump to: navigation, search
  • GNUnet

  • I2P

  • Freenet
  • Tor は第2世代オニオンルーティングのオープンソース実装で、匿名プロキシネットワークへのアクセスを提供します。Tor の目標はトラフィック解析攻撃を防いでネットワークの匿名性を守ることです。

    1 イントロダクション

    Tor ネットワークのユーザーはマシン上でオニオンプロキシを実行します。このソフトウェアは Tor に接続し、定期的に Tor ネットワークの仮想回線を構築します。Tor は層状の (つまり 'タマネギ' のような) 暗号化をすることで、ルーター間の完全な匿名性を保証しています。同時に、オニオンプロキシソフトウェアにはクライアントのために SOCKS インターフェースがあります。つまり SOCKS を利用できるアプリケーションは Tor に接続可能で、多様な通信が Tor 仮想回線を利用することができます。

    Warning: あなたが匿名性を維持するのに必要なのは Tor だけではありません。注意するべき落とし穴がいくつか存在します (参照: Want Tor to really work?)。

    上記のプロセスを通すことで、オニオンプロキシはネットワークトラフィックを管理してエンドユーザーの匿名性を守ります。通信を暗号化して、Tor ネットワークの他のノードを通して送信し、通信を受信した末端のノードで復号化してから指定されたサーバーに転送することで、ユーザーが匿名化されます。Tor によって匿名性が得られる代わりに、トラフィックのルート変更が何度も行われるため、通常の直接接続よりも通信速度が著しく遅くなります。さらに、Tor はトラフィックの解析に対する防護をしますが、Tor ネットワークの境界 (ネットワークに出入りするトラフィック) でトラフィックを確認することは防げません。

    See the Wikipedia article on this subject for more information: Tor

    2 インストール

    公式リポジトリにある torインストールしてください。

    arm (Anonymizing Relay Monitor) パッケージには帯域使用量や接続の詳細などをターミナルに表示するモニタが含まれています。

    さらに、Tor の Qt フロントエンドである
    Warning: This page points to an AUR package. Please remove the link. Reason: See Issue#1983
    が利用できます。Tor プロセスの操作に加えて、Vidalia では Tor の状態の回覧・設定、利用帯域の監視、ログメッセージの回覧・フィルター・検索が可能です。
    Warning: Vidalia にはアクティブなメンテナが存在しないため、大量のバグが修正されず放置されています。vidalia を使うことは 推奨されません

    3 設定

    Tor をより深く理解するために、設定ファイルの /etc/tor/torrc をよく見て下さい。設定オプションの説明は man torTor website で見られます。ほとんどの場合はデフォルト設定で問題なく Tor は動作します。

    torrc の設定と tor.service の設定で衝突が発生する可能性があります:

    • torrc では、RunAsDaemon はデフォルトどおりに 0 に設定してください。tor.service[Service] セクションで Type=simple が設定されているためです。
    • torrc では、User は設定しないでください。tor.service[Service] セクションで User=root に設定されているためです。

    3.1 リレー設定

    Tor から開くことができるファイル記述子の最大数は tor.serviceLimitNOFILE で設定できます。リレーを高速化したいときはこの数値を上げて下さい。

    あなたのコンピュータでウェブサーバーを実行していない場合、AccountingMax を設定する必要はありません。ORPort443 にしたり DirPort80 にすると良いでしょう。多くの Tor ユーザーはファイアウォールによって足止めされており、ウェブブラウズしかできないようになっていますが、この変更によってあなたの Tor リレーに到達できるようになります。既にポート 80 と 443 を使っている場合、他のポートとしては 22, 110, 143 などが候補に挙げられています [1]。ただしこれらは特権が与えられたポートなので、tor.serviceUser=roottorrcUser tor を設定して、Tor を root で起動する必要があります。

    詳しくは Tor ドキュメントの Lifecycle of a New Relay を読むことを推奨します。

    4 Tor を Chroot で実行する

    セキュリティを高めるために、chroot で Tor を実行するのが望ましい場合があります。以下のスクリプトは /opt/torchroot に適切な chroot を作成します:

    ~/torchroot-setup.sh
    #!/bin/bash
    export TORCHROOT=/opt/torchroot
    
    mkdir -p $TORCHROOT
    mkdir -p $TORCHROOT/etc/tor
    mkdir -p $TORCHROOT/dev
    mkdir -p $TORCHROOT/usr/bin
    mkdir -p $TORCHROOT/usr/lib
    mkdir -p $TORCHROOT/usr/share/tor
    mkdir -p $TORCHROOT/var/lib
    
    ln -s /usr/lib  $TORCHROOT/lib
    cp /etc/hosts           $TORCHROOT/etc/
    cp /etc/host.conf       $TORCHROOT/etc/
    cp /etc/localtime       $TORCHROOT/etc/
    cp /etc/nsswitch.conf   $TORCHROOT/etc/
    cp /etc/resolv.conf     $TORCHROOT/etc/
    cp /etc/tor/torrc       $TORCHROOT/etc/tor/
    
    cp /usr/bin/tor         $TORCHROOT/usr/bin/
    cp /usr/share/tor/geoip* $TORCHROOT/usr/share/tor/
    cp /lib/libnss* /lib/libnsl* /lib/ld-linux-*.so* /lib/libresolv* /lib/libgcc_s.so* $TORCHROOT/usr/lib/
    cp $(ldd /usr/bin/tor | awk '{print $3}'|grep --color=never "^/") $TORCHROOT/usr/lib/
    cp -r /var/lib/tor      $TORCHROOT/var/lib/
    chown -R tor:tor $TORCHROOT/var/lib/tor
    
    sh -c "grep --color=never ^tor /etc/passwd > $TORCHROOT/etc/passwd"
    sh -c "grep --color=never ^tor /etc/group > $TORCHROOT/etc/group"
    
    mknod -m 644 $TORCHROOT/dev/random c 1 8
    mknod -m 644 $TORCHROOT/dev/urandom c 1 9
    mknod -m 666 $TORCHROOT/dev/null c 1 3
    
    if [[ "$(uname -m)" == "x86_64" ]]; then
      cp /usr/lib/ld-linux-x86-64.so* $TORCHROOT/usr/lib/.
      ln -sr /usr/lib64 $TORCHROOT/lib64
      ln -s $TORCHROOT/usr/lib ${TORCHROOT}/usr/lib64
    fi

    このスクリプトを root で実行した後、次のコマンドで chroot に Tor を起動できます: # chroot --userspec=tor:tor /opt/torchroot /usr/bin/tor

    5 使用方法

    systemd を使って tor.service を起動・有効にしてください。

    もしくは、vidalia インターフェースからも tor を起動出来ます。

    プログラムに Tor を通すには、SOCKS5 プロキシとして 127.0.0.1 か localhost をポート 9050 (tor の標準設定) 又は 9051 (vidalia の標準設定) で使うようにプログラムを設定してください。 Tor が正しく機能しているか確認するために Tor , Harvard , Xenobite.eu などのウェブサイトを開いてみましょう。

    6 ウェブブラウズ

    Tor プロジェクトは現在 tor を使ったウェブブラウズは Tor Browser Bundle だけサポートしています。このブラウザは AUR からダウンロード可能です (Tor Browser Bundle)。Firefox にパッチをあてたバージョンにサポートを拡張して作られています。普通の FirefoxChromium など他のブラウザで Tor を使うこともできますが、Tor プロジェクトからは推奨されていません

    Tip: AUR の TBB のソース tarball の署名を makepkg で確認するには、次のコマンドで Tor Project の署名鍵 (現在は 2E1AC68ED40814E0) をキーサーバーからダウンロードして gpg キーリングに追加する必要があります: $ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 2E1AC68ED40814E0

    6.1 Firefox

    設定 > 詳細 > ネットワークタブ > 接続設定 から SOCKS の localhost ポート 9050 を使うように手動で Firefox を設定してください。そしてアドレスバーに about:config と入力してください。network.proxy.socks_remote_dnstrue に変更してブラウザを再起動してください。これで、全ての DNS リクエストは TOR の socks プロキシを通過するようになります。

    6.2 Luakit

    次を実行:

    $ torify luakit
    

    7 HTTP プロキシ

    Tor は PolipoPrivoxy などの HTTP プロキシと一緒に使うことができますが、Tor の開発チームはブラウザが直接サポートしている SOCKS5 ライブラリを使うことを推奨しています。

    7.1 Firefox

    FoxyProxy アドオンを使うことで URL に合わせて複数のプロキシを指定したりすることができます。Firefox を再起動したら手動で Firefox を PolipoPrivoxy が動作しているポート 8118localhost に設定してください。これらの設定は Add > Standard proxy type から設定できます。プロキシのラベル (例: Tor) を選択してポートとホストを HTTP ProxySSL Proxy フィールドに入力してください。Tor が正しく機能しているかどうかは Tor Check ウェブサイトを開くことで確認できます。

    7.2 Polipo

    Tor Project は Polipo の問題を回避して匿名性を上げるためにカスタマイズされた Polipo 設定ファイル を作成しています。

    SOCKS 5 プロキシが使える場合、Tor は自動的にポート 9050 で起動するので、Polipo は必須ではないことを覚えておいて下さい。Tor で Chromium を使いたい場合、Polipo パッケージは必要ありません (参照: #Chromium)。

    7.3 Privoxy

    メッセンジャーなど (例: Jabber, IRC) 他のアプリケーションでセットアップを使うこともできます。アプリケーションが HTTP プロキシをサポートしていれば Privoxy に接続することができます (127.0.0.1:8118)。直接 SOCKS プロキシを使うには、アプリケーションから Tor を指定します (127.0.0.1:9050)。この方法の問題はアプリケーションが DNS 解決を独自に行うような場合、情報が漏洩する可能性があるということです。代わりに (Privoxy なおで) Socks4A を使用してください。

    8 インスタントメッセージ

    IM クライアントで tor を使う場合、polipo/privoxy などの http プロキシは必要ありません。デフォルトでポート 9050 を listen する tor のデーモンを直接使用します。

    8.1 Pidgin

    You can set up Pidgin to use Tor globally, or per account. To use Tor globally, go to Tools -> Preferences -> Proxy. To use Tor for specific accounts, go to Accounts > Manage Accounts, select the desired account, click Modify, then go to the Proxy tab. The proxy settings are as follows:

    Proxy type 	SOCKS5
    Host 	        127.0.0.1
    Port 	        9150
    

    Note that some time in 2013 the Port has changed from 9050 to 9150 if you use the Tor Browser Bundle. Try the other value if you receive a "Connection refused" message.

    9 Irssi

    Freenode は .onion に直接接続することを推奨しています。接続時に nickserv で認証するには charybdis と ircd-seven の SASL が必要です。Irssi#SASL で認証 を参照してください。irssi を起動:

    $ torsocks irssi
    

    Set your identification to nickserv, which will be read when connecting. Supported mechanisms are ECDSA-NIST256P-CHALLENGE (see ecdsatool) and PLAIN. DH-BLOWFISH is no longer supported.

    /sasl set network username password mechanism
    

    Disable CTCP and DCC and set a different hostname to prevent information disclosure: [2]

    /ignore * CTCPS
    /ignore * DCC
    /set hostname fake_host
    

    Freenode に接続:

    /connect -network network frxleqtzgvwkv7oz.onion
    

    詳しくは Accessing freenode Via Tor, SASL README, IRC/SILC Wiki article を見て下さい。

    10 Pacman

    Pacman のダウンロード操作 (リポジトリ DB, パッケージ, パブリックキー) を Tor ネットワークを通して行うことが可能です。やや大げさですが、もしあなたに (LAN やミラーなどに) 敵がいる場合、インストールしたパッケージが何なのか知られることがなくなります。ただし遅延がひどくなり、スループットが遅くなり、気づかれる可能性があり、(現在の接続で Tor がフィルタリングされている場合) インストールができない可能性があります。

    Warning: It would be arguably simpler for an adversary, specifically one who desires to indiscriminately disseminate malware, to perform his/her activity by deploying malicious Tor exit node(s). Always use signed packages and verify new public keys by out-of-band means.
    /etc/pacman.conf
    ...
    XferCommand = /usr/bin/curl --socks5-hostname localhost:9050 -C - -f %u > %o
    ...

    11 Tor サーバーを実行する

    Tor ネットワークは人々が提供する帯域に頼っています。ネットワークに貢献する方法は複数あります。

    11.1 Tor ブリッジの実行

    Tor ブリッジは Tor のパブリックディレクトリに記載されない Tor リレーです。政府や ISP によって Tor のパブリックリレーが全てブロックされたときでも Tor ネットワークに接続することを可能にします。

    11.1.1 設定

    https://www.torproject.org/docs/bridges によれば、torrc に以下の4行を設定してください:

       SocksPort 0
       ORPort 443
       BridgeRelay 1
       Exitpolicy reject *:*
    

    11.1.2 トラブルシューティング

    If you get "Could not bind to 0.0.0.0:443: Permission denied" errors on startup, you'll need to pick a higher ORPort (e.g. 8080), or perhaps forward the port in your router.

    11.2 Tor リレーの実行

    あなたのマシンを (リレーのオンライン時間によって) エントリーノードや転送リレーとして動作させます。ブリッジリレーとは違って、Tor のパブリックディレクトリに記載されます。誰でも Tor のディレクトリからあなたの IP アドレスを見ることができるようになりますが、このリレーは他のリレーや Tor 出口ノードに転送するだけで、インターネットに直接転送することはありません。

    11.2.1 設定

    最低でも 20KiB/s は共有してください:

    Nickname tornickname
    ORPort 9001
    BandwidthRate 20 KB            # Throttle traffic to 20KB/s
    BandwidthBurst 50 KB           # But allow bursts up to 50KB/s
    

    リレーからの退出を拒否する:

    ExitPolicy reject *:*
    

    11.3 Tor 出口ノードの実行

    Any requests from a Tor user to the regular internet obviously need to exit the network somewhere, and exit nodes provide this vital service. To the accessed host, the request will appear as having originated from your machine. This means that running an exit node is generally considered more legally onerous than running other forms of Tor relays. Before becoming an exit relay, you may want to read Tips for Running an Exit Node With Minimal Harrasment.

    11.3.1 設定

    torrc を使うことで、出口ノードを通過できるサービスを設定することができます。

    全てのトラフィックを許可:

    ExitPolicy accept	*:*
    

    irc ポート 6660-6667 だけがノードから退出することを許可する:

    ExitPolicy accept *:6660-6667,reject *:* # Allow irc ports but no more
    

    デフォルトでは、Tor は特定のポートをブロックします。torrc を使うことで上書きすることが可能です:

    ExitPolicy accept *:119        # Accept nntp as well as default exit policy
    

    12 TorDNS

    Tor 0.2.x シリーズには DNS フォワーダが組み込まれています。有効化するには、以下の行を Tor の設定ファイルに追加してデーモンを再起動してください:

    /etc/tor/torrc
    DNSPort 9053
    AutomapHostsOnResolve 1
    AutomapHostsSuffixes .exit,.onion
    

    This will allow Tor to accept DNS requests (listening on port 9053 in this example) like a regular DNS server, and resolve the domain via the Tor network. A downside is that it's only able to resolve DNS queries for A-records; MX and NS queries are never answered. For more information see this Debian-based introduction.

    DNS queries can also be performed through a command line interface by using tor-resolve. For example:

    $ tor-resolve archlinux.org
    66.211.214.131
    

    12.1 全ての DNS クエリで TorDNS を使う

    It is possible to configure your system, if so desired, to use TorDNS for all queries your system makes, regardless of whether or not you eventually use Tor to connect to your final destination. To do this, configure your system to use 127.0.0.1 as its DNS server and edit the 'DNSPort' line in /etc/tor/torrc to show:

    DNSPort 53
    

    Alternatively, you can use a local caching DNS server, such as dnsmasq or pdnsd, which will also compensate for TorDNS being a little slower than traditional DNS servers. The following instructions will show how to set up dnsmasq for this purpose.

    Change the tor setting to listen for the DNS request in port 9053 and install dnsmasq.

    Modify its configuration file so that it contains:

    /etc/dnsmasq.conf
    no-resolv
    server=127.0.0.1#9053
    listen-address=127.0.0.1
    

    These configurations set dnsmasq to listen only for requests from the local computer, and to use TorDNS at its sole upstream provider. It is now neccessary to edit /etc/resolv.conf so that your system will query only the dnsmasq server.

    /etc/resolv.conf
    nameserver 127.0.0.1
    

    Start the dnsmasq daemon.

    Finally if you use dhcpd you would need to change its settings to that it does not alter the resolv configuration file. Just add this line in the configuration file:

    /etc/dhcpcd.conf
    nohook resolv.conf
    

    If you already have an nohook line, just add resolv.conf separated with a comma.

    13 Torify

    torify を利用すると、アプリケーションの設定を変更することなく、Tor ネットワークを介してアプリケーションを使うことができるようになります。man ページより:

    torify is a simple wrapper that attempts to find the best underlying Tor wrapper available on a system. It calls torsocks with a tor specific configuration file.

    使用例:

    $ torify elinks checkip.dyndns.org
    $ torify wget -qO- https://check.torproject.org/ | grep -i congratulations
    

    Torify will not, however, perform DNS lookups through the Tor network. A workaround is to use it in conjunction with tor-resolve (described above). In this case, the procedure for the first of the above examples would look like this:

    $ tor-resolve checkip.dyndns.org
    208.78.69.70
    
    $ torify elinks 208.78.69.70
    

    14 トラブルシューティング

    14.1 Problem with user value

    tor デーモンが起動しない場合、root で次のコマンドを実行してください (もしくは sudo を使用):

    # tor
    

    以下のエラーが表示される場合:

    May 23 00:27:24.624 [warn] Error setting groups to gid 43: "Operation not permitted".
    May 23 00:27:24.624 [warn] If you set the "User" option, you must start Tor as root.
    May 23 00:27:24.624 [warn] Failed to parse/validate config: Problem with User value. See logs for details.
    May 23 00:27:24.624 [err] Reading config failed--see warnings above.
    

    Then it means that the problem is with the User value, which likely means that one or more files or directories in your /var/lib/tor directory is not owned by tor. This can be determined by using the following find command:

    find /var/lib/tor/ ! -user tor
    

    Any files or directories listed in the output from this command needs to have its ownership changed. This can be done individually for each file like so:

    chown tor:tor /var/lib/tor/filename
    

    Or to change everything listed by the above find example, modify the command to this:

    find /var/lib/tor/ ! -user tor -exec chown tor:tor {} \;
    

    Tor should now start up correctly.

    Still if you cannot start the tor service, run the service using root (this will switch back to the tor user). To do this, change the user name in the /etc/tor/torrc file:

    User tor
    

    Now modify the systemd's tor service file /usr/lib/systemd/system/tor.service as follows

    [Service]
    User=root
    Group=root
    Type=simple
    

    The process will be run as tor user. For this purpose change user and group ID to tor and also make it writable:

    # chown -R tor:tor /var/lib/tor/
    # chmod -R 755 /var/lib/tor
    

    Now save changes and run the daemon:

    # systemctl --system daemon-reload
    # systemctl start tor.service
    

    15 参照

    16 Acknowledgement

    This wiki article is based on ArchWiki. We may have removed non-FSDG bits from it.