 |
plc.myforum.ro PLCs users www.plc.myforum.ro!
|
| View previous topic :: View next topic |
| Author |
Message |
kosta Member

Joined: 09 Aug 2015 Posts: 161 Location: Salonic
|
Posted: 20/12/2016 13:21 Post subject: QuickStart TOR in .NET Core |
|
|
QuickStart TOR in .NET Core
https://www.codeproject.com/Articles/1161078/QuickStart-TOR-in-NET-Core
This library aims to serve these basic needs and nothing more. In other words: if you simply want to "change your IP", this library is for you.
Understanding the problem
Some people attempt to launch the Tor process on their local machine, giving the process a port number for the SOCKS port, and then configure their browser to point to the Tor process. This will not work.
Tor is a SOCKS proxy which means that it is able to connect to IP addresses and ports, but it does not understand HTTP requests.
Tor.NET - A managed Tor network library
https://www.codeproject.com/articles/1072864/tor-net-a-managed-tor-network-library
https://www.codeproject.com/KB/cs/1072864/Tor_NET_1_0_2.zip
Configure TOR
Download TOR Expert Bundle.
https://www.torproject.org/download/download
You can find a samle TOR config file here, call it torrc.
https://svn.torproject.org/svn/tor/tags/tor-0_0_9_5/src/config/torrc.sample.in
Place torrc in the proper default location (depending on your OS), or just run the tor process later by feeding it with the right configuration. Read more about it, here.
https://www.torproject.org/docs/tor-manual.html.en
Edit the sample config file:
Optionally uncomment and edit the SocksPort, if you don't uncomment it, it will default to 9050 port anyway.
Uncomment the default ControlPort 9051, optionally edit it.
Uncomment and modify the password hash:
To run my tests, for the ControlPortPassword = "ILoveBitcoin21" the hash should be: HashedControlPassword 16:0978DBAF70EEB5C46063F3F6FD8CBC7A86DF70D2206916C1E2AE29EAF6
You should use different, more complicated one. Figure it out, then you can start tor like this: tor --hash-password password where password is the password you've chosen. It will give you the hashed password.
Start tor, it will listen to the ports you set in the config file.
SocksPort vs ControlPort
The control port is used for controlling Tor, usually via other software like Arm. The Socks port is the port running as a SOCKS5 proxy. This is the one you want to use. Please note that Tor is not an HTTP proxy, so your script will need to be configured to use a SOCKS5 proxy.
http://tor.stackexchange.com/questions/12627/whats-the-difference-between-controlport-and-socksport/12632#12632
Build & Test
If you are in a hurry, you can skip this section and just get the NuGet package and use it, but you might save some time if you make sure everything runs fine, by running my tests. Now get .NET Core, if you haven't already done so and fire up a terminal:
git clone https://github.com/nopara73/DotNetTor
cd DotNetTor/
dotnet restore
cd src/DotNetTor.Tests/
dotnet test
How to use it
Consider the following simple console app, where
I write out your real IP
Your TOR IP
Change your TOR circuit
Finally write out the changed TOR IP.
| Code: |
var requestUri = "http://icanhazip.com/"; // Gives back your IP
// 1. Get your (real) IP, just like you normally do
using (var httpClient = new HttpClient())
{
var content = httpClient.GetAsync(requestUri).Result.Content.ReadAsStringAsync().Result;
Console.WriteLine($"Your real IP: \t\t{content}");
}
// 2. Get your IP through TOR
using (var socksPortClient = new SocksPort.Client())
{
var handler = socksPortClient.GetHandlerFromDomain("icanhazip.com");
using (var httpClient = new HttpClient(handler))
{
var content = httpClient.GetAsync(requestUri).Result.Content.ReadAsStringAsync().Result;
Console.WriteLine($"Your TOR IP: \t\t{ content}");
}
// 3. Change TOR IP
var controlPortClient = new ControlPort.Client(password: "ILoveBitcoin21");
controlPortClient.ChangeCircuit();
// 4. Get changed TOR IP
handler = socksPortClient.GetHandlerFromRequestUri(requestUri);
using (var httpClient = new HttpClient(handler))
{
var content = httpClient.GetAsync(requestUri).Result.Content.ReadAsStringAsync().Result;
Console.WriteLine($"Your other TOR IP: \t{content}");
}
} |
https://github.com/joelverhagen/SocketToMe
https://github.com/sharpbrowser/Tor.NET
Tor.NET - A managed Tor network library
https://www.codeproject.com/articles/1072864/tor-net-a-managed-tor-network-library |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|