2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @file Controller.h
|
|
|
|
|
* @brief Main orchestration class for KVC Framework operations
|
|
|
|
|
* @author Marek Wesolowski
|
|
|
|
|
* @date 2025
|
|
|
|
|
* @copyright KVC Framework
|
|
|
|
|
*
|
|
|
|
|
* Central controller managing kernel driver communication, process protection,
|
|
|
|
|
* DPAPI password extraction, and system-level operations.
|
|
|
|
|
* Integrates all framework components and provides unified interface.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-17 21:46:05 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-10-02 01:08:10 +02:00
|
|
|
#include "SessionManager.h"
|
2025-09-17 21:46:05 +02:00
|
|
|
#include "kvcDrv.h"
|
2025-10-15 01:15:59 +02:00
|
|
|
#include "DSEBypass.h"
|
2025-09-17 21:46:05 +02:00
|
|
|
#include "OffsetFinder.h"
|
|
|
|
|
#include "TrustedInstallerIntegrator.h"
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <optional>
|
2025-09-23 22:13:43 +02:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <unordered_map>
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// Forward declarations
|
2025-09-17 21:46:05 +02:00
|
|
|
class ReportExporter;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @struct ProcessEntry
|
|
|
|
|
* @brief Kernel process structure representation for EPROCESS manipulation
|
|
|
|
|
*
|
|
|
|
|
* Contains complete process information obtained from kernel space
|
|
|
|
|
* including protection levels, signature information, and kernel addresses.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
struct ProcessEntry
|
|
|
|
|
{
|
2025-10-05 12:43:36 +02:00
|
|
|
ULONG_PTR KernelAddress; ///< EPROCESS structure address in kernel space
|
|
|
|
|
DWORD Pid; ///< Process identifier
|
|
|
|
|
UCHAR ProtectionLevel; ///< PP/PPL/None protection level (combined byte)
|
|
|
|
|
UCHAR SignerType; ///< Digital signature authority
|
|
|
|
|
UCHAR SignatureLevel; ///< Executable signature verification level
|
|
|
|
|
UCHAR SectionSignatureLevel; ///< DLL signature verification level
|
|
|
|
|
std::wstring ProcessName; ///< Process executable name
|
2025-09-17 21:46:05 +02:00
|
|
|
};
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @struct ProcessMatch
|
|
|
|
|
* @brief Process search result with kernel information
|
|
|
|
|
*
|
|
|
|
|
* Used for process resolution operations when driver may not be available.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
struct ProcessMatch
|
|
|
|
|
{
|
2025-10-05 12:43:36 +02:00
|
|
|
DWORD Pid = 0; ///< Process ID
|
|
|
|
|
std::wstring ProcessName; ///< Process name
|
|
|
|
|
ULONG_PTR KernelAddress = 0; ///< Kernel EPROCESS address
|
2025-09-17 21:46:05 +02:00
|
|
|
};
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @struct SQLiteAPI
|
|
|
|
|
* @brief WinSQLite dynamic loading structure for browser database operations
|
|
|
|
|
*
|
|
|
|
|
* Function pointers for SQLite3 operations used in browser password extraction.
|
|
|
|
|
* Loaded dynamically to avoid static linking dependencies.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
struct SQLiteAPI
|
|
|
|
|
{
|
2025-10-05 12:43:36 +02:00
|
|
|
HMODULE hModule = nullptr; ///< SQLite3 module handle
|
|
|
|
|
int (*open_v2)(const char*, void**, int, const char*) = nullptr; ///< sqlite3_open_v2
|
|
|
|
|
int (*prepare_v2)(void*, const char*, int, void**, const char**) = nullptr; ///< sqlite3_prepare_v2
|
|
|
|
|
int (*step)(void*) = nullptr; ///< sqlite3_step
|
|
|
|
|
const unsigned char* (*column_text)(void*, int) = nullptr; ///< sqlite3_column_text
|
|
|
|
|
const void* (*column_blob)(void*, int) = nullptr; ///< sqlite3_column_blob
|
|
|
|
|
int (*column_bytes)(void*, int) = nullptr; ///< sqlite3_column_bytes
|
|
|
|
|
int (*finalize)(void*) = nullptr; ///< sqlite3_finalize
|
|
|
|
|
int (*close_v2)(void*) = nullptr; ///< sqlite3_close_v2
|
2025-09-17 21:46:05 +02:00
|
|
|
};
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @struct PasswordResult
|
|
|
|
|
* @brief Password extraction result structure for DPAPI operations
|
|
|
|
|
*
|
|
|
|
|
* Stores decrypted credentials from browsers and WiFi with metadata.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
struct PasswordResult
|
|
|
|
|
{
|
2025-10-05 12:43:36 +02:00
|
|
|
std::wstring type; ///< Chrome, Edge, WiFi credential type
|
|
|
|
|
std::wstring profile; ///< Browser/WiFi profile name
|
|
|
|
|
std::wstring url; ///< URL for browser logins
|
|
|
|
|
std::wstring username; ///< Login username
|
|
|
|
|
std::wstring password; ///< Decrypted password
|
|
|
|
|
std::wstring file; ///< Source file path
|
|
|
|
|
std::wstring data; ///< Additional data
|
|
|
|
|
std::wstring status; ///< DECRYPTED, ENCRYPTED, FAILED
|
|
|
|
|
uintmax_t size = 0; ///< Data size in bytes
|
2025-09-17 21:46:05 +02:00
|
|
|
};
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @struct RegistryMasterKey
|
|
|
|
|
* @brief Registry master key for DPAPI decryption operations
|
|
|
|
|
*
|
|
|
|
|
* Represents encrypted master keys extracted from registry for DPAPI operations.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
struct RegistryMasterKey
|
|
|
|
|
{
|
2025-10-05 12:43:36 +02:00
|
|
|
std::wstring keyName; ///< Registry key path (DPAPI_SYSTEM, NL$KM, etc.)
|
|
|
|
|
std::vector<BYTE> encryptedData; ///< Raw encrypted key data from registry
|
|
|
|
|
std::vector<BYTE> decryptedData; ///< Decrypted master key data
|
|
|
|
|
bool isDecrypted = false; ///< Decryption success flag
|
2025-09-17 21:46:05 +02:00
|
|
|
};
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @class Controller
|
|
|
|
|
* @brief Main orchestration class for all KVC Framework operations
|
|
|
|
|
*
|
|
|
|
|
* Manages:
|
|
|
|
|
* - Kernel driver lifecycle and communication
|
|
|
|
|
* - Process protection manipulation (PP/PPL)
|
|
|
|
|
* - Memory dumping operations with protection handling
|
|
|
|
|
* - DPAPI password extraction (Chrome, Edge, WiFi)
|
|
|
|
|
* - Windows Defender exclusion management
|
|
|
|
|
* - TrustedInstaller privilege escalation
|
|
|
|
|
* - Registry operations and hive management
|
|
|
|
|
* - Session state tracking and restoration
|
|
|
|
|
*
|
|
|
|
|
* @note Central hub integrating all framework components
|
|
|
|
|
* @warning Requires appropriate privileges for different operations
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
class Controller
|
|
|
|
|
{
|
|
|
|
|
public:
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @brief Construct controller and initialize core components
|
|
|
|
|
*
|
|
|
|
|
* Initializes TrustedInstaller integration, offset finder, and SQLite.
|
|
|
|
|
* Does not automatically load driver - call driver methods as needed.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
Controller();
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Destructor with comprehensive cleanup
|
|
|
|
|
*
|
|
|
|
|
* Ends driver session, unloads SQLite, and cleans up resources.
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
~Controller();
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// Disable copy semantics
|
|
|
|
|
Controller(const Controller&) = delete; ///< Copy constructor deleted
|
|
|
|
|
Controller& operator=(const Controller&) = delete; ///< Copy assignment deleted
|
|
|
|
|
|
|
|
|
|
// Enable move semantics
|
|
|
|
|
Controller(Controller&&) noexcept = default; ///< Move constructor
|
|
|
|
|
Controller& operator=(Controller&&) noexcept = default; ///< Move assignment
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-15 01:15:59 +02:00
|
|
|
// DSE Bypass methods
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Disables Driver Signature Enforcement (DSE) on the system
|
|
|
|
|
*
|
|
|
|
|
* This method bypasses kernel-mode code signing protection by:
|
|
|
|
|
* - Locating the CiEnabled/CI!g_CiOptions global variable in kernel memory
|
|
|
|
|
* - Modifying its value to disable signature enforcement checks
|
|
|
|
|
* - Bypassing PatchGuard protection mechanisms
|
|
|
|
|
*
|
|
|
|
|
* @return true if DSE was successfully disabled, false otherwise
|
|
|
|
|
* @note Requires kernel driver to be loaded and elevated privileges
|
|
|
|
|
* @warning This exposes the system to unsigned driver loading - use with caution
|
|
|
|
|
* @note Automatically handles CiEnabled (Win7) and g_CiOptions (Win8+) variants
|
|
|
|
|
*/
|
|
|
|
|
bool DisableDSE() noexcept;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Restores Driver Signature Enforcement to its original state
|
|
|
|
|
*
|
|
|
|
|
* Reverts the changes made by DisableDSE() by:
|
|
|
|
|
* - Restoring the original value of CiOptions/CiEnabled
|
|
|
|
|
* - Re-enforcing kernel-mode code signing requirements
|
|
|
|
|
* - Ensuring system integrity is maintained
|
|
|
|
|
*
|
|
|
|
|
* @return true if DSE was successfully restored, false otherwise
|
|
|
|
|
* @note Should be called before driver unload to maintain system security
|
|
|
|
|
* @warning Failure to restore DSE may leave the system in an insecure state
|
|
|
|
|
*/
|
|
|
|
|
bool RestoreDSE() noexcept;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Retrieves the kernel address of CI!g_CiOptions or CiEnabled variable
|
|
|
|
|
*
|
|
|
|
|
* Locates the critical kernel structure that controls DSE by:
|
|
|
|
|
* - Scanning kernel memory for known patterns
|
|
|
|
|
* - Using exported kernel symbols when available
|
|
|
|
|
* - Employing heuristic search methods as fallback
|
|
|
|
|
*
|
|
|
|
|
* @return ULONG_PTR Virtual address of CiOptions in kernel space, 0 if not found
|
|
|
|
|
* @note The address is used for direct memory modification to bypass DSE
|
|
|
|
|
* @note Returns different addresses based on Windows version (Win7 vs Win8+)
|
|
|
|
|
*/
|
|
|
|
|
ULONG_PTR GetCiOptionsAddress() const noexcept;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Retrieves current DSE status including g_CiOptions address and value
|
|
|
|
|
*
|
|
|
|
|
* Queries the kernel for current Driver Signature Enforcement state by:
|
|
|
|
|
* - Locating ci.dll module in kernel space
|
|
|
|
|
* - Finding g_CiOptions variable address
|
|
|
|
|
* - Reading current enforcement flags
|
|
|
|
|
*
|
|
|
|
|
* @param outAddress Reference to store g_CiOptions kernel address
|
|
|
|
|
* @param outValue Reference to store current g_CiOptions value
|
|
|
|
|
* @return true if status retrieved successfully, false otherwise
|
|
|
|
|
* @note Requires driver session with kernel memory access
|
|
|
|
|
* @note outValue bits 1-2 indicate DSE state (set = enabled)
|
|
|
|
|
*/
|
|
|
|
|
bool GetDSEStatus(ULONG_PTR& outAddress, DWORD& outValue) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Memory Dumping Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Dump process memory to file with driver support
|
|
|
|
|
* @param pid Process ID to dump
|
|
|
|
|
* @param outputPath Output file path
|
|
|
|
|
* @return true if dump successful
|
|
|
|
|
* @note Handles protected processes and undumpable flags
|
|
|
|
|
* @note Uses kernel driver for memory access
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool DumpProcess(DWORD pid, const std::wstring& outputPath) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Dump process by name with pattern matching
|
|
|
|
|
* @param processName Process name or pattern
|
|
|
|
|
* @param outputPath Output file path
|
|
|
|
|
* @return true if dump successful
|
|
|
|
|
* @note Supports partial name matching and wildcards
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool DumpProcessByName(const std::wstring& processName, const std::wstring& outputPath) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
// === Binary Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Load and split kvc.dat into components
|
|
|
|
|
* @return true if components extracted successfully
|
|
|
|
|
* @note Deploys kvc_pass.exe and kvc_crypt.dll to System32
|
|
|
|
|
* @note Uses XOR decryption for embedded binaries
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool LoadAndSplitCombinedBinaries() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Write extracted components to filesystem
|
|
|
|
|
* @param kvcPassData kvc_pass.exe binary data
|
|
|
|
|
* @param kvcCryptData kvc_crypt.dll binary data
|
|
|
|
|
* @return true if both components written successfully
|
|
|
|
|
* @note Uses TrustedInstaller privileges for System32 deployment
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool WriteExtractedComponents(const std::vector<BYTE>& kvcPassData,
|
|
|
|
|
const std::vector<BYTE>& kvcCryptData) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Process Information Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief List all protected processes with details
|
|
|
|
|
* @return true if enumeration successful
|
|
|
|
|
* @note Uses driver for kernel process list access
|
|
|
|
|
* @note Color-coded output based on trust levels
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ListProtectedProcesses() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get protection information for specific process
|
|
|
|
|
* @param pid Process ID to query
|
|
|
|
|
* @return true if information retrieved successfully
|
|
|
|
|
* @note Displays protection level, signer, and signature information
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool GetProcessProtection(DWORD pid) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get protection information by process name
|
|
|
|
|
* @param processName Process name to query
|
|
|
|
|
* @return true if information retrieved successfully
|
|
|
|
|
* @note Supports partial name matching
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool GetProcessProtectionByName(const std::wstring& processName) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Print detailed process information
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @return true if information printed successfully
|
|
|
|
|
* @note Shows kernel address, protection, and signature details
|
|
|
|
|
*/
|
2025-10-03 00:14:00 +02:00
|
|
|
bool PrintProcessInfo(DWORD pid) noexcept;
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Process Protection Manipulation ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set process protection level (force operation)
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @param protectionLevel Protection level string ("PP", "PPL", "None")
|
|
|
|
|
* @param signerType Signer type string ("Windows", "Antimalware", etc.)
|
|
|
|
|
* @return true if protection set successfully
|
|
|
|
|
* @note Ignores current protection state - forces new values
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool SetProcessProtection(DWORD pid, const std::wstring& protectionLevel, const std::wstring& signerType) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Protect unprotected process
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @return true if protection applied
|
|
|
|
|
* @note Fails if process already protected
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ProtectProcess(DWORD pid, const std::wstring& protectionLevel, const std::wstring& signerType) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove protection from process
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @return true if protection removed
|
|
|
|
|
* @note Sets protection to PS_PROTECTED_TYPE::None
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool UnprotectProcess(DWORD pid) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Name-based Protection Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Protect process by name with pattern matching
|
|
|
|
|
* @param processName Process name or pattern
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @return true if protection applied to matching processes
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ProtectProcessByName(const std::wstring& processName, const std::wstring& protectionLevel, const std::wstring& signerType) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unprotect process by name
|
|
|
|
|
* @param processName Process name or pattern
|
|
|
|
|
* @return true if protection removed from matching processes
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool UnprotectProcessByName(const std::wstring& processName) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set protection by name (force operation)
|
|
|
|
|
* @param processName Process name or pattern
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @return true if protection set on matching processes
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool SetProcessProtectionByName(const std::wstring& processName, const std::wstring& protectionLevel, const std::wstring& signerType) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Signer-based Batch Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unprotect all processes with specific signer
|
|
|
|
|
* @param signerName Signer type name
|
|
|
|
|
* @return true if all matching processes unprotected
|
|
|
|
|
* @note Saves operation to session manager for restoration
|
|
|
|
|
*/
|
2025-10-04 22:05:44 +02:00
|
|
|
bool UnprotectBySigner(const std::wstring& signerName) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief List all processes with specific signer
|
|
|
|
|
* @param signerName Signer type name
|
|
|
|
|
* @return true if listing successful
|
|
|
|
|
*/
|
2025-10-04 22:05:44 +02:00
|
|
|
bool ListProcessesBySigner(const std::wstring& signerName) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Change protection for all processes with specific signer
|
|
|
|
|
* @param currentSigner Current signer type to match
|
|
|
|
|
* @param level New protection level
|
|
|
|
|
* @param newSigner New signer type
|
|
|
|
|
* @return true if protection changed successfully
|
|
|
|
|
*/
|
2025-10-04 22:05:44 +02:00
|
|
|
bool SetProtectionBySigner(const std::wstring& currentSigner,
|
|
|
|
|
const std::wstring& level,
|
|
|
|
|
const std::wstring& newSigner) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Session State Restoration ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Restore protection for specific signer group from session
|
|
|
|
|
* @param signerName Signer type to restore
|
|
|
|
|
* @return true if restoration successful
|
|
|
|
|
* @note Uses session manager for state tracking
|
|
|
|
|
*/
|
2025-10-02 01:08:10 +02:00
|
|
|
bool RestoreProtectionBySigner(const std::wstring& signerName) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Restore all saved protection states
|
|
|
|
|
* @return true if all restorations successful
|
|
|
|
|
*/
|
2025-10-02 01:08:10 +02:00
|
|
|
bool RestoreAllProtection() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Display session history and statistics
|
|
|
|
|
*/
|
2025-10-02 01:08:10 +02:00
|
|
|
void ShowSessionHistory() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @brief Set process protection using kernel address
|
|
|
|
|
* @param addr Kernel EPROCESS address
|
|
|
|
|
* @param protection Combined protection byte
|
|
|
|
|
* @return true if protection set successfully
|
|
|
|
|
*/
|
2025-10-02 01:08:10 +02:00
|
|
|
bool SetProcessProtection(ULONG_PTR addr, UCHAR protection) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
SessionManager m_sessionMgr; ///< Session manager for state tracking
|
2025-09-25 03:00:24 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Batch Process Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unprotect all protected processes
|
|
|
|
|
* @return true if all processes unprotected
|
|
|
|
|
* @warning This affects all protected processes on system
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool UnprotectAllProcesses() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unprotect multiple processes by target list
|
|
|
|
|
* @param targets Vector of process targets (PIDs or names)
|
|
|
|
|
* @return true if all targets processed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool UnprotectMultipleProcesses(const std::vector<std::wstring>& targets) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Protect multiple processes with specified parameters
|
|
|
|
|
* @param targets Vector of process targets
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @return true if all targets protected successfully
|
|
|
|
|
*/
|
2025-10-03 09:46:50 +02:00
|
|
|
bool ProtectMultipleProcesses(const std::vector<std::wstring>& targets,
|
|
|
|
|
const std::wstring& protectionLevel,
|
|
|
|
|
const std::wstring& signerType) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set protection for multiple processes (force)
|
|
|
|
|
* @param targets Vector of process targets
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @return true if all targets processed successfully
|
|
|
|
|
*/
|
2025-10-03 09:46:50 +02:00
|
|
|
bool SetMultipleProcessesProtection(const std::vector<std::wstring>& targets,
|
|
|
|
|
const std::wstring& protectionLevel,
|
|
|
|
|
const std::wstring& signerType) noexcept;
|
2025-09-23 22:13:43 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Process Termination ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Terminate multiple processes by PID
|
|
|
|
|
* @param pids Vector of process IDs to terminate
|
|
|
|
|
* @return true if all processes terminated successfully
|
|
|
|
|
* @note Uses protection-aware termination
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
bool KillMultipleProcesses(const std::vector<DWORD>& pids) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Terminate multiple processes by target list
|
|
|
|
|
* @param targets Vector of process targets (PIDs or names)
|
|
|
|
|
* @return true if all targets terminated successfully
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
bool KillMultipleTargets(const std::vector<std::wstring>& targets) noexcept;
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @brief Terminate process with driver support
|
|
|
|
|
* @param pid Process ID to terminate
|
|
|
|
|
* @return true if process terminated successfully
|
|
|
|
|
* @note Uses protection-aware termination
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
bool KillProcess(DWORD pid) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Terminate process by name
|
|
|
|
|
* @param processName Process name or pattern
|
|
|
|
|
* @return true if matching processes terminated
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
bool KillProcessByName(const std::wstring& processName) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Kernel Process Access ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get kernel EPROCESS address for process
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @return Kernel address or nullopt if not found
|
|
|
|
|
* @note Uses cached addresses for performance
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
std::optional<ULONG_PTR> GetProcessKernelAddress(DWORD pid) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get process protection level from kernel address
|
|
|
|
|
* @param kernelAddress EPROCESS address in kernel space
|
|
|
|
|
* @return Protection byte or nullopt on failure
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
std::optional<UCHAR> GetProcessProtection(ULONG_PTR kernelAddress) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get complete process list with kernel information
|
|
|
|
|
* @return Vector of process entries
|
|
|
|
|
* @note Uses driver for kernel space access
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
std::vector<ProcessEntry> GetProcessList() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Self-Protection Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Apply protection to current process
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @return true if self-protection successful
|
|
|
|
|
* @note Used for privilege escalation and stealth
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
bool SelfProtect(const std::wstring& protectionLevel, const std::wstring& signerType) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Resolve process name without driver dependency
|
|
|
|
|
* @param processName Process name to resolve
|
|
|
|
|
* @return Process match information or nullopt
|
|
|
|
|
* @note Fallback method when driver is unavailable
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
std::optional<ProcessMatch> ResolveNameWithoutDriver(const std::wstring& processName) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === DPAPI Password Extraction ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extract and display passwords from all sources
|
|
|
|
|
* @param outputPath Output directory for reports
|
|
|
|
|
* @return true if extraction completed
|
|
|
|
|
* @note Extracts Chrome, Edge, and WiFi credentials
|
|
|
|
|
* @note Generates HTML and TXT reports
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ShowPasswords(const std::wstring& outputPath) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Export browser data for specific browser
|
|
|
|
|
* @param outputPath Output directory
|
|
|
|
|
* @param browserType Browser type ("chrome", "edge")
|
|
|
|
|
* @return true if export successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ExportBrowserData(const std::wstring& outputPath, const std::wstring& browserType) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === System Integration ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Execute command with TrustedInstaller privileges
|
|
|
|
|
* @param commandLine Command to execute
|
|
|
|
|
* @return true if execution successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RunAsTrustedInstaller(const std::wstring& commandLine);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Execute command with TrustedInstaller privileges (silent)
|
|
|
|
|
* @param command Command to execute
|
|
|
|
|
* @return true if execution successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RunAsTrustedInstallerSilent(const std::wstring& command);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add context menu entries to Windows Explorer
|
|
|
|
|
* @return true if entries added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddContextMenuEntries();
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Legacy Defender Exclusion Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add current executable to Defender exclusions
|
|
|
|
|
* @param customPath Custom path to exclude (empty = current executable)
|
|
|
|
|
* @return true if exclusion added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddToDefenderExclusions(const std::wstring& customPath = L"");
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove current executable from Defender exclusions
|
|
|
|
|
* @param customPath Custom path to remove (empty = current executable)
|
|
|
|
|
* @return true if exclusion removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemoveFromDefenderExclusions(const std::wstring& customPath = L"");
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Enhanced Defender Exclusion Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add Defender exclusion by type
|
|
|
|
|
* @param type Exclusion type
|
|
|
|
|
* @param value Value to exclude
|
|
|
|
|
* @return true if exclusion added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddDefenderExclusion(TrustedInstallerIntegrator::ExclusionType type, const std::wstring& value);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove Defender exclusion by type
|
|
|
|
|
* @param type Exclusion type
|
|
|
|
|
* @param value Value to remove
|
|
|
|
|
* @return true if exclusion removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemoveDefenderExclusion(TrustedInstallerIntegrator::ExclusionType type, const std::wstring& value);
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Type-specific Exclusion Convenience Methods ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add file extension exclusion
|
|
|
|
|
* @param extension Extension to exclude (e.g., ".exe")
|
|
|
|
|
* @return true if exclusion added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddExtensionExclusion(const std::wstring& extension);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove file extension exclusion
|
|
|
|
|
* @param extension Extension to remove
|
|
|
|
|
* @return true if exclusion removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemoveExtensionExclusion(const std::wstring& extension);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add IP address exclusion
|
|
|
|
|
* @param ipAddress IP address to exclude
|
|
|
|
|
* @return true if exclusion added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddIpAddressExclusion(const std::wstring& ipAddress);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove IP address exclusion
|
|
|
|
|
* @param ipAddress IP address to remove
|
|
|
|
|
* @return true if exclusion removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemoveIpAddressExclusion(const std::wstring& ipAddress);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add process exclusion
|
|
|
|
|
* @param processName Process name to exclude
|
|
|
|
|
* @return true if exclusion added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddProcessExclusion(const std::wstring& processName);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove process exclusion
|
|
|
|
|
* @param processName Process name to remove
|
|
|
|
|
* @return true if exclusion removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemoveProcessExclusion(const std::wstring& processName);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add path exclusion
|
|
|
|
|
* @param path Path to exclude
|
|
|
|
|
* @return true if exclusion added successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool AddPathExclusion(const std::wstring& path);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove path exclusion
|
|
|
|
|
* @param path Path to remove
|
|
|
|
|
* @return true if exclusion removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemovePathExclusion(const std::wstring& path);
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === System Administration ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Clear all Windows event logs
|
|
|
|
|
* @return true if logs cleared successfully
|
|
|
|
|
* @note Requires administrative privileges
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ClearSystemEventLogs() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Legacy Driver Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Install kernel driver from embedded resource
|
|
|
|
|
* @return true if driver installed successfully
|
|
|
|
|
* @note Extracts driver from steganographic icon resource
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool InstallDriver() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Uninstall kernel driver and remove files
|
|
|
|
|
* @return true if driver uninstalled successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool UninstallDriver() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Start driver service (interactive)
|
|
|
|
|
* @return true if service started
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool StartDriverService() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Stop driver service
|
|
|
|
|
* @return true if service stopped
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool StopDriverService() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Start driver service silently
|
|
|
|
|
* @return true if service started
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool StartDriverServiceSilent() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extract encrypted driver from resources
|
|
|
|
|
* @return Encrypted driver data
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::vector<BYTE> ExtractEncryptedDriver() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Decrypt driver data using XOR cipher
|
|
|
|
|
* @param encryptedData Encrypted driver data
|
|
|
|
|
* @return Decrypted driver data
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::vector<BYTE> DecryptDriver(const std::vector<BYTE>& encryptedData) noexcept;
|
2025-09-25 12:44:29 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Emergency Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Perform atomic cleanup of temporary files and services
|
|
|
|
|
* @return true if cleanup successful
|
|
|
|
|
* @note Emergency method for recovering from failed operations
|
|
|
|
|
*/
|
2025-09-25 12:44:29 +02:00
|
|
|
bool PerformAtomicCleanup() noexcept;
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Backdoor Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Install sticky keys backdoor
|
|
|
|
|
* @return true if backdoor installed successfully
|
|
|
|
|
* @warning Security risk - only for authorized testing
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool InstallStickyKeysBackdoor() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove sticky keys backdoor
|
|
|
|
|
* @return true if backdoor removed successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RemoveStickyKeysBackdoor() noexcept;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Core components
|
2025-10-05 12:43:36 +02:00
|
|
|
TrustedInstallerIntegrator m_trustedInstaller; ///< TrustedInstaller integration component
|
|
|
|
|
std::unique_ptr<kvc> m_rtc; ///< Kernel driver communication interface
|
|
|
|
|
std::unique_ptr<OffsetFinder> m_of; ///< Kernel offset finder
|
2025-10-15 01:15:59 +02:00
|
|
|
std::unique_ptr<DSEBypass> m_dseBypass; ///< Kernel code signing enforcement bypass
|
2025-10-05 12:43:36 +02:00
|
|
|
SQLiteAPI m_sqlite; ///< SQLite API for browser database operations
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Privilege and System Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Enable debug privilege for process manipulation
|
|
|
|
|
* @return true if privilege enabled successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool EnableDebugPrivilege() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @brief Write file with TrustedInstaller privileges
|
|
|
|
|
* @param filePath File path to write
|
|
|
|
|
* @param data Data to write
|
|
|
|
|
* @return true if write successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool WriteFileWithPrivileges(const std::wstring& filePath, const std::vector<BYTE>& data) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Binary Processing ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Split combined PE binary into components
|
|
|
|
|
* @param combinedData Combined binary data
|
|
|
|
|
* @param kvcPassData Output for kvc_pass.exe data
|
|
|
|
|
* @param kvcCryptData Output for kvc_crypt.dll data
|
|
|
|
|
* @return true if splitting successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool SplitCombinedPE(const std::vector<BYTE>& combinedData,
|
|
|
|
|
std::vector<BYTE>& kvcPassData,
|
|
|
|
|
std::vector<BYTE>& kvcCryptData) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Atomic Driver Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Force remove driver service
|
|
|
|
|
* @return true if service removed successfully
|
|
|
|
|
*/
|
2025-09-18 23:42:08 +02:00
|
|
|
bool ForceRemoveService() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Ensure driver is available and loaded
|
|
|
|
|
* @return true if driver ready for operations
|
|
|
|
|
*/
|
2025-09-23 01:38:42 +02:00
|
|
|
bool EnsureDriverAvailable() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Check if driver is currently loaded
|
|
|
|
|
* @return true if driver service is running
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool IsDriverCurrentlyLoaded() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Perform atomic driver initialization
|
|
|
|
|
* @return true if initialization successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool PerformAtomicInit() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Perform atomic init with error cleanup
|
|
|
|
|
* @return true if initialization successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool PerformAtomicInitWithErrorCleanup() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Silent Driver Installation ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Install driver silently without user interaction
|
|
|
|
|
* @return true if silent installation successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool InstallDriverSilently() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Register driver service silently
|
|
|
|
|
* @param driverPath Path to driver file
|
|
|
|
|
* @return true if service registered successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool RegisterDriverServiceSilent(const std::wstring& driverPath) noexcept;
|
2025-09-23 22:13:43 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Driver Session Management ===
|
|
|
|
|
|
|
|
|
|
bool m_driverSessionActive = false; ///< Driver session active flag
|
|
|
|
|
std::chrono::steady_clock::time_point m_lastDriverUsage; ///< Last driver usage timestamp
|
2025-09-23 22:13:43 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
/**
|
|
|
|
|
* @brief Begin driver session
|
|
|
|
|
* @return true if session started successfully
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
bool BeginDriverSession();
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Check if service is in zombie state
|
|
|
|
|
* @return true if service exists but not responding
|
|
|
|
|
*/
|
2025-10-04 22:05:44 +02:00
|
|
|
bool IsServiceZombie() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief End driver session
|
|
|
|
|
* @param force Force session end without cleanup
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
void EndDriverSession(bool force = false);
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Update driver usage timestamp
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
void UpdateDriverUsageTimestamp();
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Cache Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Refresh kernel address cache
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
void RefreshKernelAddressCache();
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get cached kernel address for process
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @return Cached kernel address or nullopt
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
std::optional<ULONG_PTR> GetCachedKernelAddress(DWORD pid);
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Internal Process Termination ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Internal process termination implementation
|
|
|
|
|
* @param pid Process ID to terminate
|
|
|
|
|
* @param batchOperation True if part of batch operation
|
|
|
|
|
* @return true if termination successful
|
|
|
|
|
*/
|
2025-09-23 22:13:43 +02:00
|
|
|
bool KillProcessInternal(DWORD pid, bool batchOperation = false) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Kernel Address Cache ===
|
2025-09-23 22:13:43 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
std::unordered_map<DWORD, ULONG_PTR> m_kernelAddressCache; ///< Kernel address cache for processes
|
|
|
|
|
std::chrono::steady_clock::time_point m_cacheTimestamp; ///< Cache timestamp for invalidation
|
|
|
|
|
|
|
|
|
|
// === Process List Cache ===
|
|
|
|
|
|
|
|
|
|
std::vector<ProcessEntry> m_cachedProcessList; ///< Cached process list
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Internal Kernel Process Management ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get initial system process address
|
|
|
|
|
* @return System process address or nullopt
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::optional<ULONG_PTR> GetInitialSystemProcessAddress() noexcept;
|
2025-10-02 01:08:10 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Process Pattern Matching ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Find processes by name pattern
|
|
|
|
|
* @param pattern Process name pattern
|
|
|
|
|
* @return Vector of matching processes
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::vector<ProcessMatch> FindProcessesByName(const std::wstring& pattern) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Check if process name matches pattern
|
|
|
|
|
* @param processName Process name to check
|
|
|
|
|
* @param pattern Pattern to match against
|
|
|
|
|
* @return true if name matches pattern
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool IsPatternMatch(const std::wstring& processName, const std::wstring& pattern) noexcept;
|
2025-10-03 09:46:50 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Internal Batch Operation Helpers ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Internal process protection implementation
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @param batchOperation True if part of batch operation
|
|
|
|
|
* @return true if protection successful
|
|
|
|
|
*/
|
2025-10-03 09:46:50 +02:00
|
|
|
bool ProtectProcessInternal(DWORD pid, const std::wstring& protectionLevel,
|
|
|
|
|
const std::wstring& signerType, bool batchOperation) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Internal set protection implementation
|
|
|
|
|
* @param pid Process ID
|
|
|
|
|
* @param protectionLevel Protection level string
|
|
|
|
|
* @param signerType Signer type string
|
|
|
|
|
* @param batchOperation True if part of batch operation
|
|
|
|
|
* @return true if protection set successfully
|
|
|
|
|
*/
|
2025-10-03 09:46:50 +02:00
|
|
|
bool SetProcessProtectionInternal(DWORD pid, const std::wstring& protectionLevel,
|
|
|
|
|
const std::wstring& signerType, bool batchOperation) noexcept;
|
2025-09-17 21:46:05 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Memory Dumping ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Create minidump of process memory
|
|
|
|
|
* @param pid Process ID to dump
|
|
|
|
|
* @param outputPath Output file path
|
|
|
|
|
* @return true if dump created successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool CreateMiniDump(DWORD pid, const std::wstring& outputPath) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set current process protection level
|
|
|
|
|
* @param protection Protection byte to set
|
|
|
|
|
* @return true if protection set successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool SetCurrentProcessProtection(UCHAR protection) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === DPAPI Extraction Lifecycle ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Initialize password extraction components
|
|
|
|
|
* @return true if initialization successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool PerformPasswordExtractionInit() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Cleanup password extraction resources
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
void PerformPasswordExtractionCleanup() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Registry Master Key Extraction ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extract registry master keys with TrustedInstaller
|
|
|
|
|
* @param masterKeys Output vector for master keys
|
|
|
|
|
* @return true if extraction successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ExtractRegistryMasterKeys(std::vector<RegistryMasterKey>& masterKeys) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extract LSA secrets via TrustedInstaller
|
|
|
|
|
* @param masterKeys Output vector for master keys
|
|
|
|
|
* @return true if extraction successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ExtractLSASecretsViaTrustedInstaller(std::vector<RegistryMasterKey>& masterKeys) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Parse registry file for secrets
|
|
|
|
|
* @param regFilePath Registry file path
|
|
|
|
|
* @param masterKeys Output vector for master keys
|
|
|
|
|
* @return true if parsing successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ParseRegFileForSecrets(const std::wstring& regFilePath, std::vector<RegistryMasterKey>& masterKeys) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert hex string to byte vector
|
|
|
|
|
* @param hexString Hex string to convert
|
|
|
|
|
* @param bytes Output byte vector
|
|
|
|
|
* @return true if conversion successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ConvertHexStringToBytes(const std::wstring& hexString, std::vector<BYTE>& bytes) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Registry Master Key Processing ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Process registry master keys for display
|
|
|
|
|
* @param masterKeys Master keys to process
|
|
|
|
|
* @return true if processing successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ProcessRegistryMasterKeys(std::vector<RegistryMasterKey>& masterKeys) noexcept;
|
2025-10-04 22:05:44 +02:00
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Browser Password Processing ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Process browser passwords with AES-GCM decryption
|
|
|
|
|
* @param masterKeys Registry master keys for decryption
|
|
|
|
|
* @param results Output vector for password results
|
|
|
|
|
* @param outputPath Output directory for reports
|
|
|
|
|
* @return true if processing successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ProcessBrowserPasswords(const std::vector<RegistryMasterKey>& masterKeys, std::vector<PasswordResult>& results, const std::wstring& outputPath) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Process single browser instance
|
|
|
|
|
* @param browserPath Browser data path
|
|
|
|
|
* @param browserName Browser name
|
|
|
|
|
* @param masterKeys Registry master keys
|
|
|
|
|
* @param results Output vector for results
|
|
|
|
|
* @param outputPath Output directory
|
|
|
|
|
* @return true if processing successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ProcessSingleBrowser(const std::wstring& browserPath, const std::wstring& browserName, const std::vector<RegistryMasterKey>& masterKeys, std::vector<PasswordResult>& results, const std::wstring& outputPath) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extract browser master key
|
|
|
|
|
* @param browserPath Browser data path
|
|
|
|
|
* @param browserName Browser name
|
|
|
|
|
* @param masterKeys Registry master keys
|
|
|
|
|
* @param decryptedKey Output decrypted key
|
|
|
|
|
* @return true if extraction successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ExtractBrowserMasterKey(const std::wstring& browserPath, const std::wstring& browserName, const std::vector<RegistryMasterKey>& masterKeys, std::vector<BYTE>& decryptedKey) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Process login database
|
|
|
|
|
* @param loginDataPath Login database path
|
|
|
|
|
* @param browserName Browser name
|
|
|
|
|
* @param profileName Profile name
|
|
|
|
|
* @param masterKey Decrypted master key
|
|
|
|
|
* @param results Output vector for results
|
|
|
|
|
* @param outputPath Output directory
|
|
|
|
|
* @return Number of passwords processed
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
int ProcessLoginDatabase(const std::wstring& loginDataPath, const std::wstring& browserName, const std::wstring& profileName, const std::vector<BYTE>& masterKey, std::vector<PasswordResult>& results, const std::wstring& outputPath) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === WiFi Credential Extraction ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extract WiFi credentials via netsh
|
|
|
|
|
* @param results Output vector for results
|
|
|
|
|
* @return true if extraction successful
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool ExtractWiFiCredentials(std::vector<PasswordResult>& results) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === SQLite Database Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Load SQLite library dynamically
|
|
|
|
|
* @return true if library loaded successfully
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
bool LoadSQLiteLibrary() noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unload SQLite library
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
void UnloadSQLiteLibrary() noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Cryptographic Operations ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Decrypt data using DPAPI with master keys
|
|
|
|
|
* @param encryptedData Data to decrypt
|
|
|
|
|
* @param masterKeys Registry master keys
|
|
|
|
|
* @return Decrypted data or empty on failure
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::vector<BYTE> DecryptWithDPAPI(const std::vector<BYTE>& encryptedData, const std::vector<RegistryMasterKey>& masterKeys) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Decrypt Chrome AES-GCM encrypted data
|
|
|
|
|
* @param encryptedData Encrypted data to decrypt
|
|
|
|
|
* @param key AES decryption key
|
|
|
|
|
* @return Decrypted string or empty on failure
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::string DecryptChromeAESGCM(const std::vector<BYTE>& encryptedData, const std::vector<BYTE>& key) noexcept;
|
|
|
|
|
|
2025-10-05 12:43:36 +02:00
|
|
|
// === Process Name Resolution ===
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Resolve process name with driver-free options
|
|
|
|
|
* @param processName Process name to resolve
|
|
|
|
|
* @return Process match or nullopt
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::optional<ProcessMatch> ResolveProcessName(const std::wstring& processName) noexcept;
|
2025-10-05 12:43:36 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Find processes by name without driver
|
|
|
|
|
* @param pattern Process name pattern
|
|
|
|
|
* @return Vector of matching processes
|
|
|
|
|
*/
|
2025-09-17 21:46:05 +02:00
|
|
|
std::vector<ProcessMatch> FindProcessesByNameWithoutDriver(const std::wstring& pattern) noexcept;
|
|
|
|
|
};
|