windows10驱动 x64--- 驱动实现隐藏驱动模块(五)

本文介绍了如何在Windows驱动程序中实现驱动模块的隐藏,通过遍历LDR_DATA_TABLE_ENTRY结构体的双链表,修改链接字段来达到隐藏指定驱动的目的。在驱动加载前后对比,展示了驱动隐藏的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

驱动实现隐藏驱动模块(五)

原理

每个驱动DriverObject->DriverSection存着个结构体LDR_DATA_TABLE_ENTRY
{
LIST_ENTRY InLoadOrderLinks;
LIST_ENTRY InMemoryOrderLinks;
LIST_ENTRY InInitializationOrderLinks;
PVOID DllBase;
PVOID EntryPoint;
ULONG64 SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
}
双链表遍历前面已经文章已经很多次了

驱动代码 — 0环

#include "ntifs.h"
#include<wdm.h>

//extern PEPROCESS PsInitialSystemProcess;
NTSTATUS DriverUnload(PDRIVER_OBJECT DriverObject)
{
	DbgPrint("Driver Exit \r\n");
	return STATUS_SUCCESS;

}
typedef struct LDR_DATA_TABLE_ENTRY
{
	LIST_ENTRY InLoadOrderLinks;
	LIST_ENTRY InMemoryOrderLinks; 
	LIST_ENTRY InInitializationOrderLinks;
	PVOID DllBase;
	PVOID EntryPoint;
	ULONG64 SizeOfImage;
	UNICODE_STRING FullDllName;
	UNICODE_STRING BaseDllName;

}DriverSectionObject, * pDriverSectionObject;



NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING Regedit)
{
	
	pDriverSectionObject SectionObject = (pDriverSectionObject)DriverObject->DriverSection;
	PLIST_ENTRY bmpDriverList = (PLIST_ENTRY)SectionObject->InLoadOrderLinks.Flink;

	SectionObject = (pDriverSectionObject)bmpDriverList;

	pDriverSectionObject tmpSectionObject = SectionObject;


	UNICODE_STRING UniString1;
	WCHAR* string1 = L"MyDriverHello.sys";
	RtlInitUnicodeString(&UniString1,string1);
	DbgPrint("DriverName:%wZ\n", &UniString1);

	//遍历内核驱动
	for (;;)
	{
		bmpDriverList = bmpDriverList->Flink;
		SectionObject = (pDriverSectionObject)bmpDriverList;
		DbgPrint("DriverName:%wZ\n", &SectionObject->BaseDllName);
		RtlEqualUnicodeString(&SectionObject->BaseDllName, &UniString1, TRUE);
		//相等等于1  不相等为 0 返回是char类型
		if (tmpSectionObject == SectionObject)
		{
			DbgPrint("结尾了");
			break;
		}
		if(RtlEqualUnicodeString(&SectionObject->BaseDllName,&UniString1,TRUE))

		{
		
			//内核驱动隐藏
			bmpDriverList->Flink->Blink = bmpDriverList->Blink;
			bmpDriverList->Blink->Flink = bmpDriverList->Flink;
			//过滤掉头指针 重新遍历
			bmpDriverList = bmpDriverList->Flink;
			for (;;)
			{
				bmpDriverList = bmpDriverList->Flink;
				SectionObject = (pDriverSectionObject)bmpDriverList;
				DbgPrint("DriverName:%wZ\n", &SectionObject->BaseDllName);
				RtlEqualUnicodeString(&SectionObject->BaseDllName, &UniString1, TRUE);
				if (tmpSectionObject == SectionObject)
				{
					DbgPrint("结尾了");
					break;
				}
			}
			break;

		}
	
	}





	DriverObject->DriverUnload = DriverUnload;
	return STATUS_SUCCESS;
}

总结

隐藏驱动–>MyDriverHello.sys
驱动加载前:可以看到MyDriverHello.sys
在这里插入图片描述
驱动加载后:看不到MyDriverHello.sys
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值