Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
pano_query.cpp
Go to the documentation of this file.
1#include "pano_query.h"
2#include <ntifs.h>
3
4
6 UNREFERENCED_PARAMETER(policyInfo);
7 HANDLE hProcess;
8 PEPROCESS eProcess;
9
10 if (ProcessId == NULL) {
11 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[-] Panoptes: Invalid ProcessId\n");
12 return STATUS_INVALID_PARAMETER; //0xC000000D
13 }
14
15 NTSTATUS status = PsLookupProcessByProcessId(ProcessId, &eProcess);
16 if (!NT_SUCCESS(status)) {
17 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[-] Panoptes: PsLookupProcessByProcessId failed with status 0x%X\n", status);
18 return status;
19 }
20
21 status = ObOpenObjectByPointer(
22 eProcess,
23 OBJ_KERNEL_HANDLE,
24 NULL,
25 0x1000,//PROCESS_QUERY_LIMITED_INFORMATION,
26 *PsProcessType,
27 KernelMode,
28 &hProcess);
29
30 ObDereferenceObject(eProcess);
31
32 if (!NT_SUCCESS(status)) {
33 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[-] Panoptes: ObOpenObjectByPointer failed with status 0x%X\n", status);
34 return status;
35 }
36
38 policyInfoLocal.Policy = ProcessSignaturePolicy;
39 status = ZwQueryInformationProcess(hProcess, ProcessMitigationPolicy, &policyInfoLocal, sizeof(policyInfoLocal), nullptr);
40 if (!NT_SUCCESS(status)) {
41 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[-] Panoptes: ZwQueryInformationProcess failed with status 0x%X\n", status);
42 }
43
44 if (&policyInfoLocal != NULL) {
45 if (policyInfoLocal.Data.SignaturePolicy.MicrosoftSignedOnly != 0) {
46 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[+] Panoptes: Process with MicrosoftOnly");
47 }
48 }
49
50 ZwClose(hProcess);
51
52 return STATUS_SUCCESS;
53}
54
55
56//NTSTATUS InitializeZwQueryInformationProcess() {
57// UNICODE_STRING routineName;
58// RtlInitUnicodeString(&routineName, L"ZwQueryInformationProcess");
59// //https://stackoverflow.com/questions/3707133/how-to-use-zwqueryinformationprocess-to-get-processimagefilename-in-a-kernel-dri
60// ZwQueryInformationProcess = (QUERY_INFO_PROCESS)MmGetSystemRoutineAddress(&routineName);
61// if (ZwQueryInformationProcess == NULL) {
62// DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[-] Panoptes: Cannot resolve ZwQueryInformationProcess\n");
63// return STATUS_INVALID_HANDLE;
64// }
65//
66// return STATUS_SUCCESS;
67//}
68
69
70
71
NTSTATUS QueryProcessMitigationPolicy(HANDLE ProcessId, PROCESS_MITIGATION_POLICY_INFORMATION *policyInfo)
Definition pano_query.cpp:5
NTSTATUS NTAPI ZwQueryInformationProcess(HANDLE hProcess, PROCESSINFOCLASS infoType, PVOID pBuf, ULONG lenBuf, SIZE_T *returnLength)
PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY SignaturePolicy
Definition pano_query.h:16
PROCESS_MITIGATION_POLICY Policy
Definition pano_query.h:7
union _PROCESS_MITIGATION_POLICY_INFORMATION::@5 Data