44 memzero(pMsrViol,
sizeof(*pMsrViol));
66 WARNING(
"[WARNING] IntNotifyIntroEvent failed: 0x%08x\n", status);
114 if (NULL == NewValue)
122 (0 == OriginalValue))
129 if (OriginalValue == *NewValue)
139 exitAfterInformation =
FALSE;
141 memzero(&originator,
sizeof(originator));
142 memzero(&victim,
sizeof(victim));
148 exitAfterInformation =
TRUE;
153 ERROR(
"[ERROR] Failed getting originator: 0x%08x\n", status);
154 exitAfterInformation =
TRUE;
161 ERROR(
"[ERROR] Failed getting zone details: 0x%08x\n", status);
162 exitAfterInformation =
TRUE;
165 if (exitAfterInformation)
180 memzero(pMsrViol,
sizeof(*pMsrViol));
208 WARNING(
"[WARNING] IntNotifyIntroEvent failed: 0x%08x\n", status);
259 if (NULL == NewValue)
267 (0 == OriginalValue))
274 if (OriginalValue == *NewValue)
282 memzero(&victim,
sizeof(victim));
283 memzero(&originator,
sizeof(originator));
288 exitAfterInformation =
FALSE;
294 exitAfterInformation =
TRUE;
299 ERROR(
"[ERROR] Failed getting originator: 0x%08x\n", status);
300 exitAfterInformation =
TRUE;
307 ERROR(
"[ERROR] Failed getting zone details: 0x%08x\n", status);
308 exitAfterInformation =
TRUE;
311 if (exitAfterInformation)
345 BOOLEAN hookX64Msrs, hookX86Msrs;
356 hookX86Msrs = !hookX64Msrs;
362 hookX64Msrs = hookX86Msrs =
TRUE;
369 TRACE(
"[MSR] Adding protection on MSR IA32_SYSENTER_EIP...\n");
374 ERROR(
"[ERROR] Failed hooking the MSR!\n");
379 TRACE(
"[MSR] Adding protection on MSR IA32_SYSENTER_ESP...\n");
384 ERROR(
"[ERROR] Failed hooking the MSR!\n");
389 TRACE(
"[MSR] Adding protection on MSR IA32_SYSENTER_CS...\n");
394 ERROR(
"[ERROR] Failed hooking the MSR!\n");
401 TRACE(
"[MSR] Adding protection on MSR IA32_STAR...\n");
406 ERROR(
"[ERROR] Failed hooking the MSR!\n");
410 TRACE(
"[MSR] Adding protection on MSR IA32_LSTAR...\n");
415 ERROR(
"[ERROR] Failed hooking the MSR!\n");
444 TRACE(
"[MSR] Removing protection on MSR IA32_LSTAR...\n");
453 TRACE(
"[MSR] Removing protection on MSR IA32_STAR...\n");
462 TRACE(
"[MSR] Removing protection on MSR IA32_SYSENTER_CS...\n");
471 TRACE(
"[MSR] Removing protection on MSR IA32_SYSENTER_Eip...\n");
480 TRACE(
"[MSR] Removing protection on MSR IA32_SYSENTER_ESP...\n");
Measures kernel mode exceptions checks.
enum _INTRO_ACTION_REASON INTRO_ACTION_REASON
The reason for which an INTRO_ACTION was taken.
#define IG_IA32_SYSENTER_ESP
QWORD IntAlertCoreGetFlags(QWORD ProtectionFlag, INTRO_ACTION_REASON Reason)
Returns the flags for an alert.
An internal error occurred (no memory, pages not present, etc.).
BOOLEAN IntPolicyCoreForceBetaIfNeeded(QWORD Flag, INTRO_ACTION *Action)
Checks if a forced action should be taken even if the log-only mode is active.
MITRE_ID MitreID
The Mitre ID that corresponds to this attack.
QWORD SystemCr3
The Cr3 used to map the kernel.
#define INT_STATUS_SUCCESS
BOOLEAN IntPolicyCoreTakeAction(QWORD Flag, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
Returns the action that should be taken for a core introspection option.
QWORD NewValue[8]
The written value. Only the first Size bytes are valid.
void IntAlertMsrFill(const EXCEPTION_VICTIM_ZONE *Victim, const EXCEPTION_KM_ORIGINATOR *Originator, EVENT_MSR_VIOLATION *MsrViolation)
Saves information about a MSR write attempt in an event.
INTRO_MODULE ReturnModule
The module to which the current code return to.
#define INT_SUCCESS(Status)
QWORD Flags
A combination of ALERT_FLAG_* values describing the alert.
static void * gSysenterEspHook
IA32_SYSENTER_ESP hook.
#define IG_IA32_SYSENTER_EIP
#define INT_STATUS_NOT_NEEDED_HINT
KERNEL_DRIVER * Driver
The driver that's modifying the memory.
int INTSTATUS
The status data type.
INTSTATUS IntMsrSyscallUnprotect(void)
Remove protection from all protected MSRs.
INTRO_EXEC_CONTEXT ExecContext
Information about the instruction that triggered the alert.
static BOOLEAN gMsrHookSet
True if the SYSCALL/SYSENTER MSRs are protected.
Describes a kernel-mode originator.
static void * gSysenterEipHook
IA32_SYSENTER_EIP hook.
INTRO_GUEST_TYPE OSType
The type of the guest.
void IntAlertFillCpuContext(BOOLEAN CopyInstruction, INTRO_CPUCTX *CpuContext)
Fills the current CPU context for an alert.
struct _EXCEPTION_KM_ORIGINATOR::@63 Return
void IntAlertFillVersionInfo(INTRO_VIOLATION_HEADER *Header)
Fills version information for an alert.
struct _EVENT_MSR_VIOLATION::@291 Originator
static void * gSysenterCsHook
IA32_SYSENTER_CS hook.
#define INTRO_OPT_PROT_KM_MSR_SYSCALL
INTRO_ACTION_REASON Reason
The reason for which Action was taken.
INTSTATUS IntAlertFillCodeBlocks(QWORD Rip, QWORD Cr3, BOOLEAN Execute, INTRO_CODEBLOCKS *CodeBlocks)
Fills the code blocks pattern for an alert.
static INTSTATUS IntWinMsrSendAlert(PEXCEPTION_VICTIM_ZONE Victim, PEXCEPTION_KM_ORIGINATOR Originator, INTRO_ACTION Action, INTRO_ACTION_REASON Reason)
Send an MSR alert.
static void * gSyscallStarHook
IA32_STAR hook.
GENERIC_ALERT gAlert
Global alert buffer.
void IntAlertFillLixKmModule(const KERNEL_DRIVER *Driver, INTRO_MODULE *EventModule)
Saves information about a kernel module inside an alert.
INTRO_CODEBLOCKS CodeBlocks
Code blocks extracted for the alert.
#define INT_STATUS_EXCEPTION_BLOCK
INTRO_CPUCTX CpuContext
The context of the CPU that triggered the alert.
INTSTATUS IntNotifyIntroEvent(INTRO_EVENT_TYPE EventClass, void *Param, size_t EventSize)
Notifies the integrator about an introspection alert.
Event structure for MSR violation.
BOOLEAN Guest64
True if this is a 64-bit guest, False if it is a 32-bit guest.
INTSTATUS IntExceptGetVictimMsr(QWORD NewValue, QWORD OldValue, DWORD Msr, EXCEPTION_VICTIM_ZONE *Victim)
This function is used to get the information about the MSR victim.
static void * gSyscallLstarHook
IA32_LSTAR hook.
void IntExceptKernelLogInformation(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator, INTRO_ACTION Action, INTRO_ACTION_REASON Reason)
Print the information about a kernel-mode violation and dumps the code-blocks.
INTSTATUS IntHookMsrRemoveHook(HOOK_MSR *Hook)
Remove a model specific register hook.
#define INT_STATUS_ALREADY_INITIALIZED_HINT
static INTSTATUS IntWinMsrHandleWrite(DWORD Msr, DWORD Flags, INTRO_ACTION *Action, void *Context, QWORD OriginalValue, const QWORD *NewValue)
Handles a model specific register write attempt done by a Windows guest.
INTRO_MODULE Module
The module that did the malicious access.
Describes the modified zone.
#define UNREFERENCED_PARAMETER(P)
#define INT_STATUS_INVALID_PARAMETER_6
enum _INTRO_ACTION INTRO_ACTION
Event actions.
QWORD Rip
The RIP from where the call to the exported function came.
QWORD OldValue[8]
The original value. Only the first Size bytes are valid.
INTSTATUS IntHookMsrSetHook(DWORD Msr, DWORD Flags, PFUNC_MsrReadWriteHookCallback Callback, void *Context, void **Hook)
Set a model-specific register write hook.
QWORD Cr3
The value of the guest CR3 register when the event was generated.
MM Mm
Guest memory information, such as paging mode, system Cr3 value, etc.
GUEST_STATE gGuest
The current guest state.
void IntAlertFillWinProcessByCr3(QWORD ProcessCr3, INTRO_PROCESS *EventProcess)
Saves information about a Windows process inside an alert. The process is searched by its kernel CR3...
INTSTATUS IntMsrSyscallProtect(void)
Enable protection for all SYSCALL and SYSENTER MSRs.
INTSTATUS(* PFUNC_MsrReadWriteHookCallback)(DWORD Msr, DWORD Flags, INTRO_ACTION *Action, void *Context, QWORD OriginalValue, QWORD *NewValue)
Model specific register access callback.
struct _EXCEPTION_KM_ORIGINATOR::@64 Original
static INTSTATUS IntLixMsrHandleWrite(DWORD Msr, DWORD Flags, INTRO_ACTION *Action, void *Context, QWORD OriginalValue, const QWORD *NewValue)
Handles a model specific register write attempt done by a Linux guest.
INTRO_ACTION Action
The action that was taken as the result of this alert.
union _EVENT_MSR_VIOLATION::@292 Victim
INTRO_PROCESS CurrentProcess
The current process.
INTRO_VIOLATION_HEADER Header
The alert header.
The action was blocked because there was no exception for it.
DWORD Msr
The ID of the MSR as defined by the Intel documentation.
Sent when a MSR violation triggers an alert.See EVENT_MSR_VIOLATION.
void IntAlertFillLixCurrentProcess(INTRO_PROCESS *EventProcess)
Saves the current Linux process inside an event.
INTSTATUS IntExceptKernelGetOriginator(EXCEPTION_KM_ORIGINATOR *Originator, DWORD Options)
This function is used to get the information about the kernel-mode originator.
INTSTATUS IntAlertFillExecContext(QWORD Cr3, INTRO_EXEC_CONTEXT *ExecContext)
Fills the current execution context.
#define IG_IA32_SYSENTER_CS
void IntExcept(EXCEPTION_VICTIM_ZONE *Victim, void *Originator, EXCEPTION_TYPE Type, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason, INTRO_EVENT_TYPE EventClass)
This function is the entry point for the exception mechanism.
INTRO_WRITE_INFO WriteInfo
The original value of the MSR and the value that the guest tried to write.
#define INT_STATUS_INVALID_PARAMETER_3