Skip to content

Commit

Permalink
First Trou commit !
Browse files Browse the repository at this point in the history
Please note that I am currently writing the whole wiki.
It will take some time, so be patient :)

And contact me on discord if you have any questions!
  • Loading branch information
NaolShow committed Apr 30, 2020
1 parent 88e3a07 commit 1f90925
Show file tree
Hide file tree
Showing 18 changed files with 2,935 additions and 2 deletions.
547 changes: 547 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

97 changes: 95 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,95 @@
# Trou
Tor + Privoxy for the best anonymous HTTP proxy implementation on C#
# <img src="https://github.com/NaolShow/Trou/blob/master/logo.png?raw=true" width="250"/>
---

> Join **ToWolf** server to get latest news about **Trou** - https://discord.gg/m7CZ6md
> Tor + Privoxy for the best anonymous HTTP proxy implementation on C#
Trou is a complete Tor (and Tor Controller) and Privoxy implementation on C#
You can use every services separately or combined to have a local anonymous proxy !

**You could use Trou with**:
- HttpClients
- WebClients
- WebBrowsers
- (and everything that support HTTP or Socks5 proxy..)

## Compatibility

**Trou is made using .NET Core 3.1 and it's working currently working on:**
- Windows 8 and higher (you could go up to windows 7, just check the project wiki)

/!\ **Linux and Mac OS compatibility is planned** /!\

# :rocket: Quick example
---

Here's a quick example on how to use Trou.
This example is very minimalist, and it doesn't even care about errors/warnings/exceptions..

You can also get this [example project](https://github.com/NaolShow/Trou/blob/master/TrouExample)

```cs

// - Instantiate Trou proxy
TrouProxy proxy = new TrouProxy(new TorProxySettings() {
TorBundlePath = @"C:\AnyFolder\TorProxy"
}, new TorControllerSettings() {

}, new PrivoxyProxySettings() {
PrivoxyBundlePath = @"C:\AnyFolder\PrivoxyProxy"
});

// - Start
proxy.Start();

// - Check IP
// Create client connected to Tor using Trou
WebClient client = new WebClient() {
Proxy = new WebProxy("127.0.0.1:8118")
};

// Write TOR IP address
Console.WriteLine(client.DownloadString("http://api.ipify.org"));

// - Stop
Console.ReadLine();
client.Dispose();
proxy.Dispose();

```

# :books: Documentation
---

**The complete Trou documentation [can be found here](https://github.com/NaolShow/Trou/wiki)**

# :question: Help
---

If you need help, or if you want to contact me in general, just make a github issue ticket !
You can also contact me on my discord server or in private messages: [NaolShow#7243](#)

# :wrench: Installation
---

You have two ways to install Trou, the first one is by far the most simplest one:
```
// With the package manager (Nuget)
PM> Install-Package Trou
// With .NET CLI
dotnet add package Trou
```
You can also go in your project top bar menu in visual studio > Manage Nuget packages > Search for "Trou" > Install

The second way is to go in the [release](https://github.com/NaolShow/Trou/releases) tab in the github project,
and download the last .dll, and then just reference it in your project!

# :newspaper: Licence
---

Distributed under the GNU General Public Licence v3.0. See LICENSE for more information.
31 changes: 31 additions & 0 deletions Trou.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Trou", "Trou\Trou.csproj", "{818BC883-C5C2-4638-844F-48A68CEECE8D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrouExample", "TrouExample\TrouExample.csproj", "{D5124A10-86EE-4904-B266-88F3A4AAD32A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{818BC883-C5C2-4638-844F-48A68CEECE8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{818BC883-C5C2-4638-844F-48A68CEECE8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{818BC883-C5C2-4638-844F-48A68CEECE8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{818BC883-C5C2-4638-844F-48A68CEECE8D}.Release|Any CPU.Build.0 = Release|Any CPU
{D5124A10-86EE-4904-B266-88F3A4AAD32A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5124A10-86EE-4904-B266-88F3A4AAD32A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5124A10-86EE-4904-B266-88F3A4AAD32A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5124A10-86EE-4904-B266-88F3A4AAD32A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6C833C61-2A95-4808-A4FD-C44E78365717}
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions Trou/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CS1591: Missing XML comment for publicly visible type or member
dotnet_diagnostic.CS1591.severity = none
137 changes: 137 additions & 0 deletions Trou/Services/PrivoxyProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using System;
using System.IO;
using System.Linq;
using Trou.ServicesSettings;
using Trou.Tools;

namespace Trou.Services {

/// <summary>
/// Allows to start a <see cref="PrivoxyProxy"/> which will listen to an IP and a Port for HTTP requests
/// </summary>
public class PrivoxyProxy : IDisposable {

#region Variables

#region PrivoxyProxy

/// <summary>
/// <see cref="PrivoxyProxy"/> hidden process
/// </summary>
public HiddenProcess Process { get; private set; }
/// <summary>
/// <see cref="PrivoxyProxy"/> process executable path
/// </summary>
public string PrivoxyExe { get; private set; }

/// <summary>
/// <see cref="PrivoxyProxy"/> settings
/// </summary>
public PrivoxyProxySettings Settings { get; set; }

#endregion

#endregion

#region Constructors

/// <summary>
/// Initializes a new intance of the <see cref="PrivoxyProxy"/> service
/// </summary>
public PrivoxyProxy(PrivoxyProxySettings settings) {

// Save
Settings = settings;

}

#endregion

/// <summary>
/// Refreshes every Arguments and Configuration keys from the <see cref="PrivoxyProxySettings"/> before starting the <see cref="PrivoxyProxy"/> process
/// </summary>
private void RefreshArguments() {

#region Paths

// Privoxy executable path
PrivoxyExe = Settings.PrivoxyFile ?? Path.Combine(Settings.PrivoxyBundlePath, "privoxy.exe");

#endregion

#region Network

// Listening address & port
Settings.Configuration["listen-address"] = string.Format("{0}:{1}", Settings.ListeningAddress, Settings.ListeningPort);

#region Forward

// Forward to SOCKS 5 proxy
Settings.Configuration["forward-socks5t"] = string.Format("/ {0}:{1} .", Settings.ForwardAddress, Settings.ForwardPort);

#endregion

#endregion

#region Arguments

// Set process as not a daemon
Settings.Arguments["--no-daemon"] = string.Empty;

// Set configuration file in arguments
Settings.Arguments["configfile"] = Path.Combine(Path.GetDirectoryName(PrivoxyExe), "trou_privoxy_config");

#endregion

}

#region Start & Stop

/// <summary>
/// Starts the <see cref="PrivoxyProxy"/> service
/// </summary>
public void Start() {

// Privoxy process is already started
if (Process != null) {

// Stop Privoxy process
Dispose();

}

// Refresh arguments and get them as a single string
RefreshArguments();
string arguments = string.Join(" ", Settings.Arguments.ToList().Select(a => string.Format("{0} {1}", a.Key, a.Value)));

// Write the configuration file
File.WriteAllText(Path.Combine(Path.GetDirectoryName(PrivoxyExe), "trou_privoxy_config"), string.Join(Environment.NewLine, Settings.Configuration.ToList().Select(a => string.Format("{0} {1}", a.Key, a.Value))));

// Create hidden process
Process = new HiddenProcess(Path.GetDirectoryName(PrivoxyExe), PrivoxyExe, arguments, HiddenProcess.PriorityClass.NORMAL_PRIORITY_CLASS, true);

// Start hidden process
if (!Process.Start()) {

// Throw exception
throw new Exception("start_failed: Privoxy process start failed");

}

}

/// <summary>
/// Dispose the <see cref="PrivoxyProxy"/> service
/// </summary>
public void Dispose() {

// Dispose process
Process?.Dispose();

}

#endregion

}

}
Loading

0 comments on commit 1f90925

Please sign in to comment.