2017-06-13 8 views
1

Windows 10でTorのIPを更新しようとすると、常に失敗します(thisthisのようなスタックオーバーフローの記事を読んだことがあります作品)。標準のPythonソケットでのみ、Tor7.0の新しいipを取得する

  • OS:Windowsの10 64-ビット
  • TOR:バージョン7.0
私torrcの

内容torrc-デフォルトの

# This file was generated by Tor; if you edit it, comments will not be preserved 
# The old torrc file was renamed to torrc.orig.1 or similar, and Tor will ignore it 

DataDirectory C:\Users\yyyy\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor 
GeoIPFile C:\Users\yyyy\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\geoip 
GeoIPv6File C:\Users\yyyy\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\geoip6 
HiddenServiceStatistics 0 

HashedControlPassword 16:D14CC89AD7848B8C60093105E8284A2D3AB2CF3C20D95FECA0848CFAD2 
CookieAuthentication 1 #either with nor without this line, still fail 

内容

# torrc-defaults for Tor Browser 
# 
# DO NOT EDIT THIS FILE 
# 
# This file is distributed with Tor Browser and SHOULD NOT be modified (it 
# may be overwritten during the next Tor Browser update). To customize your 
# Tor configuration, shut down Tor Browser and edit the torrc file. 
# 
# If non-zero, try to write to disk less frequently than we would otherwise. 
AvoidDiskWrites 1 
# Where to send logging messages. Format is minSeverity[-maxSeverity] 
# (stderr|stdout|syslog|file FILENAME). 
Log notice stdout 
CookieAuthentication 1 
## fteproxy configuration 
ClientTransportPlugin fte exec TorBrowser\Tor\PluggableTransports\fteproxy --managed 

## obfs4proxy configuration 
ClientTransportPlugin obfs2,obfs3,obfs4,scramblesuit exec TorBrowser\Tor\PluggableTransports\obfs4proxy 

## meek configuration 
ClientTransportPlugin meek exec TorBrowser\Tor\PluggableTransports\terminateprocess-buffer TorBrowser\Tor\PluggableTransports\meek-client-torbrowser -- TorBrowser\Tor\PluggableTransports\meek-client 

スクリプトの使用IPアドレスを更新する

import repr as reprlib 
import socket 
import sys 

try: 
    tor_c = socket.create_connection(("127.0.0.1", 9151)) 
    tor_c.send('AUTHENTICATE "{}"\r\n'.format("16:D14CC89AD7848B8C60093105E8284A2D3AB2CF3C20D95FECA0848CFAD2")) 
    response = tor_c.recv(1024) 
    if response != '250 OK\r\n250 OK\r\n': 
     sys.stderr.write('Unexpected response from Tor control port: {}\n'.format(response)) 
except Exception, e: 
    sys.stderr.write('Error connecting to Tor control port: {}\n'.format(repr(e))) 
しかし、サーバは常に私にTorのコントロールポートから

予期しない応答を返信:515認証に失敗しました:パスワードはまたは 認証Cookie HashedControlPasswordと一致しませんでした。

私は、タスクのこの種のためのPythonライブラリがある知っているが、私はこれを適切に行うことができるか、だけのpythonの標準ソケットライブラリでIPを更新したいと思います?ありがとう

答えて

1

HashedControlPasswordがハッシュであります認証パスワードの認証するには、AUTHENTICATE "your actual password"となります。

制御プロトコルは比較的簡単です。例えば

は:

telnet localhost 9051 
Trying 127.0.0.1... 
Connected to localhost. 
Escape character is '^]'. 
authenticate "password" 
250 OK 
signal NEWNYM 
250 OK <-- identity changed for new circuits 

これが私の作品:

import repr as reprlib 
import socket 
import sys 

try: 
    tor_c = socket.create_connection(("127.0.0.1", 9051)) 
    tor_c.send("AUTHENTICATE \"{}\"\n".format("password")) 
    response = tor_c.recv(1024) 
    if response != '250 OK\r\n': 
     sys.stderr.write('Unexpected response from Tor control port: {}\n'.format(response)) 
    tor_c.send("SIGNAL NEWNYM\n"); 
    response = tor_c.recv(1024) 
    print(response) 
except Exception, e: 
    sys.stderr.write('Error connecting to Tor control port: {}\n'.format(repr(e))) 

はまた、この例に従って、Pythonのを避けることができます:Request new identity from Windows command line

+0

ありがとう、問題はパスワードです、私はハッシュを入力すべきではなく、実際のパスワード、どのように愚かな私でした。 – StereoMatching

関連する問題