Git Product home page Git Product logo

dotnettor's Introduction

DotNetTor

Stable and performant Tor library in .NET Core.

Windows Linux & OSX
Windows build status Linux & OSX build status

See quickstart tutorial on CodeProject

Build & Test

  1. git clone https://github.com/nopara73/DotNetTor
  2. cd DotNetTor/
  3. dotnet restore
  4. cd src/DotNetTor.Tests/
  5. Configure Tor properly.
  6. dotnet test

Configure Tor

  1. Download Tor Expert Bundle: https://www.torproject.org/download/download
  2. Download the torrc config file sample: https://github.com/nopara73/DotNetTor/blob/master/torrc
  3. Place torrc in the proper default location (depending on your OS) and edit it:
  • Optionally uncomment and edit the SocksPort, if you don't uncomment it will default to 9050 port anyway
  • The default ControlPort in the sample is 9051, optionally edit it.
  • Modify the password hash
    • To run my tests, for the ControlPortPassword = "ILoveBitcoin21" the hash should be: HashedControlPassword 16:0978DBAF70EEB5C46063F3F6FD8CBC7A86DF70D2206916C1E2AE29EAF6
    • For your application you should use different one, a more complicated one. Then start tor like this: tor --hash-password password where password is the password you've chosen. It will give you the HashedControlPassword.
  1. Start tor, it will listen to the ports you set in the config file.

Usage

var requestUri = "http://icanhazip.com/";

// 1. Get real IP
using (var httpClient = new HttpClient())
{
	var message = httpClient.GetAsync(requestUri).Result;
	var content = message.Content.ReadAsStringAsync().Result;
	Console.WriteLine($"Your real IP: \t\t{content}");
}

// 2. Get Tor IP
using (var httpClient = new HttpClient(new SocksPortHandler("127.0.0.1", socksPort: 9050)))
{
	var message = httpClient.GetAsync(requestUri).Result;
	var content = message.Content.ReadAsStringAsync().Result;
	Console.WriteLine($"Your Tor IP: \t\t{content}");

	// 3. Change Tor IP
	var controlPortClient = new ControlPort.Client("127.0.0.1", controlPort: 9051, password: "ILoveBitcoin21");
	controlPortClient.ChangeCircuitAsync().Wait();

	// 4. Get changed Tor IP
	message = httpClient.GetAsync(requestUri).Result;
	content = message.Content.ReadAsStringAsync().Result;
	Console.WriteLine($"Your other Tor IP: \t{content}");
}

Acknowledgement

Originally the SocksPort part of this project was a leaned down, modified and .NET Core ported version of the SocketToMe project.
Originally the ControlPort part of this project was a leaned down, modified and .NET Core ported version of the Tor.NET project.
At this point of the development you can still find parts of the former project in the codebase, however the latter has been completely replaced.

dotnettor's People

Contributors

halotron avatar lontivero avatar mikeapple avatar nicolasdorier avatar nopara73 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.