Вопрос Хочу создать собственный лоадер/инжектор.

Начинающий
Статус
Оффлайн
Регистрация
17 Мар 2021
Сообщения
10
Реакции[?]
0
Поинты[?]
0
Хочу создать собственный лоадер/инжектор на C++ без защиты, без меню(в консоли), просто чтобы он брал длл из папки в которой находится он сам. Сначала Он ищет в совпадение между названием dll записанных в него и dll в папке(то есть их несколько. если инжектор в папке с fatality.dll он будет лоадить фаталити, если с primordial.dll то примордиал и так далее) и выводит название инъектируемого чита. Дальше он открывает steam.exe(если не открыт) и ищет в папке steam.dll. Если не находит то чтобы продолжить нужно написать подтверждающую команду типа 1 или Y, и он продолжает без взаимодействия со steam.exe. Если там написано что угодно кроме этой команды он выводит что инъекция отменена и через 5 секунд закрывается. Если steam.dll найден он инжектит steam.dll в steam.exe, выводит успешна или не успешна инъекция, и ждёт открытия ксго(проверяет наличие программы csgo.exe каждые 5 секунд). Когда ксго открыта он инжектит "названиечита".dll в csgo.exe, выводит успешна или не успешна инъекция, и через 5 секунд закрывается. Надеюсь написал свою задумку ясно. В програимированнии на C++ я абсолютный 0, так что попрошу разжевывать мне всё как младенцу кашку. Такая идея пришла мне в голову когда я пригласил своего друга поиграть на хвх, дал ему чит, инжектор, кфг, луашки, ну в общем всё, а он не понимал ни одного моего слова ещё на этапе инъекции чита.
 
get good get legendware
Участник
Статус
Оффлайн
Регистрация
22 Сен 2020
Сообщения
444
Реакции[?]
202
Поинты[?]
49K
Load library injector:
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
#include <string>
#include <filesystem>
#include <thread>

namespace fs = std::filesystem;

// Function to get the process ID by process name
DWORD GetProcessIdByName(const std::string& processName) {
    PROCESSENTRY32 processEntry = { sizeof(PROCESSENTRY32) };
    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    if (snapshot == INVALID_HANDLE_VALUE) {
        return 0;
    }

    DWORD processId = 0;
    if (Process32First(snapshot, &processEntry)) {
        do {
            if (processName == processEntry.szExeFile) {
                processId = processEntry.th32ProcessID;
                break;
            }
        } while (Process32Next(snapshot, &processEntry));
    }

    CloseHandle(snapshot);
    return processId;
}

// Function to inject DLL
bool InjectDLL(DWORD processId, const std::string& dllPath) {
    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
    if (!hProcess) {
        std::cerr << "Failed to open target process." << std::endl;
        return false;
    }

    void* pAlloc = VirtualAllocEx(hProcess, nullptr, dllPath.size() + 1, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
    if (!pAlloc) {
        std::cerr << "Failed to allocate memory in target process." << std::endl;
        CloseHandle(hProcess);
        return false;
    }

    if (!WriteProcessMemory(hProcess, pAlloc, dllPath.c_str(), dllPath.size() + 1, nullptr)) {
        std::cerr << "Failed to write to target process memory." << std::endl;
        VirtualFreeEx(hProcess, pAlloc, 0, MEM_RELEASE);
        CloseHandle(hProcess);
        return false;
    }

    HMODULE hKernel32 = GetModuleHandle("kernel32.dll");
    if (!hKernel32) {
        std::cerr << "Failed to get handle to kernel32.dll." << std::endl;
        VirtualFreeEx(hProcess, pAlloc, 0, MEM_RELEASE);
        CloseHandle(hProcess);
        return false;
    }

    HANDLE hThread = CreateRemoteThread(hProcess, nullptr, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32, "LoadLibraryA"), pAlloc, 0, nullptr);
    if (!hThread) {
        std::cerr << "Failed to create remote thread in target process." << std::endl;
        VirtualFreeEx(hProcess, pAlloc, 0, MEM_RELEASE);
        CloseHandle(hProcess);
        return false;
    }

    WaitForSingleObject(hThread, INFINITE);
    CloseHandle(hThread);
    VirtualFreeEx(hProcess, pAlloc, 0, MEM_RELEASE);
    CloseHandle(hProcess);

    return true;
}

// Main function
int main() {
    std::string dllName;
    std::string dllPath;

    // Find the DLL in the current folder
    for (const auto& entry : fs::directory_iterator(fs::current_path())) {
        if (entry.path().extension() == ".dll") {
            dllName = entry.path().filename().string();
            dllPath = entry.path().string();
            break;
        }
    }

    if (dllName.empty()) {
        std::cerr << "No DLL found in the current folder." << std::endl;
        return 1;
    }

    std::cout << "Found DLL: " << dllName << std::endl;

    DWORD steamProcessId = GetProcessIdByName("steam.exe");
    if (steamProcessId == 0) {
        std::cout << "steam.exe is not running. Continue without Steam? (1/Y to continue, anything else to cancel): ";
        std::string response;
        std::cin >> response;

        if (response != "1" && response != "Y" && response != "y") {
            std::cout << "Injection canceled. Exiting..." << std::endl;
            std::this_thread::sleep_for(std::chrono::seconds(5));
            return 0;
        }
    } else {
        std::string steamDllPath;
        for (const auto& entry : fs::directory_iterator(fs::current_path())) {
            if (entry.path().filename() == "steam.dll") {
                steamDllPath = entry.path().string();
                break;
            }
        }

        if (!steamDllPath.empty()) {
            std::cout << "Injecting steam.dll into steam.exe..." << std::endl;
            if (InjectDLL(steamProcessId, steamDllPath)) {
                std::cout << "Successfully injected steam.dll into steam.exe." << std::endl;
            } else {
                std::cerr << "Failed to inject steam.dll into steam.exe." << std::endl;
            }
        } else {
            std::cout << "steam.dll not found. Continue without Steam injection? (1/Y to continue, anything else to cancel): ";
            std::string response;
            std::cin >> response;

            if (response != "1" && response != "Y" && response != "y") {
                std::cout << "Injection canceled. Exiting..." << std::endl;
                std::this_thread::sleep_for(std::chrono::seconds(5));
                return 0;
            }
        }
    }

    std::cout << "Waiting for csgo.exe to open..." << std::endl;
    DWORD csgoProcessId = 0;
    while ((csgoProcessId = GetProcessIdByName("csgo.exe")) == 0) {
        std::this_thread::sleep_for(std::chrono::seconds(5));
    }

    std::cout << "Injecting " << dllName << " into csgo.exe..." << std::endl;
    if (InjectDLL(csgoProcessId, dllPath)) {
        std::cout << "Successfully injected " << dllName << " into csgo.exe." << std::endl;
    } else {
        std::cerr << "Failed to inject " << dllName << " into csgo.exe." << std::endl;
    }

    std::this_thread::sleep_for(std::chrono::seconds(5));
    return 0;
}
 
Сверху Снизу