"Window" Tor (onion head routing) +privoxy Network practice (with Java instance code)

Source: Internet
Author: User
Tags response code

1. Background we need to visit Onion suffix website, need to pass Tor (the Onion Router, onion router). In general, installing Tor broswer can be a requirement. But what I'm going to do is to get the contents of the Onion website through the program. The Tor website recommends using stem to operate Tor, but stem is a Python library, but I am more familiar with Java. So I want to use Tor+privoxy to build the network, and then use the above proxy network in Java to get the data of the Onion website. At first because of the wrong way (the first in the Ubuntu configuration, found that can not succeed, the reason is not clear, a full day =.=), and then go to the window under the configuration, found very smooth! So record the configuration process. 2. Environment Construction 2.1 Tor to the Tor official website to download the latest version (Https://www.torproject.org/download/download), if the above address can not access (by the wall, you understand), you may use this address https:// Tor.eff.org/download/download.html.en. After download, install directly using the default option, where the installation directory is: C:\tor-win32-0.2.7.6. When the installation is complete, start C:\tor-win32-0.2.7.6\Tor\tor.exe
Note: Tor now requires a VPN for normal use, so connect to VPN before starting Tor.exe, or you won't be able to use the Tor network.
2.2 Privoxywindow platform Download the installation package (HTTP://WWW.SILVESTER.ORG.UK/PRIVOXY/WINDOWS/3.0.23/) directly from the official website, where the installation directory is: C:\Program Files ( x86) \privoxy, after installing the Config.txt under Open Directory, add the following configuration entry: forward-socks5/localhost:9050.
As shown in the following:
9050 is the Tor default listening port, and if you modify it, you have to follow the changes.
Restart Privoxy at this point. It is important to note that the Privoxy is using port 8118 by default.
3. Use Tor network 3.1 to use the firefox--option in Firefox-advanced-network-Connect, then click "Settings" to enter the proxy settings screen.

Fill in the following information

Once saved, you can access the Onion network without an accident. Onion site can be found here: http://thehiddenwiki.org/on a

3.2 Using the same principles as Firefox in your program, you want to use Tor in Java, and simply use proxies (you've tried orchid before,Silvertunnel_ng Such a framework, have no effect, and then did not continue to try to switch to Privoxy, if a friend has a viable solution, hope to share. directly on the code: import java.util.ArrayList; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.NameValuePair; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; /*** Download onion Web page using tor proxy* @author nerve */public class torhttpclient { Public static void main (string[] args) { //create Httpclientbuilder httpclientbuilder Httpclientbuilder = Httpclientbuilder. Create  (); //HttpClient closeablehttpclient closeablehttpclient = httpclientbuilder. Build (); //proxy address, proxy port number, protocol type httphost Proxy = new httphost ("127.0.0.1", 8118, "http"); requestconfig Config = requestconfig. Custom  (). SetProxy (proxy). Build ();    //Request address httpget HttpPost = new httpget ("http://mobil7rab6nuf7vx.onion/");          httppost. Setconfig (config); try {closeablehttpresponse Response = closeablehttpclient. Execute (httppost); /c10>httpentity httpentity = response. getentity (); System. Out. println ("Response code="+response. Getstatusline (). Getstatuscode ()); if (httpentity ! = null) { //Print response content System. Out. println ("Response content: \ n" + entityutils. toString  (httpentity, "UTF-8"));             }   //release Resources closeablehttpclient. Close (); } Catch (Exception e) { e. Printstacktrace  ();         }     }}

the referenced jar package:
OK.


From for notes (Wiz)

"Window" Tor (onion head routing) +privoxy Network practice (with Java instance code)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.