Torを使用してHTTPTunnelPortを使用して端末コマンドをリダイレクトする

Torを使用してHTTPTunnelPortを使用して端末コマンドをリダイレクトする

Torを介してターミナルコマンドをリダイレクトしようとしています。ただし、正規のIPアドレスを確認しようとすると、次のエラーが発生します。

$ curl https://ipinfo.io/ip
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:9051 

このコマンドを使用して端末のプロキシを設定しました。

$ export http_proxy='http://127.0.0.1:9051'    
$ export https_proxy='https://127.0.0.1:9051'

/etc/tor/torrcに「HTTPTunnelPort 9051」を追加し、Torサービスを再起動しました。

また、ポート9051が開いていてリッスンしていることを確認しました。

$ sudo lsof -i -P -n | grep LISTEN 
tor       10757      debian-tor    6u  IPv4 120224      0t0  TCP 127.0.0.1:9050 (LISTEN)
tor       10757      debian-tor    7u  IPv4 120225      0t0  TCP 127.0.0.1:9051 (LISTEN)

ベストアンサー1

Curlはocks5と互換性があります。 Tor経由でCurlを使用してダウンロードするために使用するBashスクリプトは次のとおりです。

~/bin/torrific-curl

#!/usr/bin/env bash

_address="${1:?No address supplied}"
_location="${2}"
_socks5_port='9050'

_cmd=('curl' '--socks5' "localhost:${_socks5_port}" '--socks5-hostname' "localhost:${_socks5_port}" '-s' "${_address}")

((${#_location})) && {
  ${_cmd[@]} -o "${_location}"
} || {
  ${_cmd[@]}
}

設定

chmod u+x ~/bin/torrific-curl

使用法

torrific-curl 'https://ipinfo.io/ip'

## Or with output file...

torrific-curl\
  'https://ipinfo.io/ip'\
  "/tmp/torrific-ip_$(date +'%Y-%m_%d-%T').txt"

… …ちょっとそうです。ヒット&ミスどのアプリケーションがTorとうまく機能するかについて詳しくは、HTTPTunnelPortこの回答を再編集することになります。

おすすめ記事