viernes, 30 de agosto de 2013

TORified .NET applications

Today I learned how to use TOR in a .NET application. It is pretty easy, I'm going to explain it step by step.
  1. 1. Download Privoxy and TOR and install them by the default way.
  2. 2. Open the config file in your Privoxy installation folder and unccomment the following line: "forward-socks5   /  127.0.0.1:9050". This will allow request routing over TOR.
  3. 3. Open Visual Studio and create a new console project and paste this piece of code:
        public static void Main(string[] args)
        {
            
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://whatismyipaddress.com/");
            request.Proxy = new WebProxy("127.0.0.1",8118);
            string s = "";
            using (var response = request.GetResponse())
            {
                using (var reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
                {
                    s = reader.ReadToEnd();
                }
            }
        }

That's all. Now you can perform anonimous queries :)

No hay comentarios:

Publicar un comentario