How to configure a tor proxy on windows?

我是研究僧i 提交于 2021-02-05 07:01:21

问题


How do I configure a tor proxy on windows?

For example, I want to run the following python script through a tor proxy:

import requests

proxies = {
    'http':'socks5h://localhost:9050',
    'https':'socks5h:/localhost:9050'
}
url = 'someWebsite.onion'
res = requests.get(url, proxies=proxies)

On unix systems, you can simply run tor in terminal, but this doesn't seem to work on windows.


回答1:


Txtorcon and Stem are libraries developed by the Tor Project for controlling Tor from Python. Stem doesn't have any external dependencies. However, txtorcon allows one to launch Tor from Python, rather than just connect to a running instance.

Both of these libraries require a Tor binary already installed though. It is possible to use the Tor included with the Tor Browser Bundle, connecting on port 9150 (with control port of 9151).

Better yet though, you can download the "Expert Bundle" to get the Tor binary without any browser. The download for it is not currently linked from their new website, but the latest version can still be pulled from https://dist.torproject.org/torbrowser/. Navigate to a directory for either the alpha or stable version and search for "tor-win64-" (or "tor-win32-" if you need 32-bit).




回答2:


navigate to \Tor Browser\Browser\TorBrowser\Data\Tor and edit torcc file

# ControlPort 9051
SocksPort 9051

restart tor

use tor proxy everywhere:

control panel -> network & internet -> internet options -> connection -> lan setting -> tick proxy server & goto advance & add:

proxy 127.0.0.1 port 9051

use tor proxy in a browser like firefox:

options -> network setting -> tick Manual proxy configuration & add:

proxy 127.0.0.1 port 9051

use with python requests library:

import requests

proxies = {
    'http':'socks5://127.0.0.1:9051',
    'https':'socks5:/127.0.0.1:9051'
}
url = 'https://check.torproject.org/'
res = requests.get(url, proxies=proxies)

Note: You have to keep running tor browser for this

I am using like this & it's working. Hope it will work for you also




回答3:


he working good, but need start tor service in windows or made service tor auto start in windows when startup

all time tor service in this path after download tor browser

your_installation_path\Tor Browser\Browser\TorBrowser\Tor

the bin name is tor.exe you should add path in the windows PATH



来源:https://stackoverflow.com/questions/55497125/how-to-configure-a-tor-proxy-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!