Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
callbacks.h File Reference
#include "structs.h"
#include <ntddk.h>
#include <wdf.h>

Go to the source code of this file.

Classes

struct  _INJECT_SHELL
 

Macros

#define MAX_PATH   256
 

Typedefs

typedef struct _INJECT_SHELL INJECT_SHELL
 
typedef struct _INJECT_SHELLPINJECT_SHELL
 

Functions

PVOID NTAPI RtlImageDirectoryEntryToData (_In_ PVOID BaseOfImage, _In_ BOOLEAN MappedAsImage, _In_ USHORT DirectoryEntry, _Out_ PULONG Size)
 
BOOLEAN NTAPI KeTestAlertThread (IN KPROCESSOR_MODE AlertMode)
 
BOOLEAN NTAPI PsIsProtectedProcess (_In_ PEPROCESS Process)
 
EXTERN_C PVOID RtlImageDirectoryEntryToData (IN PVOID Base, IN BOOLEAN MappedAsImage, IN USHORT DirectoryEntry, OUT PULONG Size)
 
VOID RemoveCallbacks ()
 
NTSTATUS InitializeKernelCallbacks ()
 

Variables

POBJECT_TYPE * IoDeviceObjectType
 

Macro Definition Documentation

◆ MAX_PATH

#define MAX_PATH   256

Definition at line 6 of file callbacks.h.

Typedef Documentation

◆ INJECT_SHELL

typedef struct _INJECT_SHELL INJECT_SHELL

◆ PINJECT_SHELL

typedef struct _INJECT_SHELL * PINJECT_SHELL

Function Documentation

◆ InitializeKernelCallbacks()

NTSTATUS InitializeKernelCallbacks ( )

Definition at line 558 of file callbacks.cpp.

559{
560 PAGED_CODE();
561 NTSTATUS status;
562 //UNICODE_STRING callbackAltitude;
564 //RtlInitUnicodeString(&callbackAltitude, L"1931");
565
566 //OB_CALLBACK_REGISTRATION callbackRegistration;
567 //OB_OPERATION_REGISTRATION operationRegistration;
568 //RtlSecureZeroMemory(&operationRegistration, sizeof(OB_OPERATION_REGISTRATION));
569 //RtlSecureZeroMemory(&callbackRegistration, sizeof(OB_CALLBACK_REGISTRATION));
570 //operationRegistration.ObjectType = PsProcessType;
571 //operationRegistration.Operations = OB_OPERATION_HANDLE_CREATE | OB_OPERATION_HANDLE_DUPLICATE;
572 //operationRegistration.PreOperation = PreOperationCallback;
574 //operationRegistration.PostOperation = NULL;
575
576 //callbackRegistration.Version = OB_FLT_REGISTRATION_VERSION;
577 //callbackRegistration.OperationRegistrationCount = 1;
578 //callbackRegistration.Altitude = callbackAltitude;
579 //callbackRegistration.OperationRegistration = &operationRegistration;
580 //callbackRegistration.RegistrationContext = NULL;
581
582 //status = ObRegisterCallbacks(&callbackRegistration, &g_ObRegistrationHandle);
583 //if (!NT_SUCCESS(status)) {
584 // DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: Driver Failed to Set Object Registration Callbacks - Ensure /INTEGRITYCHECK is added to the linker options\n");
585 // return status;
586 //}
587 //DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[+] Panoptes: Set Object Registration Callbacks\n");
588
589 InitializeListHead(&g_ProcessList);
590 //KeInitializeSpinLock(&g_ProcessListLock);
591 status = PsSetCreateProcessNotifyRoutineEx(ProcessCreateCallback, FALSE);
592 if (!NT_SUCCESS(status)) {
593 //ObUnRegisterCallbacks(g_ObRegistrationHandle);
594 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: Driver Failed to Set Process Creation Notify Routine Notify Routine - Ensure /INTEGRITYCHECK is added to the linker options\n");
595 return status;
596 }
597 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[+] Panoptes: Set Process Creation Notify Callbacks\n");
598
599 status = PsSetLoadImageNotifyRoutine(LoadImageNotifyRoutine);
600 if (!NT_SUCCESS(status)) {
601 NTSTATUS removeStatus = PsSetCreateProcessNotifyRoutineEx(ProcessCreateCallback, TRUE);
602 if (!NT_SUCCESS(removeStatus)) {
603 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: Driver Failed to remove callback for Set Process Creation Notify Routine Notify Routine\n");
604 return removeStatus;
605 }
606 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: Driver Failed to Set Process Load Image Notify Routine - Ensure /INTEGRITYCHECK is added to the linker options\n");
607 return status;
608 }
609 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[+] Panoptes: Set Image Load Notify Callbacks\n");
610
611 return STATUS_SUCCESS;
612}
VOID LoadImageNotifyRoutine(PUNICODE_STRING FullImageName, HANDLE ProcessId, PIMAGE_INFO ImageInfo)
LIST_ENTRY g_ProcessList
Definition callbacks.cpp:8
VOID ProcessCreateCallback(PEPROCESS Process, HANDLE ProcessId, PPS_CREATE_NOTIFY_INFO CreateInfo)

References g_ProcessList, LoadImageNotifyRoutine(), and ProcessCreateCallback().

Referenced by DriverEntry().

◆ KeTestAlertThread()

BOOLEAN NTAPI KeTestAlertThread ( IN KPROCESSOR_MODE  AlertMode)

Referenced by InjectDllKernelApc().

◆ PsIsProtectedProcess()

BOOLEAN NTAPI PsIsProtectedProcess ( _In_ PEPROCESS  Process)

Referenced by LoadImageNotifyRoutine().

◆ RemoveCallbacks()

VOID RemoveCallbacks ( )

Definition at line 614 of file callbacks.cpp.

614 {
615 //ObUnRegisterCallbacks(g_ObRegistrationHandle);
616 PsSetCreateProcessNotifyRoutineEx(ProcessCreateCallback, TRUE);
617 PsRemoveLoadImageNotifyRoutine(LoadImageNotifyRoutine);
618 return;
619}

References LoadImageNotifyRoutine(), and ProcessCreateCallback().

Referenced by UnloadPanoptes().

◆ RtlImageDirectoryEntryToData() [1/2]

PVOID NTAPI RtlImageDirectoryEntryToData ( _In_ PVOID  BaseOfImage,
_In_ BOOLEAN  MappedAsImage,
_In_ USHORT  DirectoryEntry,
_Out_ PULONG  Size 
)

◆ RtlImageDirectoryEntryToData() [2/2]

EXTERN_C PVOID RtlImageDirectoryEntryToData ( IN PVOID  Base,
IN BOOLEAN  MappedAsImage,
IN USHORT  DirectoryEntry,
OUT PULONG  Size 
)

Variable Documentation

◆ IoDeviceObjectType

POBJECT_TYPE* IoDeviceObjectType

Definition at line 38 of file callbacks.h.