c++ - LoadLibrary Dll 注入器获取路径输入并“加扰”
问题描述
我已经使用 MinGW 32 位编译器在 QT Creator 中创建了一个 GUI DLL 注入器,并不断遇到这个反复出现的问题,我将单击注入,它不会注入 DLL,但它会扰乱我的 DLL 路径。
示例:示例屏幕截图
- 第一个路径是转换正确类型后的DLL
- Last DLL是进程后的DLL
- 地址就是DLL在目标进程中所在的地址
- 0 是 GetLastError()
代码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
}
}
}
我没有尝试过很多解决方案,只有几种不同的转换技术,但它们没有改变任何东西,知道是什么导致了这种奇怪的输出吗?
提前致谢。
编辑:以为我已经修复了它,但它似乎完全随机发生,有时它起作用,有时它并没有真正混淆。
解决方案
推荐阅读
- excel - MS Excel 公式:使用范围列表从文本中查找和删除多个匹配项
- python - Python 链式属性访问中的无传播
- c# - Process.OutputDataReceived 未触发
- android - 在 React Native 中使用 axios 时出现网络错误
- powershell - 我在 OSD 的 WinPE 阶段提示用户输入计算机名称
- python - 从平面像素列表中制作排名 4 的 numpy 数组以在 Keras 的 ImageDataGenerator 中使用,然后在 matplotlib 中使用
- ruby - Ruby/Rvm sudo 安装在 Linux 桌面上,终端没有在 PATH 中获取 Ruby 工具
- java - 如何访问从方法传递的数组以便在主方法中重新排列它
- sql - 将总和与总存储空间进行比较
- c# - 根据数据库C#中的另一个组合框填充组合框