|
You last visited: Today at 13:54
Advertisement
[TUTORIAL] How to make a simple Injector in C#
Discussion on [TUTORIAL] How to make a simple Injector in C# within the Cabal Guides & Templates forum part of the Cabal Online category.
07/31/2013, 21:19
|
#1
|
elite*gold: 0
Join Date: Jul 2011
Posts: 2
Received Thanks: 25
|
[TUTORIAL] How to make a simple Injector in C#
Hello ladies and gentleman today we are going to make a simple injector in C#, ok lets start!
1. First we need to create a new Windows Form Application:
2. Double click on Form1 and add this Reference to our program:
Code:
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
3. Paste this code and put it as image show:
Code:
[DllImport("kernel32")]
public static extern IntPtr CreateRemoteThread(
IntPtr hProcess,
IntPtr lpThreadAttributes,
uint dwStackSize,
UIntPtr lpStartAddress, // raw Pointer into remote process
IntPtr lpParameter,
uint dwCreationFlags,
out IntPtr lpThreadId
);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
UInt32 dwDesiredAccess,
Int32 bInheritHandle,
Int32 dwProcessId
);
[DllImport("kernel32.dll")]
public static extern Int32 CloseHandle(
IntPtr hObject
);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool VirtualFreeEx(
IntPtr hProcess,
IntPtr lpAddress,
UIntPtr dwSize,
uint dwFreeType
);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern UIntPtr GetProcAddress(
IntPtr hModule,
string procName
);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAllocEx(
IntPtr hProcess,
IntPtr lpAddress,
uint dwSize,
uint flAllocationType,
uint flProtect
);
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
string lpBuffer,
UIntPtr nSize,
out IntPtr lpNumberOfBytesWritten
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(
string lpModuleName
);
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
internal static extern Int32 WaitForSingleObject(
IntPtr handle,
Int32 milliseconds
);
public Int32 GetProcessId(String proc)
{
Process[] ProcList;
ProcList = Process.GetProcessesByName(proc);
return ProcList[0].Id;
}
public void InjectDLL(IntPtr hProcess, String strDLLName)
{
IntPtr bytesout;
// Length of string containing the DLL file name +1 byte padding
Int32 LenWrite = strDLLName.Length + 1;
// Allocate memory within the virtual address space of the target process
IntPtr AllocMem = (IntPtr)VirtualAllocEx(hProcess, (IntPtr)null, (uint)LenWrite, 0x1000, 0x40); //allocation pour WriteProcessMemory
// Write DLL file name to allocated memory in target process
WriteProcessMemory(hProcess, AllocMem, strDLLName, (UIntPtr)LenWrite, out bytesout);
// Function pointer "Injector"
UIntPtr Injector = (UIntPtr)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
if (Injector == null)
{
MessageBox.Show(" Injector Error! \n ");
// return failed
return;
}
// Create thread in target process, and store handle in hThread
IntPtr hThread = (IntPtr)CreateRemoteThread(hProcess, (IntPtr)null, 0, Injector, AllocMem, 0, out bytesout);
// Make sure thread handle is valid
if (hThread == null)
{
//incorrect thread handle ... return failed
MessageBox.Show(" hThread [ 1 ] Error! \n ");
return;
}
// Time-out is 10 seconds...
int Result = WaitForSingleObject(hThread, 10 * 1000);
// Check whether thread timed out...
if (Result == 0x00000080L || Result == 0x00000102L || Result == 0xFFFFFFFF)
{
/* Thread timed out... */
MessageBox.Show(" hThread [ 2 ] Error! \n ");
// Make sure thread handle is valid before closing... prevents crashes.
if (hThread != null)
{
//Close thread in target process
CloseHandle(hThread);
}
return;
}
// Sleep thread for 1 second
Thread.Sleep(1000);
// Clear up allocated space ( Allocmem )
VirtualFreeEx(hProcess, AllocMem, (UIntPtr)0, 0x8000);
// Make sure thread handle is valid before closing... prevents crashes.
if (hThread != null)
{
//Close thread in target process
CloseHandle(hThread);
}
// return succeeded
return;
}
4. Add the Inject button to our Form[Design], When finish double click on it:
5. Paste this code to our button1 (Inject Button):
Code:
String strDLLName = @"C:\EXAMPLE.dll"; // here you put the dll you want, only the path.
String strProcessName = "cabalmain"; //here you will put the process name without ".exe"
Int32 ProcID = GetProcessId(strProcessName);
if (ProcID >= 0)
{
IntPtr hProcess = (IntPtr)OpenProcess(0x1F0FFF, 1, ProcID);
if (hProcess == null)
{
MessageBox.Show("OpenProcess() Failed!");
return;
}
else
InjectDLL(hProcess, strDLLName);
}
And we are done here! if you like it, and want to make automatic injection Thanks me and I will show you. happy Injection!
|
|
|
08/16/2017, 11:57
|
#2
|
elite*gold: 0
Join Date: Jun 2017
Posts: 35
Received Thanks: 8
|
Thanks for a lot
|
|
|
09/22/2017, 09:57
|
#3
|
elite*gold: 0
Join Date: Oct 2016
Posts: 13
Received Thanks: 0
|
How to make a simple trainer in C#?
|
|
|
10/07/2017, 15:41
|
#4
|
elite*gold: 61
Join Date: Oct 2017
Posts: 189
Received Thanks: 103
|
Thanks a lot..
|
|
|
11/01/2017, 10:11
|
#5
|
elite*gold: 0
Join Date: Nov 2017
Posts: 1
Received Thanks: 0
|
thanks
|
|
|
11/14/2017, 21:45
|
#6
|
elite*gold: 0
Join Date: Oct 2014
Posts: 12
Received Thanks: 4
|
got problem before inject
|
|
|
12/05/2017, 13:37
|
#7
|
elite*gold: 0
Join Date: Oct 2016
Posts: 2
Received Thanks: 0
|
hi all any 1 can help me create 1 dll ?
|
|
|
03/17/2019, 16:31
|
#8
|
elite*gold: 0
Join Date: Mar 2019
Posts: 1
Received Thanks: 0
|
Quote:
Originally Posted by fr34km4n
Hello ladies and gentleman today we are going to make a simple injector in C#, ok lets start!
1. First we need to create a new Windows Form Application:
2. Double click on Form1 and add this Reference to our program:
Code:
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
3. Paste this code and put it as image show:
Code:
[DllImport("kernel32")]
public static extern IntPtr CreateRemoteThread(
IntPtr hProcess,
IntPtr lpThreadAttributes,
uint dwStackSize,
UIntPtr lpStartAddress, // raw Pointer into remote process
IntPtr lpParameter,
uint dwCreationFlags,
out IntPtr lpThreadId
);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
UInt32 dwDesiredAccess,
Int32 bInheritHandle,
Int32 dwProcessId
);
[DllImport("kernel32.dll")]
public static extern Int32 CloseHandle(
IntPtr hObject
);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool VirtualFreeEx(
IntPtr hProcess,
IntPtr lpAddress,
UIntPtr dwSize,
uint dwFreeType
);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern UIntPtr GetProcAddress(
IntPtr hModule,
string procName
);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAllocEx(
IntPtr hProcess,
IntPtr lpAddress,
uint dwSize,
uint flAllocationType,
uint flProtect
);
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
string lpBuffer,
UIntPtr nSize,
out IntPtr lpNumberOfBytesWritten
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(
string lpModuleName
);
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
internal static extern Int32 WaitForSingleObject(
IntPtr handle,
Int32 milliseconds
);
public Int32 GetProcessId(String proc)
{
Process[] ProcList;
ProcList = Process.GetProcessesByName(proc);
return ProcList[0].Id;
}
public void InjectDLL(IntPtr hProcess, String strDLLName)
{
IntPtr bytesout;
// Length of string containing the DLL file name +1 byte padding
Int32 LenWrite = strDLLName.Length + 1;
// Allocate memory within the virtual address space of the target process
IntPtr AllocMem = (IntPtr)VirtualAllocEx(hProcess, (IntPtr)null, (uint)LenWrite, 0x1000, 0x40); //allocation pour WriteProcessMemory
// Write DLL file name to allocated memory in target process
WriteProcessMemory(hProcess, AllocMem, strDLLName, (UIntPtr)LenWrite, out bytesout);
// Function pointer "Injector"
UIntPtr Injector = (UIntPtr)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
if (Injector == null)
{
MessageBox.Show(" Injector Error! \n ");
// return failed
return;
}
// Create thread in target process, and store handle in hThread
IntPtr hThread = (IntPtr)CreateRemoteThread(hProcess, (IntPtr)null, 0, Injector, AllocMem, 0, out bytesout);
// Make sure thread handle is valid
if (hThread == null)
{
//incorrect thread handle ... return failed
MessageBox.Show(" hThread [ 1 ] Error! \n ");
return;
}
// Time-out is 10 seconds...
int Result = WaitForSingleObject(hThread, 10 * 1000);
// Check whether thread timed out...
if (Result == 0x00000080L || Result == 0x00000102L || Result == 0xFFFFFFFF)
{
/* Thread timed out... */
MessageBox.Show(" hThread [ 2 ] Error! \n ");
// Make sure thread handle is valid before closing... prevents crashes.
if (hThread != null)
{
//Close thread in target process
CloseHandle(hThread);
}
return;
}
// Sleep thread for 1 second
Thread.Sleep(1000);
// Clear up allocated space ( Allocmem )
VirtualFreeEx(hProcess, AllocMem, (UIntPtr)0, 0x8000);
// Make sure thread handle is valid before closing... prevents crashes.
if (hThread != null)
{
//Close thread in target process
CloseHandle(hThread);
}
// return succeeded
return;
}
4. Add the Inject button to our Form[Design], When finish double click on it:
5. Paste this code to our button1 (Inject Button):
Code:
String strDLLName = @"C:\EXAMPLE.dll"; // here you put the dll you want, only the path.
String strProcessName = "cabalmain"; //here you will put the process name without ".exe"
Int32 ProcID = GetProcessId(strProcessName);
if (ProcID >= 0)
{
IntPtr hProcess = (IntPtr)OpenProcess(0x1F0FFF, 1, ProcID);
if (hProcess == null)
{
MessageBox.Show("OpenProcess() Failed!");
return;
}
else
InjectDLL(hProcess, strDLLName);
}
And we are done here! if you like it, and want to make automatic injection Thanks me and I will show you. happy Injection!
|
still working thanks alot dude!!! #YouAreAKing
|
|
|
08/18/2019, 22:08
|
#9
|
elite*gold: 0
Join Date: Aug 2019
Posts: 1
Received Thanks: 0
|
can someone help me it does not inject when i press the button
Discord: Leak#6228
The DLL Works because i have tried it with different injectors.
|
|
|
04/07/2020, 00:52
|
#10
|
elite*gold: 0
Join Date: May 2018
Posts: 179
Received Thanks: 30
|
Quite late, but good job. Helped me out!
|
|
|
05/27/2020, 23:08
|
#11
|
elite*gold: 0
Join Date: May 2017
Posts: 1
Received Thanks: 0
|
THANK YOUUUUUUUUU
|
|
|
|
Similar Threads
|
[TUTORIAL] how to make your own .dll injector
06/11/2013 - S4 League Hacks, Bots, Cheats & Exploits - 9 Replies
Hey there reading this, obviously if you didn't notice, This is a tutorial, A really simple one telling you how to make your own dll injector, I'll be instructing you and telling you what to use in the form (e.x. : buttons/textboxes/etc.) and will provide my injector's source code (Solution) down in the downloads
What you should be able to do after this TUT
Make your own dll injector, that injects multiple dll files at once
Use the 'OpenFileDialog' tool
What you'll need in this TUT
|
Tutorial how to make a injector!
05/28/2012 - Coding Tutorials - 10 Replies
Watcha need:
Microsoft Visual Basic 2008
Steps:
Make your own windows form application project
Add:
1 Label
1 Button
1 Timer
|
Simple .Dll Injector
07/29/2010 - Combat Arms Hacks, Bots, Cheats & Exploits - 5 Replies
Hallo
habe einen simple injector gebastelt der nur für eine hack dll ist
viel spaß und ist 100% clean
1. Unbennen der .dll
du musst die hack.dll also den namen der .dll in -> WORLD DLL INJECT.dll
2. WORLD DLL INJECT.dll und INJECTOR in den CA ordner
3. INJECTOR als Adminstartor bei Vista/7 starten und Hacken !
Virustotal :
|
All times are GMT +2. The time now is 13:54.
|
|