首页 > 解决方案 > LoadLibrary Dll 注入器获取路径输入并“加扰”

问题描述

我已经使用 MinGW 32 位编译器在 QT Creator 中创建了一个 GUI DLL 注入器,并不断遇到这个反复出现的问题,我将单击注入,它不会注入 DLL,但它会扰乱我的 DLL 路径。

示例:示例屏幕截图

代码DLL路径转换:

QString fileInput = ui->filesCmb->currentText();    //gets dll
dllPath = fileInput.toStdString().c_str();    //converts dll to string
qDebug() << dllPath << "\n";

注入过程代码:

QString methodChosen = ui->methodCmb->currentText();
QString targetProcess = ui->processTxt->text();
const wchar_t* tgtProc = (const wchar_t*)targetProcess.utf16();

if (methodChosen == "Manual Map") {
    ui->statusTxt->setPlainText("Method not added[" + methodChosen + "]");

} else if (methodChosen == "LdrLoadDLL") {
    ui->statusTxt->setPlainText("Method not added[" + methodChosen + "]");

} else {
    ui->statusTxt->setPlainText("File input: " + fileInput + "\n" + "Method: " + methodChosen + "\n" + "Target Process: " + targetProcess + "\n" + "Dll path: " + dllPath + "\n");
    DWORD pid = getPid(tgtProc);
    dwordToQstring = QString::number(pid);

    HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, NULL, pid);
    if (!pHandle || pHandle == INVALID_HANDLE_VALUE) {
        ui->statusTxt->setPlainText("Couldn't get handle[" + dwordToQstring + "]");
    }

    LPVOID pDllPath = VirtualAllocEx(pHandle, 0, strlen(dllPath) + 1, MEM_COMMIT, PAGE_READWRITE);  // allocate memeory within our target process to fit our dll


    if (pDllPath != nullptr) {
        WriteProcessMemory(pHandle, pDllPath, (LPVOID)dllPath, strlen(dllPath) + 1, 0); //writes our dll to the allocated memory
        HANDLE hLoad = CreateRemoteThread(pHandle, 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA"), pDllPath, 0, 0); //creates a thread in the target process to allow out code to run


        if (hLoad != nullptr) {
            WaitForSingleObject(hLoad, INFINITE);   //maybe waits for our dll code to execute?
            ui->statusTxt->setPlainText("File input: " + fileInput + "\n" + "Method: " + methodChosen + "\n" + "Target Process: " + targetProcess + "\n" + "PID: " + dwordToQstring + "\n" + "INJECTED");
            qDebug() << "LastDLL=>" << dllPath << "\n";
            qDebug() << &pDllPath;
            qDebug() << GetLastError();

            VirtualFreeEx(pHandle, pDllPath, strlen(dllPath) + 1, MEM_RELEASE); // free the memory allocated for out dll
         }
    }
} 

我没有尝试过很多解决方案,只有几种不同的转换技术,但它们没有改变任何东西,知道是什么导致了这种奇怪的输出吗?

提前致谢。

编辑:以为我已经修复了它,但它似乎完全随机发生,有时它起作用,有时它并没有真正混淆。

标签: c++windowsqtdlldll-injection

解决方案


推荐阅读