02-10-2012, 00:07
(This post was last modified: 02-10-2012, 16:51 by Tomsen1410.)
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:
And here is the custom header(was jsut for testing) with a custom function to central the text in the console:
Now have fun
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;
char* DLLName = NULL;
char* ProcName = NULL;
string sEndStatus = "Press [F2] to quit";
string sCusInjectStatus = "Press [F1] to inject DLL";
bool getProcID(char* cPName,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(ProcName, sProcName.c_str());
cout << endl;
cout << "Type in the DLL name: ";
cin >> sDLLName;
DLLName = new char[sDLLName.length()];
strcpy(DLLName, sDLLName.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 " << i << endl;
Sleep(1000);
}
return 0;
}
bool getProcID(char* cPName,DWORD &idAdd){
bool isHere;
PROCESSENTRY32 pe32;
HANDLE hSnapShot;
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
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 RemoteString, LoadLibAddy;
Proc = OpenProcess(CREATE_THREAD_ACCESS, FALSE, pID);
if(!Proc)
{
return false;
}
LoadLibAddy = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
RemoteString = (LPVOID)VirtualAllocEx(Proc, NULL, strlen(DLLName), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(Proc, (LPVOID)RemoteString, DLLName, strlen(DLLName), NULL);
CreateRemoteThread(Proc, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, (LPVOID)RemoteString, NULL, NULL);
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; i <= num; i++){
if(tmp >= 80){
for(int q = 0; q < 80;q++){
cur++;
cout << s[q];}
tmp -= 80;}
else{
int strt = int(40 - tmp/2);
for(int w = 0; w < strt; w++){
cout << " ";}
for(cur; cur <= len-1; cur++){
cout << s[cur];}
}
}
}
}
Now have fun