tor

Python urllib2 with Tor proxy throws `HTTP Error 403`

血红的双手。 提交于 2019-12-11 11:13:31
问题 I am trying to parse a web page using this solution like the following: from bs4 import BeautifulSoup as bs import re import time import random ---------------------- import socks import socket # Can be socks4/5 socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,'127.0.0.1', 9050) socket.socket = socks.socksocket # Magic! def getaddrinfo(*args): return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))] socket.getaddrinfo = getaddrinfo ---------------------- import urllib2 # define

Send Tor NEWNYM request using Java

怎甘沉沦 提交于 2019-12-11 04:09:15
问题 My application uses Tor successfully, but I would like to send a NEWNYM request to obtain a new identity. I could kill and restart the process, or possibly use a shell script, but I'd prefer to do it in native Java. There is a Python solution, but I'm not quite sure how to map it to Java connection types. I imagine it's fairly similar to my Tor HTTP code, but I'm not familiar enough with Java connection types to make it happen. // My starter code. public static String torNewIP() throws

How to connect to .onion sites using python aiohttp?

泄露秘密 提交于 2019-12-10 23:38:15
问题 I am trying to connect to a .onion site using python. I have tor running on port 9050 and I am getting the following error: Traceback (most recent call last): File "/Users/jane/code/test/test.py", line 15, in main res = await fetch(session, id) File "/Users/jane/code/test/test.py", line 9, in fetch async with session.get(url) as res: File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1005, in __aenter__ self._resp = await self._coro File "/usr/local/lib/python3.7/site

IP remains unchanged

我的未来我决定 提交于 2019-12-10 21:18:33
问题 I am trying to connect to Tor by code and change my identity. The results that I have gotten so far are that I connect successfully but can't change my identity. Here is my code : import socket import socks import httplib def connectTor(): socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"127.0.0.1",9150,True) socket.socket = socks.socksocket def newIdentity(): socks.setdefaultproxy() s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect(("127.0.0.1",9151)) s.send("AUTHENTICATE\r\n")

Stem as python tor client - stuck on loading descriptors

雨燕双飞 提交于 2019-12-10 20:58:09
问题 I'm trying to connect to tor with python stem, while trying to connect (using th emodified example) it just won't work...here's my code: (I'm using python 3.4.1) import socket,urllib, sys, socks, stem.process from stem.util import term SOCKS_PORT = 7000 # Set socks proxy and wrap the urllib module socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT) socket.socket = socks.socksocket # Perform DNS resolution through the socket def getaddrinfo(*args): return [(socket.AF_INET,

Python fails Tor check using urllib2 to initiate requests

房东的猫 提交于 2019-12-10 16:00:42
问题 After reading through the other questions on StackOverflow, I got a snippet of Python code that is able to make requests through a Tor proxy: import urllib2 proxy = urllib2.ProxyHandler({'http':'127.0.0.1:8118'}) opener = urllib2.build_opener(proxy) print opener.open('https://check.torproject.org/').read() Since Tor works fine in Firefox with TorButton, I expected it to work fine in Python. Unfortunately, included in the mess of HTML: Sorry. You are not using Tor . I am not sure why this is

Tor: fputs of “SIGNAL NEWNYM\r\n” results in empty response from fread

有些话、适合烂在心里 提交于 2019-12-10 12:35:46
问题 does anyone please know why fputs($fp, "SIGNAL NEWNYM\r\n"); $response = fread($fp, 1024); return an empty $response (on windows)? i can't get it to work after 5 hours trying everything i use the code in: $fp = fsockopen('localhost', 9051, $errno, $errstr, 30); $auth_code = 'a-password'; if ($fp) { echo "Connected to TOR port<br />"; } else { echo "Cant connect to TOR port<br />"; } fputs($fp, "AUTHENTICATE \"".$auth_code."\"\r\n"); $response = fread($fp, 1024); list($code, $text) = explode('

PHP tor installation

。_饼干妹妹 提交于 2019-12-10 12:08:00
问题 I have this code: <?php $ip = '127.0.0.1'; $port = '9051'; $auth = 'PASSWORD'; $command = 'signal NEWNYM'; $fp = fsockopen($ip,$port,$error_number,$err_string,10); if(!$fp) { echo "ERROR: $error_number : $err_string"; return false; } else { fwrite($fp,"AUTHENTICATE \"".$auth."\"\n"); $received = fread($fp,512); fwrite($fp,$command."\n"); $received = fread($fp,512); } fclose($fp); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://whatismyip.org"); curl_setopt($ch, CURLOPT_PROXY, "127.0

Selenium WebDriver Change Firefox path to Tor

折月煮酒 提交于 2019-12-10 11:27:03
问题 I'm trying to change webdriver in ruby to open a tor browser instead of the default firefox broswer. I'm using the following code and I have a tor browser open before I run this code. path='C:\Users\Bonnnie\Downloads\Tor Browser\App\tor.exe' Selenium::WebDriver::Firefox.path = path driver = Selenium::WebDriver.for :firefox I get the following error: unable to obtain stable firefox connection in 60 seconds I think I might be linking to the wrong tor file. 回答1: The following worked for me with

How to open tor browser using watir?

依然范特西╮ 提交于 2019-12-10 10:49:23
问题 With my ruby code I want to open Tor Browser instead of Firefox,for this I tried this code path='C:\Tor Browser\App\tor.exe' Selenium::WebDriver::Firefox.path = path driver = Selenium::WebDriver.for :firefox ie = Watir::Browser.new :firefox, :driver => driver I got this error c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium: