Coder Social home page Coder Social logo

enkomio / managedinjector Goto Github PK

View Code? Open in Web Editor NEW
198.0 11.0 32.0 5.04 MB

A C# DLL injection library

License: Other

Batchfile 23.02% C# 71.94% F# 5.04%
dll-injection dll-injector injection reverse-engineering reversing dotnet process-injector process-injection process-control csharp

managedinjector's Introduction

Managed Injector

This project implements a .NET Assembly injection library (it is inspired by the snoopwpf project). The remote process can be a managed or unmanaged one.

Download

Usage

When you want to inject an assembly in a remote process you have to consider the following aspects:

  • The ManagedInjector project currently supports only 32 bit process
  • The remote process must be a windows application (it must process messages in a message loop)

If the above pre-conditions are satisfied you can inject an assembly and invoke an activation method. There are three possibilities to invoke the activation method:

  • You must specify the full method name to invoke (eg. this.is.my.namespace.class.method)
  • You can inject an executable that defines an EntryPoint method to execute (like a Console project)
  • You can define a method with the following signatue: <public|private> static void Inject()

This library is also used by Shed to inject a DLL in a remote process. You can see a video here.

For practical examples see the TestRunner project.

Adding dependencies

If the injected assembly has any dependencies on not standard .NET assemblies, you can add those dependencies with the AddDependency method.

Adding external files

If the injected assembly needs to load some external file in order to work correctly (like a configuration file) you can specify them with the AddFile method. This method will copy the specified file in the working directory of the injected process.

Passing an argument to the Inject method

In some case is necessary to pass an argument to the method called in the injected assembly. This is achieved by passing a context object to the Inject method. Then, the Injected method needs to cast the context object to the real type (see AssemblyWithMethodAcceptingAnArgument for an example). The framework uses the BinaryFormatter class to serialize the context object, so be sure that the specified object can be serialized.

Example

Let's consider the following code:

using System;

namespace InjectedAssembly
{
    public class Main
    {
        // we use a default injection method name in order to execute our code in the remote process
        private static void Inject()
        {
            Console.WriteLine("Hello world from the injected process!");
        }
    }
}

in order to inject the Assembly generated from the above code it is enough to use the following code:

var pid = 1234;
var injector = new Injector(pid, Assembly.LoadFile("AssemblyToInject.dll"));
var injectionResult = injector.Inject();

For more examples have a look at the example folder.

Build

ManagedInjector is currently developed by using VisualStudio 2017 Community Edition (be sure to have the latest version installed). To build the source code be sure you have to:

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Antonio Parata - Core Developer - s4tan

License

Managed Injector is licensed under the Creative Commons.

managedinjector's People

Contributors

enkomio 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  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  avatar  avatar  avatar  avatar

managedinjector's Issues

some questions

what are the dependencies of this project?
your referencing DllExport, RGiesecke.DllExport.Metadata which is not to be found
and then your referencing UnmanagedExports via paket.references
so whats this all about, why so many references where are they actually needed?

no .net5 support?
Evidence.GetHostEnumerator(); is not included in .net5

what are the modes of injection supported? only manged 32bit assembly into un/managed 32bit process?
can i inject unmanaged 32 bit assembly into managed 32 bit process?

is the interprocess communication via server/client rly a necessity?

wheres the fake.dll

my build.bat doesnt work because it doesnt find ./src/fake/fake.dll
also when i did download zip it modified the bat file and removed "dotnet", put everything in one line and changed ".dll" to ".exe"

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.