:) Has Windows 10 adopted techniques against DLL injection? I am injecting into a user process like notepad but the dll is not started. I see that the thread is created by the return of createRemoteThread but does not open the selected dll (messageBox). I'm in windows 10 64Bit but I'm compiling both dll and injector in 32 bit. Thanks very much !! :) :)
Here the code: Dll File
*****************************************************************
#include <Windows.h>
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
MessageBox(0, L"Hello From testlib!", L"Hello", MB_ICONINFORMATION);
return TRUE;
}
*************************************************************
#include <iostream>
#include <Windows.h>
int main()
{
// path to our dll
LPCSTR DllPath = "D:\\projects\\standardinjection\\release\\testlib.dll";
// Open a handle to target process
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 17344);
// Allocate memory for the dllpath in the target process
// length of the path string + null terminator
LPVOID pDllPath = VirtualAllocEx(hProcess, 0, strlen(DllPath) + 1,
MEM_COMMIT, PAGE_READWRITE);
// Write the path to the address of the memory we just allocated
// in the target process
WriteProcessMemory(hProcess, pDllPath, (LPVOID)DllPath,
strlen(DllPath) + 1, 0);
// Create a Remote Thread in the target process which
// calls LoadLibraryA as our dllpath as an argument -> program loads our dll
HANDLE hLoadThread = CreateRemoteThread(hProcess, 0, 0,
(LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("Kernel32.dll"),
"LoadLibraryA"), pDllPath, 0, 0);
// Wait for the execution of our loader thread to finish
WaitForSingleObject(hLoadThread, INFINITE);
std::cout << "Dll path allocated at: " << std::hex << pDllPath << std::endl;
std::cin.get();
// Free the memory allocated for our dll path
VirtualFreeEx(hProcess, pDllPath, strlen(DllPath) + 1, MEM_RELEASE);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire