mirror of
https://github.com/JKornev/hidden
synced 2024-06-26 00:48:05 +00:00
Added path normalization to the ps monitor
This commit is contained in:
parent
22fdb1d00b
commit
4c3047c669
@ -35,15 +35,15 @@ OB_PREOP_CALLBACK_STATUS ProcessPreCallback(PVOID RegistrationContext, POB_PRE_O
|
|||||||
|
|
||||||
if (OperationInformation->KernelHandle)
|
if (OperationInformation->KernelHandle)
|
||||||
return OB_PREOP_SUCCESS;
|
return OB_PREOP_SUCCESS;
|
||||||
|
|
||||||
|
if (!IsProcessProtected(PsGetProcessId(OperationInformation->Object)))
|
||||||
|
return OB_PREOP_SUCCESS;
|
||||||
|
|
||||||
DbgPrint("FsFilter1!" __FUNCTION__ ": !!!!! Process: %d(%d:%d), Oper: %s, Space: %s\n",
|
DbgPrint("FsFilter1!" __FUNCTION__ ": !!!!! Process: %d(%d:%d), Oper: %s, Space: %s\n",
|
||||||
PsGetProcessId(OperationInformation->Object), PsGetCurrentProcessId(), PsGetCurrentThreadId(),
|
PsGetProcessId(OperationInformation->Object), PsGetCurrentProcessId(), PsGetCurrentThreadId(),
|
||||||
(OperationInformation->Operation == OB_OPERATION_HANDLE_CREATE ? "create" : "dup"),
|
(OperationInformation->Operation == OB_OPERATION_HANDLE_CREATE ? "create" : "dup"),
|
||||||
(OperationInformation->KernelHandle ? "kernel" : "user")
|
(OperationInformation->KernelHandle ? "kernel" : "user")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!IsProcessProtected(PsGetProcessId(OperationInformation->Object)))
|
|
||||||
return OB_PREOP_SUCCESS;
|
|
||||||
|
|
||||||
if (IsProcessProtected(PsGetCurrentProcessId()))
|
if (IsProcessProtected(PsGetCurrentProcessId()))
|
||||||
{
|
{
|
||||||
@ -68,15 +68,15 @@ OB_PREOP_CALLBACK_STATUS ThreadPreCallback(PVOID RegistrationContext, POB_PRE_OP
|
|||||||
if (OperationInformation->KernelHandle)
|
if (OperationInformation->KernelHandle)
|
||||||
return OB_PREOP_SUCCESS;
|
return OB_PREOP_SUCCESS;
|
||||||
|
|
||||||
DbgPrint("FsFilter1!" __FUNCTION__ ": Thread: %d(%d:%d), Oper: %s, Space: %s\n",
|
if (!IsProcessProtected(PsGetProcessId(OperationInformation->Object)))
|
||||||
|
return OB_PREOP_SUCCESS;
|
||||||
|
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": Thread: %d(%d:%d), Oper: %s, Space: %s\n",
|
||||||
PsGetThreadId(OperationInformation->Object), PsGetCurrentProcessId(), PsGetCurrentThreadId(),
|
PsGetThreadId(OperationInformation->Object), PsGetCurrentProcessId(), PsGetCurrentThreadId(),
|
||||||
(OperationInformation->Operation == OB_OPERATION_HANDLE_CREATE ? "create" : "dup"),
|
(OperationInformation->Operation == OB_OPERATION_HANDLE_CREATE ? "create" : "dup"),
|
||||||
(OperationInformation->KernelHandle ? "kernel" : "user")
|
(OperationInformation->KernelHandle ? "kernel" : "user")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!IsProcessProtected(PsGetProcessId(OperationInformation->Object)))
|
|
||||||
return OB_PREOP_SUCCESS;
|
|
||||||
|
|
||||||
if (IsProcessProtected(PsGetCurrentProcessId()))
|
if (IsProcessProtected(PsGetCurrentProcessId()))
|
||||||
{
|
{
|
||||||
DbgPrint("FsFilter1!" __FUNCTION__ ": !!!!! allow protected thread %d\n", PsGetCurrentProcessId());
|
DbgPrint("FsFilter1!" __FUNCTION__ ": !!!!! allow protected thread %d\n", PsGetCurrentProcessId());
|
||||||
@ -379,7 +379,36 @@ NTSTATUS DestroyPsMonitor()
|
|||||||
|
|
||||||
NTSTATUS AddProtectedImage(PUNICODE_STRING ImagePath, ULONG InheritType, PULONGLONG ObjId)
|
NTSTATUS AddProtectedImage(PUNICODE_STRING ImagePath, ULONG InheritType, PULONGLONG ObjId)
|
||||||
{
|
{
|
||||||
return AddRuleToPsRuleList(g_protectProcessRules, ImagePath, InheritType, ObjId);
|
const USHORT maxBufSize = ImagePath->Length + NORMALIZE_INCREAMENT;
|
||||||
|
UNICODE_STRING normalized;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
normalized.Buffer = (PWCH)ExAllocatePool(PagedPool, maxBufSize);
|
||||||
|
normalized.Length = 0;
|
||||||
|
normalized.MaximumLength = maxBufSize;
|
||||||
|
|
||||||
|
if (!normalized.Buffer)
|
||||||
|
{
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": error, can't allocate buffer\n");
|
||||||
|
return STATUS_MEMORY_NOT_ALLOCATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = NormalizeDevicePath(ImagePath, &normalized);
|
||||||
|
if (!NT_SUCCESS(status))
|
||||||
|
{
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": path normalization failed with code:%08x, path:%wZ\n", status, ImagePath);
|
||||||
|
ExFreePool(normalized.Buffer);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": protect image: %wZ\n", &normalized);
|
||||||
|
status = AddRuleToPsRuleList(g_protectProcessRules, &normalized, InheritType, ObjId);
|
||||||
|
|
||||||
|
ExFreePool(normalized.Buffer);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
//DbgPrint("FsFilter1!" __FUNCTION__ ": protect image: %wZ\n", ImagePath);
|
||||||
|
//return AddRuleToPsRuleList(g_protectProcessRules, ImagePath, InheritType, ObjId);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS GetProtectedProcessState(HANDLE ProcessId, PULONG InheritType, PBOOLEAN Enable)
|
NTSTATUS GetProtectedProcessState(HANDLE ProcessId, PULONG InheritType, PBOOLEAN Enable)
|
||||||
@ -433,7 +462,34 @@ NTSTATUS RemoveAllProtectedImages()
|
|||||||
|
|
||||||
NTSTATUS AddExcludedImage(PUNICODE_STRING ImagePath, ULONG InheritType, PULONGLONG ObjId)
|
NTSTATUS AddExcludedImage(PUNICODE_STRING ImagePath, ULONG InheritType, PULONGLONG ObjId)
|
||||||
{
|
{
|
||||||
return AddRuleToPsRuleList(g_excludeProcessRules, ImagePath, InheritType, ObjId);
|
const USHORT maxBufSize = ImagePath->Length + NORMALIZE_INCREAMENT;
|
||||||
|
UNICODE_STRING normalized;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
normalized.Buffer = (PWCH)ExAllocatePool(PagedPool, maxBufSize);
|
||||||
|
normalized.Length = 0;
|
||||||
|
normalized.MaximumLength = maxBufSize;
|
||||||
|
|
||||||
|
if (!normalized.Buffer)
|
||||||
|
{
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": error, can't allocate buffer\n");
|
||||||
|
return STATUS_MEMORY_NOT_ALLOCATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = NormalizeDevicePath(ImagePath, &normalized);
|
||||||
|
if (!NT_SUCCESS(status))
|
||||||
|
{
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": path normalization failed with code:%08x, path:%wZ\n", status, ImagePath);
|
||||||
|
ExFreePool(normalized.Buffer);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgPrint("FsFilter1!" __FUNCTION__ ": exclude image: %wZ\n", &normalized);
|
||||||
|
status = AddRuleToPsRuleList(g_excludeProcessRules, &normalized, InheritType, ObjId);
|
||||||
|
|
||||||
|
ExFreePool(normalized.Buffer);
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS GetExcludedProcessState(HANDLE ProcessId, PULONG InheritType, PBOOLEAN Enable)
|
NTSTATUS GetExcludedProcessState(HANDLE ProcessId, PULONG InheritType, PBOOLEAN Enable)
|
||||||
|
@ -618,13 +618,7 @@ NTSTATUS DestroyRegistryFilter()
|
|||||||
|
|
||||||
NTSTATUS AddHiddenRegKey(PUNICODE_STRING KeyPath, PULONGLONG ObjId)
|
NTSTATUS AddHiddenRegKey(PUNICODE_STRING KeyPath, PULONGLONG ObjId)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
return AddExcludeListRegistryKey(g_excludeRegKeyContext, KeyPath, ObjId);
|
||||||
|
|
||||||
// TODO: normalize registry key path
|
|
||||||
|
|
||||||
status = AddExcludeListRegistryKey(g_excludeRegKeyContext, KeyPath, ObjId);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS RemoveHiddenRegKey(ULONGLONG ObjId)
|
NTSTATUS RemoveHiddenRegKey(ULONGLONG ObjId)
|
||||||
@ -639,13 +633,7 @@ NTSTATUS RemoveAllHiddenRegKeys()
|
|||||||
|
|
||||||
NTSTATUS AddHiddenRegValue(PUNICODE_STRING ValuePath, PULONGLONG ObjId)
|
NTSTATUS AddHiddenRegValue(PUNICODE_STRING ValuePath, PULONGLONG ObjId)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
return AddExcludeListRegistryValue(g_excludeRegValueContext, ValuePath, ObjId);
|
||||||
|
|
||||||
// TODO: normalize registry value path
|
|
||||||
|
|
||||||
status = AddExcludeListRegistryValue(g_excludeRegValueContext, ValuePath, ObjId);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS RemoveHiddenRegValue(ULONGLONG ObjId)
|
NTSTATUS RemoveHiddenRegValue(ULONGLONG ObjId)
|
||||||
|
@ -19,22 +19,25 @@
|
|||||||
+ Добавить проект HiddenTest
|
+ Добавить проект HiddenTest
|
||||||
- Реализовать тесты в проекте HiddenTest
|
- Реализовать тесты в проекте HiddenTest
|
||||||
+ FS monitor
|
+ FS monitor
|
||||||
- Reg filter
|
+ Reg filter
|
||||||
- Ps filter
|
- Ps filter
|
||||||
- Добавить в Reg filter поддержку всех возможных операций над value
|
+ Добавить в Reg filter поддержку всех возможных операций над value
|
||||||
- set value
|
+ set value
|
||||||
- delete value
|
+ delete value
|
||||||
- query value
|
+ query value
|
||||||
- query multiple value
|
+ query multiple value
|
||||||
- Почистить Exclude List
|
- Почистить Exclude List
|
||||||
+ Добавить в Exclude List поддержку case insensetive crc32 (если возможно, например русские буквы) (*Нет необхлжимости)
|
+ Добавить в Exclude List поддержку case insensetive crc32 (если возможно, например русские буквы) (*Нет необхлжимости)
|
||||||
- Добавить в Exclude List для файлов такую же лексическую сортировку как и в реестру, возможно обьеденить ф-и
|
- Добавить в Exclude List для файлов такую же лексическую сортировку как и в реестру, возможно обьеденить ф-и
|
||||||
- Переписать всё на основе AVL или других buildin generic trees
|
- Переписать всё на основе AVL или других buildin generic trees
|
||||||
- Реализовать конвертирование пути в пути драйвера
|
+ Реализовать конвертирование пути в пути драйвера
|
||||||
- Ps monitor
|
+ Ps monitor
|
||||||
+ FS filter
|
+ FS filter
|
||||||
- Reg filter
|
+ Reg filter
|
||||||
+ Реализовать RemoveAllExcludeListEntries
|
+ Реализовать RemoveAllExcludeListEntries
|
||||||
|
- Реализовать все ф-и Ps monitor
|
||||||
|
- Добавить в библиотеку поддержку get\set state
|
||||||
|
- Решить проблему с protected (возможно разрешить создавать такие процессы только из protected\system)
|
||||||
- Реализовать IOCTL протокол управления
|
- Реализовать IOCTL протокол управления
|
||||||
+ Реализовать usermode библиотеку для работы с IOCTL API
|
+ Реализовать usermode библиотеку для работы с IOCTL API
|
||||||
- Реализовать программу управления драйвером, средствами IOCTL API
|
- Реализовать программу управления драйвером, средствами IOCTL API
|
||||||
|
Loading…
Reference in New Issue
Block a user