Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Python + Polipo + Tor

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
armanio
Posts: 2
Joined: 2015-04-14 21:03

Python + Polipo + Tor

#1 Post by armanio »

For all this, I'm using raspberry pi:

I need to send a HTTP POST request using TOR. Since TOR only supports SOCKS, I need POLIPO to redirect HTTP requests trough SOCKS in TOR.

So I'm using this piece of code in python, to send things through POLIPO

Code: Select all

    conn = http.client.HTTPConnection("localhost",8123)
    conn.set_tunnel("wikipedia.org", 80)
Polipo is set to foward things to Tor on 9050. I've opened Iceweasel, changed HTTP proxy settings to "localhost" at 8123, and then everything worked fine. I even tested the IP and it was a strange IP from some university, so TOR is working through POLIPO.
However, when I send some request with python, things get strange.

Here's my full code:

Code: Select all

 import http.client, urllib.parse
    import time
    import sys
    
    nome = "something..." 
    
    print("some text for my program \n \n")
    numero_da_vitima = input("Number of requests: ")
    total_de_ligacoes = int(input("Quantas ligações deseja fazer? "))
    intervalo = int(input("Interval in seconds? "))
    porta_tor = int(input("POLIPO PORT"))
    
    headers = {"Content-type": "application/x-www-form-urlencoded",
                "Accept": "text/plain"}
    conn = http.client.HTTPConnection("localhost",porta_tor)
    conn.set_tunnel("wikipedia.org", 80)
    
    
    def ligar(telefone):
        params = urllib.parse.urlencode({'Nome': nome, 'Telefone': telefone})
        conn.request("POST", "", params, headers)
        response = conn.getresponse()
        print(response.read().decode('utf-8'))
    conn.close()
    
    def atazanar():
        i = 0
        while (i<total_de_ligacoes):
            print("ligando para "+numero_da_vitima)
            ligar(numero_da_vitima)
            print("\n aguardando para próxima chamada\n")
            time.sleep(intervalo)
            i = i+1
    
    atazanar()
Wikipedia returns

Domain not configured

This domain points to a Wikimedia Foundation server, but is not configured on this server.

I know wikipedia.org shouldn't respond to POST but even when I try some website that accepts POST, like this example of ws3schools:

http://www.w3schools.com/tags/demo_form_method.asp

I get this:

Code: Select all

 <head><title>Document Moved</title></head>
    <body><h1>Object Moved</h1>This document may be found <a HREF="http://www.w3schools.com/tags/demo_form_method.asp">here</a></body>
So, what may be happening? Polipo + Tor works in browser, but not in python, and I get these strange responses from the servers...

Bulkley
Posts: 6387
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: Python + Polipo + Tor

#2 Post by Bulkley »

You can save yourself a lot of trouble by downloading the Tor Browser Bundle. The neat thing is you don't install it in the usual sense. You just open it in your user account and run it from there.

armanio
Posts: 2
Joined: 2015-04-14 21:03

Re: Python + Polipo + Tor

#3 Post by armanio »

but i'm not web browsing, I really need to send it with python

Post Reply