获取内核ntoskrnl.exe基地址的几种常见办法
来源:互联网 发布:world for mac 编辑:程序博客网 时间:2024/04/27 22:44
作 者: combojiang
如果大家写过shellcode一定还记得,shellcode中开头要找kernel32.dll模块的内存加载地址。
同样,如果大家要写一个内核的类似东东的话,第一步也是要找出ntoskrnl.exe模块的内存加载位置。有三种常见办法在这里咱们大体描述下:
1。利用ZwQuerySystemInformation 来检索加载的模块,从加载模块里面搜索出ntoskrnl.exe模块。例子如:http://bbs.pediy.com/showthread.php?t=58199
在开头部分就是利用ZwQuerySystemInformation 来检所ntoskrnl.exe模块的内存加载位置。
2。通过驱动DriverEntry函数的第一个参数,即DriverObject。在DriverObject结构体中有一项
DriverSection成员指向LDR_DATA_TABLE_ENTRY结构,通过遍历这张表得到ntoskrnl的基址和大小。例子如:http://bbs.pediy.com/showthread.php?t=56042
3。通过驱动DriverEntry函数的返回地址,根据系统布局图,如下:
因此,我们可以在从80000000h开始的位置搜索ntosknrl。我们的驱动程序就是加载在系统布局图的80000000h到a0000000h的区间中。
完整代码如下:
.386
.model flat, stdcall
option casemap:none
include GetKernelBase.inc
.code
GetKernelBase proc uses esi edi ebx dwSomewhereInKernel:DWORD
xor edi, edi ; assume error
mov eax, MmSystemRangeStart
mov eax, [eax]
mov eax, [eax] ; eax = 80000000h
; #define PAGE_SHIFT 12
; #define PAGE_SIZE (1UL << PAGE_SHIFT) 4k为单位
.if dwSomewhereInKernel >= eax
mov esi, dwSomewhereInKernel
and esi, not (PAGE_SIZE-1) ; start down-search from here
mov ebx, esi
sub ebx, eax ; - MmSystemRangeStart
shr ebx, PAGE_SHIFT ; Number of pages to search
.while ebx
invoke MmIsAddressValid, esi
.break .if al == FALSE ; bad
mov eax, [esi]
.if eax == 00905A4Dh ; MZ signature
mov edi, esi
.break
.endif
sub esi, PAGE_SIZE ; next page down
dec ebx ; next page
.endw
.endif
mov eax, edi
ret
GetKernelBase endp
DriverEntry proc pDriverObject:PDRIVER_OBJECT,pusRegistryPath:PUNICODE_STRING
lea ecx, [ebp][4] ; 得到DriverEntry返回地址
push ecx
invoke MmIsAddressValid, ecx
pop ecx
.if al
mov ecx, [ecx] ; Get return address from stack
invoke GetKernelBase, ecx
.if eax != 0
invoke DbgPrint, $CTA0("GetKernelBase: ntoskrnl.exe base = %08X/n"), eax
.else
invoke DbgPrint, $CTA0("GetKernelBase: Couldn't find ntoskrnl.exe base/n")
.endif
.endif
mov eax, STATUS_DEVICE_CONFIGURATION_ERROR
ret
DriverEntry endp
end DriverEntry
- 获取内核ntoskrnl.exe基地址的几种常见办法
- 获取内核ntoskrnl.exe基地址的几种常见办法
- 【总结】获取内核ntoskrnl.exe基地址的几种常见办法
- 获取内核ntoskrnl.exe基地址的几种常见办法
- 获取内核ntoskrnl.exe句柄地址的一段vc代码
- 获取Kernel32基地址的几种方法
- 获取Kernel32基地址的几种方法
- 获取Kernel32基地址的几种方法
- 获取Kernel32基地址的几种方法-相关结构
- 获取ntkrnlpa.exe基地址
- 获取操作系统内核基地址
- 获取ntoskrnl的基址
- 修改ntoskrnl.exe的方法
- 从KPCR中获取内核基地址
- 获得kernel32基地址的通用办法
- 获取字符串长度的几种办法
- ntoskrnl.exe损坏或丢失的解决方案
- 几种常见浏览器的内核分析
- JSP中文乱码问题
- 部署EAR企业应用程序时需要考虑的问题
- 实现HTTP处理程序
- 脱离光驱装系统
- 数据库事务和锁
- 获取内核ntoskrnl.exe基地址的几种常见办法
- 了凡四训
- 注册表导致VS2008切换设计视图假死
- 的 元素
- Linux下无法mount本机IP的解决方法:
- 完整可编译NT4's NTFS源码(可稳定替换xp原版ntfs.sys)
- 电信增值业务学习笔记2--移动网络基本概念和组网结构
- 转载-让ObjectARX向导跟Visual Studio Express Editor合作
- CE5.0 - eboot烧写NK.nb0的详细流程