Quote:
Originally Posted by badforce788
hi guys! i have .exe(injector) and .dll projects. i want to know which injector my .dll project interacts with. i will terminate if my injector is not used. how can I do that? thanks!
|
1. Shared Secret: Have your injector write a unique value (like a hardcoded GUID or HMAC key) into a specific memory address or a named pipe before injection.
2. DLL Check: Inside your DLL’s `DllMain`, read that memory/pipe. If the value doesn’t match, `FreeLibrary` and bail.
cpp:
// Injector:
Code:
WriteProcessMemory(hTargetProc, lpRemoteAddr, &SECRET_KEY, sizeof(SECRET_KEY), NULL);
// DLL:
Code:
if (memcmp(&local_key, &SECRET_KEY, sizeof(SECRET_KEY)) != 0) {
FreeLibraryAndExitThread(hModule, 0);
}
Note: This is trivial to bypass if someone reverses your binary. For stronger protection, obfuscate/encrypt the check or use manual mapping with header decryption (as wurstbrot123 suggested).
—
P.S. StackOverflowed’s HMAC idea works too, but requires the injector to sign the DLL pre-injection (or embed a signature). Overkill unless you’re paranoid.