![]() |
Panoptes 1.0.0
Endpoint Detection and Response
|
#include <Windows.h>#include <winternl.h>Go to the source code of this file.
Macros | |
| #define | HOOK_PROVIDER_NAME "Panoptes.Hook" |
| #define | HOOK_KEYWORD_DETECTION 0x1 |
Functions | |
| VOID | HookTraceInit () |
| Registers the provider. Call before placing the hooks. | |
| VOID | HookTraceUninit () |
| Unregisters the provider. Call after removing the hooks. | |
| BOOL | HookLoggingEnabled () |
| Whether the Log_* functions should write. FALSE on the thread running a Detours transaction (so the hooks do not report Detours patching ntdll), and while a second instance of this DLL loaded in the process does the logging instead. Defined in hook.cpp. | |
| VOID | Log_PEWritten (HANDLE ProcessHandle, BOOL CurrentProcess, PVOID BaseAddress, BOOL Executable) |
| NtWriteVirtualMemory wrote a PE image. Event "PEWritten". | |
| VOID | Log_PEBWritten (HANDLE ProcessHandle, BOOL CurrentProcess, SIZE_T Size, ULONG_PTR PebOffset) |
| NtWriteVirtualMemory wrote to a process's PEB. Event "PEBWritten". | |
| VOID | Log_EntryPointWritten (HANDLE ProcessHandle, BOOL CurrentProcess, PVOID BaseAddress, SIZE_T Size, PVOID EntryPoint, BOOL CodeWritten, BOOL FieldWritten) |
| NtWriteVirtualMemory wrote over the entry point of a process's main image (the image PEB.ImageBaseAddress points at): the first byte of the entry point code, the AddressOfEntryPoint field of its headers, or both. Event "EntryPointWritten". | |
| VOID | Log_PEBRead (HANDLE ProcessHandle, BOOL CurrentProcess, SIZE_T Size, ULONG_PTR PebOffset) |
| NtReadVirtualMemory read from a process's PEB. Event "PEBRead". | |
| VOID | Log_ProtectionSetAttempt (HANDLE ProcessHandle, BOOL CurrentProcess, NTSTATUS Status) |
| NtSetInformationProcess was called to set a process's protection level (ProcessProtectionInformation). Only the kernel may do this, so the call is expected to fail; the attempt itself is the signal. Event "ProtectionSetAttempt". | |
| VOID | Log_ApcQueued (HANDLE ThreadHandle, BOOL CurrentProcess, const char *Api, PVOID ApcRoutine, ULONG ApcFlags) |
| NtQueueApcThread or NtQueueApcThreadEx2 queued an APC to a thread. Event "ApcQueued". TargetProcessId is the process that owns the thread; the event also carries TargetThreadId. Both are 0 when the handle lacks THREAD_QUERY_LIMITED_INFORMATION; the thread is still known to be remote, because local threads are matched by object rather than by ID. | |
| VOID | Log_RemoteThreadCreated (HANDLE ProcessHandle, PVOID StartRoutine, ULONG CreateFlags) |
| NtCreateThreadEx created a thread in another process. Event "RemoteThreadCreated". | |
| VOID | Log_ExecutableAllocated (HANDLE ProcessHandle, BOOL CurrentProcess, const char *Api, PVOID BaseAddress, SIZE_T RegionSize, ULONG AllocationType, ULONG Protection) |
| NtAllocateVirtualMemory or NtAllocateVirtualMemoryEx allocated executable memory. Event "ExecutableAllocated". | |
| VOID | Log_ExecutableUnmapped (HANDLE ProcessHandle, BOOL CurrentProcess, const char *Api, PVOID BaseAddress, BOOL IsImage) |
| NtUnmapViewOfSection or NtUnmapViewOfSectionEx unmapped a view with executable pages. Unmapping an image from another process is the first step of process hollowing. Event "ExecutableUnmapped". | |
| VOID | Log_RemoteViewMapped (HANDLE ProcessHandle, const char *Api, PVOID BaseAddress, SIZE_T ViewSize, ULONG Protection, BOOL Executable, BOOL IsImage) |
| NtMapViewOfSection or NtMapViewOfSectionEx mapped a view into another process. Mapping a shared section into a target is a way to inject code without NtWriteVirtualMemory. Event "RemoteViewMapped". | |
| VOID | Log_PEMadeExecutable (HANDLE ProcessHandle, BOOL CurrentProcess, PVOID BaseAddress, ULONG OldProtection, ULONG NewProtection) |
| NtProtectVirtualMemory made a region starting with a PE image executable. Event "PEMadeExecutable". | |
| #define HOOK_KEYWORD_DETECTION 0x1 |
Definition at line 23 of file hook_trace.hpp.
Referenced by Log_ApcQueued(), Log_EntryPointWritten(), Log_ExecutableAllocated(), Log_ExecutableUnmapped(), Log_PEBRead(), Log_PEBWritten(), Log_PEMadeExecutable(), Log_PEWritten(), Log_ProtectionSetAttempt(), Log_RemoteThreadCreated(), Log_RemoteViewMapped(), and StartHookEvents().
| #define HOOK_PROVIDER_NAME "Panoptes.Hook" |
Definition at line 21 of file hook_trace.hpp.
Referenced by TRACELOGGING_DEFINE_PROVIDER().
| BOOL HookLoggingEnabled | ( | ) |
Whether the Log_* functions should write. FALSE on the thread running a Detours transaction (so the hooks do not report Detours patching ntdll), and while a second instance of this DLL loaded in the process does the logging instead. Defined in hook.cpp.
Definition at line 860 of file hook.cpp.
Referenced by Log_ApcQueued(), Log_EntryPointWritten(), Log_ExecutableAllocated(), Log_ExecutableUnmapped(), Log_PEBRead(), Log_PEBWritten(), Log_PEMadeExecutable(), Log_PEWritten(), Log_ProtectionSetAttempt(), Log_RemoteThreadCreated(), and Log_RemoteViewMapped().
| VOID HookTraceInit | ( | ) |
Registers the provider. Call before placing the hooks.
Definition at line 13 of file hook_trace.cpp.
Referenced by DllMain().
| VOID HookTraceUninit | ( | ) |
Unregisters the provider. Call after removing the hooks.
Definition at line 18 of file hook_trace.cpp.
Referenced by DllMain().
| VOID Log_ApcQueued | ( | HANDLE | ThreadHandle, |
| BOOL | CurrentProcess, | ||
| const char * | Api, | ||
| PVOID | ApcRoutine, | ||
| ULONG | ApcFlags ) |
NtQueueApcThread or NtQueueApcThreadEx2 queued an APC to a thread. Event "ApcQueued". TargetProcessId is the process that owns the thread; the event also carries TargetThreadId. Both are 0 when the handle lacks THREAD_QUERY_LIMITED_INFORMATION; the thread is still known to be remote, because local threads are matched by object rather than by ID.
| ThreadHandle | The thread the APC was queued to. |
| CurrentProcess | Whether the thread is in the current process. |
| Api | The name of the hooked function. |
| ApcRoutine | The routine the APC runs. |
| ApcFlags | The QUEUE_USER_APC_FLAGS_* values (0x1 for a special user APC, which runs without the thread entering an alertable wait); always 0 for NtQueueApcThread. |
Definition at line 202 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtQueueApcThread(), and Hooked_NtQueueApcThreadEx2().
| VOID Log_EntryPointWritten | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| PVOID | BaseAddress, | ||
| SIZE_T | Size, | ||
| PVOID | EntryPoint, | ||
| BOOL | CodeWritten, | ||
| BOOL | FieldWritten ) |
NtWriteVirtualMemory wrote over the entry point of a process's main image (the image PEB.ImageBaseAddress points at): the first byte of the entry point code, the AddressOfEntryPoint field of its headers, or both. Event "EntryPointWritten".
| ProcessHandle | The process written to. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| BaseAddress | Where the write started. |
| Size | The number of bytes written. |
| EntryPoint | The entry point address after the write, or NULL if AddressOfEntryPoint is 0. |
| CodeWritten | Whether the write covered the entry point code. |
| FieldWritten | Whether the write covered the AddressOfEntryPoint field. |
Definition at line 135 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtWriteVirtualMemory().
| VOID Log_ExecutableAllocated | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| const char * | Api, | ||
| PVOID | BaseAddress, | ||
| SIZE_T | RegionSize, | ||
| ULONG | AllocationType, | ||
| ULONG | Protection ) |
NtAllocateVirtualMemory or NtAllocateVirtualMemoryEx allocated executable memory. Event "ExecutableAllocated".
| ProcessHandle | The process the memory was allocated in. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| Api | The name of the hooked function. |
| BaseAddress | The base of the allocation, as returned by the kernel. |
| RegionSize | The size of the allocation, rounded up to whole pages. |
| AllocationType | The MEM_* allocation flags. |
| Protection | The PAGE_* protection. |
Definition at line 247 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtAllocateVirtualMemory(), and Hooked_NtAllocateVirtualMemoryEx().
| VOID Log_ExecutableUnmapped | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| const char * | Api, | ||
| PVOID | BaseAddress, | ||
| BOOL | IsImage ) |
NtUnmapViewOfSection or NtUnmapViewOfSectionEx unmapped a view with executable pages. Unmapping an image from another process is the first step of process hollowing. Event "ExecutableUnmapped".
| ProcessHandle | The process the view was unmapped from. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| Api | The name of the hooked function. |
| BaseAddress | The address passed to the unmap call. |
| IsImage | Whether the view was a mapped image (MEM_IMAGE). Logged as "IsImage", since the service fills in "Image" with the process's image path. |
Definition at line 270 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtUnmapViewOfSection(), and Hooked_NtUnmapViewOfSectionEx().
| VOID Log_PEBRead | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| SIZE_T | Size, | ||
| ULONG_PTR | PebOffset ) |
NtReadVirtualMemory read from a process's PEB. Event "PEBRead".
| ProcessHandle | The process read from. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| Size | The number of bytes read. |
| PebOffset | The offset of the read from the start of the PEB. |
Definition at line 161 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtReadVirtualMemory().
| VOID Log_PEBWritten | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| SIZE_T | Size, | ||
| ULONG_PTR | PebOffset ) |
NtWriteVirtualMemory wrote to a process's PEB. Event "PEBWritten".
| ProcessHandle | The process written to. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| Size | The number of bytes written. |
| PebOffset | The offset of the write from the start of the PEB. |
Definition at line 115 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtWriteVirtualMemory().
| VOID Log_PEMadeExecutable | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| PVOID | BaseAddress, | ||
| ULONG | OldProtection, | ||
| ULONG | NewProtection ) |
NtProtectVirtualMemory made a region starting with a PE image executable. Event "PEMadeExecutable".
| ProcessHandle | The process whose memory was reprotected. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| BaseAddress | The start of the region. |
| OldProtection | The previous protection, or 0 if the caller did not ask for it. |
| NewProtection | The new protection. |
Definition at line 316 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtProtectVirtualMemory().
| VOID Log_PEWritten | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| PVOID | BaseAddress, | ||
| BOOL | Executable ) |
NtWriteVirtualMemory wrote a PE image. Event "PEWritten".
| ProcessHandle | The process written to. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| BaseAddress | Where the image was written. |
| Executable | Whether the destination memory is executable. |
Definition at line 95 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtWriteVirtualMemory().
| VOID Log_ProtectionSetAttempt | ( | HANDLE | ProcessHandle, |
| BOOL | CurrentProcess, | ||
| NTSTATUS | Status ) |
NtSetInformationProcess was called to set a process's protection level (ProcessProtectionInformation). Only the kernel may do this, so the call is expected to fail; the attempt itself is the signal. Event "ProtectionSetAttempt".
| ProcessHandle | The process whose protection was to be set. |
| CurrentProcess | Whether ProcessHandle is the current process. |
| Status | The NTSTATUS the call returned. |
Definition at line 183 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtSetInformationProcess().
| VOID Log_RemoteThreadCreated | ( | HANDLE | ProcessHandle, |
| PVOID | StartRoutine, | ||
| ULONG | CreateFlags ) |
NtCreateThreadEx created a thread in another process. Event "RemoteThreadCreated".
| ProcessHandle | The process the thread was created in. |
| StartRoutine | The address the thread starts executing at. |
| CreateFlags | The THREAD_CREATE_FLAGS_* values, e.g. 0x1 for a suspended thread. |
Definition at line 227 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtCreateThreadEx().
| VOID Log_RemoteViewMapped | ( | HANDLE | ProcessHandle, |
| const char * | Api, | ||
| PVOID | BaseAddress, | ||
| SIZE_T | ViewSize, | ||
| ULONG | Protection, | ||
| BOOL | Executable, | ||
| BOOL | IsImage ) |
NtMapViewOfSection or NtMapViewOfSectionEx mapped a view into another process. Mapping a shared section into a target is a way to inject code without NtWriteVirtualMemory. Event "RemoteViewMapped".
| ProcessHandle | The process the view was mapped into. |
| Api | The name of the hooked function. |
| BaseAddress | The base of the view, as returned by the kernel. |
| ViewSize | The size of the view, as returned by the kernel. |
| Protection | The protection the caller requested. |
| Executable | Whether any committed page of the view is executable. |
| IsImage | Whether the view is a mapped image (MEM_IMAGE). Logged as "IsImage". |
Definition at line 291 of file hook_trace.cpp.
References HOOK_KEYWORD_DETECTION, and HookLoggingEnabled().
Referenced by Hooked_NtMapViewOfSection(), and Hooked_NtMapViewOfSectionEx().