Code Monkey home page Code Monkey logo

sockethook's Introduction

SocketHook NuGet Badge

This application allow the user to redirect any call to the windows API connect of any process in order to redirect its connection to the configured local port.

Get started

The hook was meant to be controlled by a REST API, thanks to this, any kind of application can "plug" to it and send inject directives. A WPF application using .NET Core 3.1 and the generic hosting APIs was made to show the potential of this architecture, you can see the code on this repository or download the release directly.

The API can either be started using regular CLI args or with a json configuration file on the working directory of the application (or with both). Here are two examples of json config files :

{
    "InjectToExe": "C:\\Users\\User\\Desktop\\SomeProgram.exe",
    "RedirectionPort": 8080,
    "RedirectedIps": [
      "xxx.xxx.xxx",
      "xxx.xxx.xxx"
    ]
}
{
    "InjectToPId": 17881,
    "RedirectionPort": 8080,
    "RedirectedIps": [
      "xxx.xxx.xxx",
      "xxx.xxx.xxx"
    ]
}

Also, if no InjectTo args are being provided, the application will bind a REST API (default port is 80) to the localhost in order to allow any user to triggers inject or createAndInject directive to the application. A killAll directive is also provided in order to kill all the process that might have been created within this injector instance. The route are defined this way :

  • PUT http://127.0.0.1:80/api/createandinject?exePath=C:\\Users\\User\\Desktop\\SomeProgram.exe
  • PUT http://127.0.0.1:80/api/inject?pId=17881
  • DELETE http://127.0.0.1:80/api/killall for the killAll directive

Go further

The WPF application takes advantage of the new .NET Core generic hosting APIs, therefore a library that provides interaction with the hook REST API and extensions methods to register thoses services into the commonly used IServiceCollection. This library is also available on nuget at this address.

The registration logic looks like this :

	services.AddSocketHook(opt =>
	{
		opt.AddConfiguration(ctx.Configuration);
		opt.Configure(x =>
		{
			x.UseHookServiceFactory = true;
			x.OpenHookOnStartup = true;
			x.KillAllOnExit = true;
		});
	});

And this will registers at least an ISocketHookServiceFactory which will be responsible of creating ISocketHookService instances with their relative InjectOptions.

The ISocketHookService provides 3 methods to interact with the hook API :

    public interface ISocketHookService
    {
        ValueTask<bool> TryCreateAndInject(string exePath, CancellationToken token = default);
        ValueTask<bool> TryInject(int pId, CancellationToken token = default);

        /// <exception cref="HttpRequestException" />
        ValueTask KillAllInjectedProcesses(CancellationToken token = default);
    }

Important

If you are experiencing any issue binding the HTTP server to your specified port please check this article from Microsoft : https://docs.microsoft.com/fr-fr/dotnet/framework/wcf/feature-details/configuring-http-and-https?redirectedfrom=MSDN

sockethook's People

Contributors

dependabot[bot] avatar thenameless314159 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sockethook's Issues

Issue with Local Proxy Configuration and Chrome Traffic

I have configured a local proxy on port 8000. After that, I used Postman to make a call to the following address: 127.0.0.1:9000/api/createandinject?exePath=C:\Program Files\Google\Chrome\Application\chrome.exe, and included the following request body:
{
"RedirectionPort": 8000,
"RedirectedIps": []
}
The server responded with a 200 OK status, and Chrome was automatically launched. However, upon inspecting Chrome's traffic, I noticed that it wasn't going through the proxy as expected.

I also attempted using another proxy service (S5Proxy) but encountered the same issue.

I would greatly appreciate your assistance in resolving this matter.

Thank you.

Is allowed authentication proxy?

Hello, I am trying to make a traffic redirector through a Socks5 proxy and I loved your project. It does exactly what I'm looking for, but I don't know if it allows the use of Socks5 proxy authentication. So is authentication allowed?
Because I need to redirect all traffic from a specific program to a Sock5 proxy with authentication that has internet access. SAlu2s

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.