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.
navigate to \Tor Browser\Browser\TorBrowser\Data\Tor and edit torcc file
# ControlPort 9051
SocksPort 9051
Then 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
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).
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
Related
I want to install python libs using pip from windows command prompt, but unable to due to no proxy settings. Internet connection requires 'Automatic proxy configuration URL' for browsers normally. What should i do for 'command prompt'. 'set HTTP_PROXY' is not working as it requires proxy server IP and port. in my case, its an 'Automatic proxy configuration URL'.
Download the file at the automatic proxy configuration URL. It's (usually a small) Javascript file. Interpret it manually (alas!) and create a proper proxy setting for pip.
Lately I've been playing with Python to discover its potential and I've just stumbled upon SimpleHTTPServer.
I'm on Windows 10.
I run:
python -m SimpleHTTPServer
the output is:
Serving HTTP on 0.0.0.0 port 8000 ...
I've opened the browser both on smartphone and tablet, but none of them can connect to the server when I type "http://127.0.0.1:8000".
(Translating from italian, maybe is not the exact translation)
iPad: "Safari can't open the page because the server has stopped responding"
Android: "WebPage does not respond. the webpage may be temporarily not available or it could have been moved to another address"
Why does it not work? How do I fix this?
Maybe your firewall is blocking access to python based server
Try this:
Open windows firewall
click on "allow an app or feature..." on the left side of the opened window
search for python in the list and check both the boxes private and public
It should work now
127.0.0.1 is always the IP address of the local system (its associated hostname is "localhost"). In other words, if you type 127.0.0.1:8000 on your tablet or Android device, the browser on that device will try to connect to a server running on the same device, listening on port 8000. You'll need to find out the IP address of the computer you're running Python on, and type that instead. You can use the ifconfig command on Unix, or ipconfig on Windows.
I created a Scrapy project with several spiders to crawl some websites. Now I want to use TOR to:
Hide my ip from the crawled servers;
Associate my requests to different ips, simulating accesses from different users.
I have read some info about this, for example:
using tor with scrapy framework, How to connect to https site with Scrapy via Polipo over TOR?
The answers from these links weren't helpful to me. What are the steps that I should take to make Scrapy work properly with TOR?
EDIT 1:
Considering answer 1, I started by installing TOR. As I am using Windows I downloaded the TOR Expert Bundle (https://www.torproject.org/dist/torbrowser/5.0.1/tor-win32-0.2.6.10.zip) and read the chapter about how to configure TOR as a relay (https://www.torproject.org/docs/tor-doc-windows.html.en). Unfortunately there is little or any information about how to do it on Windows. If I unzip the downloaded archive and run the file Tor\Tor.exe nothing happens. However, I can see in the Task Manager that a new process is instantiated. I don't know what is the best way to proceed from here.
After a lot of research, I found a way to setup my Scrapy project to work with TOR on Windows OS:
Download TOR Expert Bundle for Windows (1) and unzip the files to a folder (ex. \tor-win32-0.2.6.10).
The recent TOR's versions for Windows don't come with a graphical user interface (2). It is probably possible to setup TOR only through config files and cmd commands but for me, the best option was to use Vidalia. Download it (3) and unzip the files to a folder (ex. vidalia-standalone-0.2.21-win32). Run "Start Vidalia.exe" and go to Settings. On the "General" tab, point Vidalia to TOR (\tor-win32-0.2.6.10\Tor\tor.exe).
Check on "Advanced" tab and "Tor Configuration File" section the torrc file. I have the next ports configured:
ControlPort 9151
SocksPort 9050
Click Start Tor on the Vidalia Control Panel UI. After some processing you should se on the status the message "Connected to the Tor network!".
Download Polipo proxy (4) and unzip the files to a folder (ex. polipo-1.1.0-win32). Read about this proxy on the link 5.
Edit the file config.sample and add the next lines to it (in the beginning of the file, for example):
socksParentProxy = "localhost:9050"
socksProxyType = socks5
diskCacheRoot = ""
Start Polipo through cmd. Go to the folder where you unzipped the files and enter the next command "polipo.exe -c config.sample".
Now you have Polipo and TOR up and running. Polipo will redirect any request to TOR through port 9050 with SOCKS protocol. Polipo will receive any HTTP request to redirect trough port 8123.
Now you can follow the rest of the tutorial "Torifying Scrapy Project On Ubuntu" (6). Continue in the step where the tutorial explains how to test the TOR/Polipo communications.
Links:
https://www.torproject.org/download/download.html.en
https://tor.stackexchange.com/questions/6496/tor-expert-bundle-on-windows-no-installation-instructions
https://people.torproject.org/~erinn/vidalia-standalone-bundles/
http://www.pps.univ-paris-diderot.fr/~jch/software/files/polipo/
http://www.pps.univ-paris-diderot.fr/~jch/software/polipo/tor.html
http://blog.privatenode.in/torifying-scrapy-project-on-ubuntu
A detailed step-by-step Explanation is here
http://blog.privatenode.in/torifying-scrapy-project-on-ubuntu/
The Basic steps there are:
Install Tor and Polipo (for linux this might require to add a repository).
Configure Polipo to talk with TOR using SOCK Connection (see above link).
Create a custom Middleware to use tor as a http proxy and to randomly change the scrapy user agent
to suppress depreciation warning from above example, write
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
instead of 'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
What is your szenario? Have you thought about renting Proxy Servers?
Is there any way to change the firefox and chrome proxy through a python script.
System is Ubuntu or any other linux distro
Keep the browser settings as set the proxy as system proxy.
Then your python script will be
import os
os.system('export http://<your proxy>:<your port>/')
os.system('export https://<your proxy>:<your port>/')
This will set the system proxy as your proxy and hence your browser will be using your system proxy.
I try to setup a simple webinterface with cherrypy & python.
The page is visible over localhost:8080. If I try a different computer on the same LAN and try to connect with it via 192.168.1.100:8080 it doesn't work however. Do I need to open some ports? I thought this would not be needed with linux.
OS: Ubuntu on both systems
Tried Browsers Chrome & midori
Make sure to bind your server to 0.0.0.0:8080 instead of localhost:8080.
localhost always resolves to the loopback interface, which is only reachable from the same host.
0.0.0.0 on the other hand means "all interfaces" (also known as INADDR_ANY).
For details read up about INADDR_LOOPBACK and INADDR_ANY in the ip(7) manpage.