Added a test that validates hiding processes

This commit is contained in:
JKornev 2021-08-25 02:10:13 +03:00
parent a5382ce955
commit 59439bae79
3 changed files with 49 additions and 6 deletions

View File

@ -150,9 +150,10 @@ NTSTATUS NormalizeDevicePath(PCUNICODE_STRING Path, PUNICODE_STRING Normalized);
DbgPrintEx(\
DPFLTR_IHVDRIVER_ID, \
lvl, \
"[" lvlname "] [irql:%Iu,pid:%Iu] hidden!" __FUNCTION__ ": " frmt "\n", \
"[" lvlname "] [irql:%Iu,pid:%Iu,tid:%Iu]\thidden!" __FUNCTION__ ": " frmt "\n", \
KeGetCurrentIrql(), \
PsGetCurrentProcessId(), \
PsGetCurrentThreadId(), \
__VA_ARGS__ \
)

View File

@ -80,9 +80,9 @@
- Решить проблему синхронизации доступа к ActiveProcessLinks
- Добавить поддержку сокрытия из SessionProcessLinks (если в этом есть смысл)
- Реализовать сокрытие сервисов через scdb патч
- Добавить тест для проверки сокрытия процессов
+ Добавить тест для проверки сокрытия процессов
+ Решить проблему с %tu принтом лога на 32-бит драйвере
- Эмулировать создание reg\fs обьектов, когда обьект с таким же именем скрыт
+ GetProcessInProcessTable может возвращать ptr чтобы избежать UpdateProcessInProcessTable
- Windows 7 x86 protect тест завален
+ Windows 7 x86 protect тест завален
- Проверить всё на Windows Vista

View File

@ -851,6 +851,7 @@ void do_psmon_hide_tests(HidContext context)
PROCESS_INFORMATION pi;
wchar_t path[] = L"c:\\windows\\system32\\charmap.exe";
HANDLE hproc = 0;
HidObjId objId[3];
wcout << L"--------------------------------" << endl;
wcout << L"Process monitor hide tests result:" << endl;
@ -918,15 +919,56 @@ void do_psmon_hide_tests(HidContext context)
}
wcout << L" successful!" << endl;
wcout << L"Test 2: create process, hide, check, unhide" << endl;
hid_status = Hid_AddHiddenImage(context, path, HidPsInheritTypes::WithoutInherit, FALSE, &objId[1]);
if (!HID_STATUS_SUCCESSFUL(hid_status))
{
wcout << L"Error, can't hide image, code: " << HID_STATUS_CODE(hid_status) << endl;
throw exception();
}
if (!CreateProcessW(NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
auto error_code = GetLastError();
wcout << L"Error, CreateProcessW() failed with code: " << error_code << endl;
throw exception();
}
CloseHandle(pi.hThread);
hid_status = Hid_GetHiddenState(context, pi.dwProcessId, &state, &inheritType);
if (!HID_STATUS_SUCCESSFUL(hid_status))
{
wcout << L"Error, can't process hidden state, code: " << HID_STATUS_CODE(hid_status) << endl;
throw exception();
}
if (state != HidActiveState::StateEnabled || inheritType != HidPsInheritTypes::WithoutInherit)
{
wcout << L"Error, state or inheritType invalid, state: " << (UINT)state << " type: " << (UINT)inheritType << endl;
throw exception();
}
// Because hiding process on a start is async op we need to wait a bit before checking a state
Sleep(1000);
hproc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pi.dwProcessId);
if (hproc)
{
CloseHandle(hproc);
wcout << L"Error, process isn't hidden" << endl;
throw exception();
}
wcout << L" successful!" << endl;
}
catch (exception&)
{
wcout << L" failed!" << endl;
}
if (hproc)
CloseHandle(hproc);
if (pi.hProcess)
{
TerminateProcess(pi.hProcess, 0);