mirror-ac/user/main.cpp

115 lines
3.1 KiB
C++
Raw Normal View History

2023-08-15 14:02:17 +02:00
#include <iostream>
#include <Windows.h>
#include <string>
2023-09-15 22:25:02 +02:00
#include <WDBGEXTS.H>
2023-08-15 14:02:17 +02:00
#include "common.h"
2023-08-16 11:28:46 +02:00
2023-08-17 10:45:50 +02:00
#include "threadpool.h"
2023-08-22 19:32:25 +02:00
#include "client.h"
2023-08-15 14:02:17 +02:00
2023-08-17 10:45:50 +02:00
#include "../user/um/umanager.h"
#include "../user/km/kmanager.h"
DWORD WINAPI Init(HINSTANCE hinstDLL)
2023-08-16 11:28:46 +02:00
{
2023-08-17 10:45:50 +02:00
AllocConsole();
FILE* file;
freopen_s( &file, "CONOUT$", "w", stdout );
freopen_s( &file, "CONIN$", "r", stdin );
std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
2023-08-18 09:18:00 +02:00
LPTSTR pipe_name = (LPTSTR)L"\\\\.\\pipe\\DonnaACPipe";
2023-08-19 05:06:09 +02:00
LPCWSTR driver_name = L"\\\\.\\DonnaAC";
2023-08-18 07:33:13 +02:00
2023-08-17 10:45:50 +02:00
std::shared_ptr<global::ThreadPool> thread_pool = std::make_shared<global::ThreadPool>( 4 );
2023-09-07 19:49:36 +02:00
std::shared_ptr<global::Client> client_interface = std::make_shared<global::Client>( thread_pool, pipe_name );
2023-08-17 10:45:50 +02:00
2023-09-07 19:49:36 +02:00
usermode::UManager umanager( thread_pool, client_interface );
kernelmode::KManager kmanager( driver_name, thread_pool, client_interface);
global::headers::SYSTEM_INFORMATION system_information;
2023-09-08 20:41:11 +02:00
kmanager.SendClientHardwareInformation();
2023-08-19 04:52:57 +02:00
global::report_structures::SYSTEM_INFORMATION_REQUEST_RESPONSE response;
client_interface->ServerReceive( &response, sizeof( response ) );
std::cout << "RequestID: " << response.RequestId << " CanUserProceed: " <<
response.CanUserProceed << " Reason: " << response.reason << std::endl;
2023-08-17 10:45:50 +02:00
while ( !GetAsyncKeyState( VK_DELETE ) )
{
2023-09-22 20:23:49 +02:00
kmanager.VerifySystemModules();
2023-09-15 22:25:02 +02:00
//srand( time( NULL ) );
2023-09-22 20:23:49 +02:00
//int seed = ( rand() % 7 );
2023-09-15 22:25:02 +02:00
//std::cout << "Seed: " << seed << std::endl;
//switch ( seed )
//{
//case 0:
// kmanager.EnumerateHandleTables();
// break;
//case 1:
// kmanager.PerformIntegrityCheck();
// break;
//case 2:
// kmanager.ScanPoolsForUnlinkedProcesses();
// break;
//case 3:
// kmanager.VerifySystemModules();
// break;
//case 4:
// kmanager.ValidateProcessModules();
// break;
//case 5:
// kmanager.RunNmiCallbacks();
// break;
2023-09-22 20:23:49 +02:00
//case 6:
// kmanager.CheckForAttachedThreads();
// break;
2023-09-15 22:25:02 +02:00
//}
//kmanager.MonitorCallbackReports();
2023-08-30 13:27:23 +02:00
2023-09-22 20:23:49 +02:00
std::this_thread::sleep_for( std::chrono::seconds( 5 ) );
2023-08-17 10:45:50 +02:00
}
fclose( stdout );
fclose( stdin );
FreeConsole();
2023-08-16 11:28:46 +02:00
2023-08-17 10:45:50 +02:00
FreeLibraryAndExitThread( hinstDLL, 0);
return 0;
2023-08-16 11:28:46 +02:00
}
2023-08-17 10:45:50 +02:00
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved ) // reserved
2023-08-15 14:02:17 +02:00
{
2023-08-17 10:45:50 +02:00
// Perform actions based on the reason for calling.
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
2023-08-16 11:28:46 +02:00
2023-08-17 10:45:50 +02:00
DisableThreadLibraryCalls( hinstDLL );
2023-08-15 14:02:17 +02:00
2023-08-17 10:45:50 +02:00
const auto thread = CreateThread(
nullptr,
0,
reinterpret_cast< LPTHREAD_START_ROUTINE >( Init ),
hinstDLL,
0,
nullptr
);
2023-08-15 14:02:17 +02:00
2023-08-17 10:45:50 +02:00
if ( thread )
CloseHandle( thread );
2023-08-16 11:28:46 +02:00
2023-08-17 10:45:50 +02:00
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
2023-08-15 14:02:17 +02:00
}