ItsMods

Full Version: [C++]DLL Injector
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Well,
this a little tool for injecting any DLL in any process.
I know its not a big tool but its my first real "hacking" tool so i upload it.
made with C++
Sooo....here it is

EDIT:

Source code:
PHP Code:
#include <windows.h>
#include <tlhelp32.h>
#include <shlwapi.h>
#include "cus.h"

#define CREATE_THREAD_ACCESS (PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ)

using namespace std;


string sProcName;
string sDLLName;

DWORD ProcID;
bool InjectSuccess;
bool hasProcID;

string sDLLStatus;
string sProcessStatus;

charDLLName NULL;
charProcName NULL;

string sEndStatus "Press [F2] to quit";
string sCusInjectStatus "Press [F1] to inject DLL";

bool getProcID(charcPName,DWORD &idAdd);
bool InjectDLL(DWORD pID);
void UI();


int main()
{
    
eigen::central("----------DLL INJECTOR---------");
    
cout << endl;
    
eigen::central("by Tomsen1410");
    
cout << endl;
    
eigen::central("-------------------------------");
    
cout << endl;
    
cout << endl;
    
    
cout << "Type in process name: ";
    
cin >> sProcName;
    
ProcName = new char[sProcName.length()];
    
strcpy(ProcNamesProcName.c_str());
    
    
cout << endl;
    
cout << "Type in the DLL name: ";
    
cin >> sDLLName;
    
DLLName = new char[sDLLName.length()];
    
strcpy(DLLNamesDLLName.c_str());
    
    
sDLLStatus "-";
    
sProcessStatus "-";
    
UI();
    while(!
InjectSuccess){
    
        if(
GetAsyncKeyState(VK_F1))
        {    
            
hasProcID getProcID(ProcName,ProcID);
            
InjectSuccess InjectDLL(ProcID);
            if(
InjectSuccess){sEndStatus "";sCusInjectStatus "";}
            
UI();
            
Sleep(100);
        }
        if(
GetAsyncKeyState(VK_F2))
        {    
            return 
0;
        }
    }
    
Beep(1600,200);
    
UI();
    
cout << endl << endl;
    
cout << "---INJECTED---"<<endl;
    for(
int i=5;i>0;i--){
        
cout << "Closing in " << << endl;
        
Sleep(1000);
    }

    
    return 
0;
}

bool getProcID(charcPName,DWORD &idAdd){

    
bool isHere;
    
PROCESSENTRY32 pe32;
    
HANDLE hSnapShot;

    
hSnapShot CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS0);
    if(
hSnapShot == INVALID_HANDLE_VALUE){return false;}
    
pe32.dwSize sizeof(PROCESSENTRY32);

    
isHere Process32First(hSnapShot,&pe32);

    while(
isHere){

        if(
strcmp(cPName,pe32.szExeFile) == 0){
            
idAdd pe32.th32ProcessID;
            
CloseHandle(hSnapShot);
            
sProcessStatus "--Fine--";
            return 
true;}
        
isHere Process32Next(hSnapShot,&pe32);
        
pe32.dwSize sizeof(PROCESSENTRY32);
    }
    
CloseHandle(hSnapShot);
    
sProcessStatus "Process not found!";


    return 
false;
}

bool InjectDLL(DWORD pID){

   
//check if DLL exists
    
ifstream fDLL(DLLName);
    if(!
fDLL){

            
sDLLStatus "File not found!";
            return 
false;}
    
   
HANDLE Proc;
   
char buf[50]={0};
   
LPVOID RemoteStringLoadLibAddy;

   
Proc OpenProcess(CREATE_THREAD_ACCESSFALSEpID);

   if(!
Proc)
   {    
      return 
false;
   }

   
LoadLibAddy = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
   
RemoteString = (LPVOID)VirtualAllocEx(ProcNULLstrlen(DLLName), MEM_RESERVE|MEM_COMMITPAGE_READWRITE);
   
   
WriteProcessMemory(Proc, (LPVOID)RemoteStringDLLNamestrlen(DLLName), NULL);
   
   
CreateRemoteThread(ProcNULLNULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, (LPVOID)RemoteStringNULLNULL);   
   
sDLLStatus "--Fine--";
   
CloseHandle(Proc);   
   return 
true;
}

//
void UI(){

    
system("CLS");
    
eigen::central("----------DLL INJECTOR---------");
    
cout << endl;
    
eigen::central("by Tomsen1410");
    
cout << endl;
    
eigen::central("-------------------------------");
    
cout << endl;
    
cout << endl;
    
cout << endl;
    
cout << sCusInjectStatus << endl;
    
cout << sEndStatus << endl << endl;
    
cout << "Process Status: " << sProcessStatus << endl;
    
cout << "DLL Status    : " << sDLLStatus << endl;


And here is the custom header(was jsut for testing) with a custom function to central the text in the console:
PHP Code:
#include <iostream>
#include <string>
#include <fstream>

using namespace std;
namespace 
eigen{
void central(string s){
        
int num 0;
        
int len s.size();
        if(
len 80){
            
num int(len/80);}
        
        
int tmp len;
        
int cur 0;
        
        for(
int i 0<= numi++){

            
            if(
tmp >= 80){
                for(
int q 080;q++){
                    
cur++;
                    
cout << s[q];}
                
tmp -= 80;}

            else{
                
int strt int(40 tmp/2);
                for(
int w 0strtw++){
                    
cout << " ";}
                for(
curcur <= len-1cur++){
                    
cout << s[cur];}
            }
        }
    }


Now have fun Narwhal
Source ? Big Grin
Gonna upload the source tomorrow with tutorial hehe
would be cool if @OrangePL could add this in his 'project'
lolk will try to make one when I have time


good job @Tomsen1410
+rep
Thx @all...
gonna upload the source when im on ma PC..
and btw @d0h! what does "WURST POWER " mean?

looks like sausage power in german :>
Source attached! Awesome
and updated the exe, cause i accidently attached the debug version