Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8

    C# DLL Injection Library

    Due to the lack of well documented C# sources, I decided to make my own injection library. It supports both x86 and x64 injection for all methods.

    Currently, it supports the following methods
    CreateRemoteThread
    QueueUserAPC
    SetThreadContext (Thread Hijack)

    I will probably be adding more methods when I get the time, however, for now, It works as is.

    The source code is hosted on ****** as well as the instructions on how to use it.

  2. The Following 3 Users Say Thank You to notquin For This Useful Post:

    citydrifter (10-24-2018),critikal17 (11-14-2018),MikeRohsoft (10-13-2018)

  3. #2
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    Quote Originally Posted by notquin View Post
    Due to the lack of well documented C# sources, I decided to make my own injection library. It supports both x86 and x64 injection for all methods.

    Currently, it supports the following methods
    CreateRemoteThread
    QueueUserAPC
    SetThreadContext (Thread Hijack)

    I will probably be adding more methods when I get the time, however, for now, It works as is.

    The source code is hosted on ****** as well as the instructions on how to use it.
    - Added RtlCreateUserThread method

  4. #3
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    Quote Originally Posted by notquin View Post
    Due to the lack of well documented C# sources, I decided to make my own injection library. It supports both x86 and x64 injection for all methods.

    Currently, it supports the following methods
    CreateRemoteThread
    QueueUserAPC
    SetThreadContext (Thread Hijack)

    I will probably be adding more methods when I get the time, however, for now, It works as is.

    The source code is hosted on ****** as well as the instructions on how to use it.
    - Added the ability to Erase PE Headers
    - Added the ability to Randomise PE Headers

  5. #4
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    very nice maybe u can add an optional second parameter for getting the memoryInformation as output variable, so People can even restore the PE Header if they want without changing anything. If you restore the PE Header u can unload your DLL with FreeLibraryAndExitThread((HMODULE)handle, 0); from the Injected DLL itself

  6. #5
    NewieX's Avatar
    Join Date
    Jul 2016
    Gender
    female
    Posts
    39
    Reputation
    10
    Thanks
    1
    U can a manual map?

  7. #6
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Nice, go for manual mapping next. I can offer some C++ code for reference here

  8. #7
    brlala's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    1
    thanks for the share! i've been needing this for awhile

  9. #8
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    As per request, I will probably be implementing manual mapping for both architectures in the next few weeks/months once I finish up with my exams

  10. #9
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    In prep for any future updates I decided it was time to finally add unit tests

    - Added unit tests for both x86 and x64 versions of the library

  11. #10
    critikal17's Avatar
    Join Date
    Jul 2017
    Gender
    male
    Location
    Your bitch's house
    Posts
    251
    Reputation
    10
    Thanks
    55
    My Mood
    Daring
    Good clean code! Love it!

    Selling Bitcoin!
    15% Rate
    $1.15 Paypal for Every $1 BTC
    Click to add me on IM!

  12. #11
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    You should start using Marshal.GetLastError() and SetLastError = true for your p/invokes

  13. #12
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    Quote Originally Posted by Biesi View Post
    You should start using Marshal.GetLastError() and SetLastError = true for your p/invokes
    I do use them I'm debugging new code. However, there's no point leaving them in the library as the return value of each method is a boolean, not a windows error code.

  14. #13
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Quote Originally Posted by notquin View Post
    I do use them I'm debugging new code. However, there's no point leaving them in the library as the return value of each method is a boolean, not a windows error code.
    There is a point. If you throw a Win32Exception the framework will put a useful error message to your error. So the user will get a "0x5 Access denied" instead of a generic "operation failed".

  15. #14
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    Quote Originally Posted by notquin View Post
    Due to the lack of well documented C# sources, I decided to make my own injection library. It supports both x86 and x64 injection for all methods.

    Currently, it supports the following methods
    CreateRemoteThread
    QueueUserAPC
    SetThreadContext (Thread Hijack)

    I will probably be adding more methods when I get the time, however, for now, It works as is.

    The source code is hosted on ****** as well as the instructions on how to use it.
    I finally got aroud to writing a manual mapping method. Currently, the library only supports x86 manual mapping as there are some arithmetic issues I need to fix for x64 which I hope to have fixed sometime in the future.

    I apologise in advance for the code if your looking at the source, It has been a long couple of days writing this in-between exams but I will definitely clean it up to my usual standard in the near future.

    - - - Updated - - -

    Also a word of warning, I was unable to test mapping Tls entries because I didn't have any DLL's on hand that utilised the Tls Directory
    Last edited by notquin; 11-21-2018 at 03:20 AM.

  16. #15
    notquin's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    8
    The library is now available as a NuGet package to make installation much easier

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 10-26-2014, 04:46 AM
  2. [HELP] - DLL Injection
    By pelonzudo in forum C++/C Programming
    Replies: 1
    Last Post: 09-10-2008, 02:27 AM
  3. Crash at Dll inject
    By CyberStriker in forum WarRock - International Hacks
    Replies: 1
    Last Post: 08-13-2008, 06:51 AM
  4. [Help!] CA crash on dll inject
    By CyberStriker in forum Combat Arms Hacks & Cheats
    Replies: 9
    Last Post: 08-12-2008, 09:23 PM
  5. DLL injection Failled
    By aynal in forum WarRock - International Hacks
    Replies: 1
    Last Post: 01-15-2006, 09:41 PM