我在做标题上说的话有点困难.我制作了一个用于x86到x86和x64到x64的注入器,但是从x64注入x86 (使用x86 dll)并不适用于该代码:
#include <Windows.h>
#include <string>
bool InjectDll(DWORD processId, std::string dllPath)
{
HANDLE hThread, hProcess;
void* pLibRemote = 0; // the address (in the remote process) where
// szLibPath will be copied to;
HMODULE hKernel32 = GetModuleHandle("Kernel32");
char DllFullPathName[_MAX_PATH];
GetFullPathName(dllPath.c_str(), _MAX_PATH, DllFullPathName, NULL);
// Get process handle
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
// copy file path in szLibPath
char szLibPath[_MAX_PATH];
strcpy_s(szLibPath, DllFullPathName);
// 1. Allocate memory in the remote process for szLibPath
pLibRemote = VirtualAllocEx(hProcess, NULL, sizeof(szLibPath),
MEM_COMMIT, PAGE_READWRITE);
if (pLibRemote == NULL)
return false;
// 2. Write szLibPath to the allocated memory
WriteProcessMemory(hProcess, pLibRemote, (void*)szLibPath,
sizeof(szLibPath), NULL);
// 3. Force remote process to load dll
LPTHREAD_START_ROUTINE thread;
thread = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32,"LoadLibraryA");
hThread = CreateRemoteThread(hProcess, NULL, 0, thread, pLibRemote,
0, NULL);
if (hThread == NULL)
return false;
return true;
}该函数在每个场景中都返回true (甚至从注入32位进程的64位注入器返回),但是它实际上无法注入dll。
顺便说一句,在我的研究中,我发现了这些问题:
x86 Code Injection into an x86 Process from a x64 Process
C++: Injecting 32 bit targets from 64 bit process
但虽然答案解释了怎么做,但我并没有真正做到.所以也许我只需要一个代码片段就能把我送上正确的道路?
发布于 2015-04-15 15:31:32
更改这一行:
thread = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32,"LoadLibraryA");这一行:
thread = (LPTHREAD_START_ROUTINE)system("loadLibrary_x86_address.exe");"loadLibrary_x86_address.exe“是一个32位应用程序,定义为:
#include <Windows.h>
int main()
{
return (int)LoadLibraryA;
}行得通!这是一种黑客行为,但它能起作用。
https://stackoverflow.com/questions/29652839
复制相似问题