Git Product home page Git Product logo

tcprelayinjecter2's Introduction

TCPRelayInjecter2

Author: Arno0x.

As opposed to my first version of this project, this second version:

  • uses a completely different approach (no more CLR loading into the remote process, not necessary),
  • supports both 32 or 64 bits target process.

This tool is used to inject a "TCP Relay" managed assembly (TcpRelay_x86.dll or TcpRelay_x64.dll) into an unmanaged process. The relay is basically listening on a TCP port and relaying (forwarding) the received connection to another destination port, either locally (localhost) or, optionnaly, to a remote IP.

Note: TCPRelayInjecter only relays TCP connections.

Background and context

I created this tool in order to bypass Windows local firewall rules preventing some inbound connections I needed (in order to perform some relay and/or get a MiTM position). As a non-privileged user, firewall rules could not be modified or added.

The idea is to find a process running as the same standard (non-privileged) user AND allowed to receive any network connection, or at least the one we need. You can find such a process by analyzing the local FW rules:

netsh advfirewall firewall show rule name=all

From there we just have to inject a TCP Relay assembly in the process fulfilling your needs, passing it some arguments like a local port to listen to, a destination port and an optionnal destination IP to forward the traffic to.

Compile

The injecter comes in two flavors achieving exactly the same goal: there's a C++ version (TcpRelayInjecter.cpp) and there's a C# version (TcpRelayInjecter.cs). You only need to compile one of these two files. It might be easier though to compile the C# injecter as it doesn't require VisualStudio or any other C++ compiler, it just needs the csc.exe compiler which comes with the .Net framework installed with any recent Windows OS.

Targetting 32 bits processes:

  • You'll need the 32 bits version of both the DLL and the injecter
  • Compile the DLL: *Refer to the comments in the headers of the TcpRelay.cs
    • Modify the .Net DLL to export the EntryPoint method as explained in the file header comments.
  • Compile the injecter either using TcpRelayInjecter.cpp or TcpRelayInjecter.cs. Refer to the file header comments for compilation instructions.

Targetting 64 bits processes:

  • You'll need the 64 bits version of both the DLL and the injecter
  • Compile the DLL:
    • Refer to the comments in the headers of the TcpRelay.cs
    • Modify the .Net DLL to export the EntryPoint method as explained in the file header comments.
  • Compile the injecter either using TcpRelayInjecter.cpp or TcpRelayInjecter.cs. Refer to the file header comments for compilation instructions.

Usage

Prior to running the tool, ensure the binary files are all in the same path:

  • TcpRelayInjecter_x86.exe
  • TCPRelay_x86.dll

or

  • TcpRelayInjecter_x64.exe
  • TCPRelay_x64.dll

Then use the following command line:

TcpRelayInjecter_x86|x64.exe <target_process_name> <listening_port> <destination_port> [destination_IP]

  • target_process_name: the name of the executable we want to inject the TCP Forwarder into
  • listening_port: the TCP port to use for listening for inbound connections
  • destination_port: the TCP port to which forward the traffic (typically another process would be listening on that port)
  • destination_IP: Optionnal, the destination IP to which forward the traffic, if not specified, defaults to localhost

tcprelayinjecter2's People

Contributors

arno0x 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.