阅读:1459回复:9
请教问题:函数替换
请教问题:我找到了NTDLL.DLL的地址,也把我自己的函数替换了原来的函数(ZwSetValue),可就是不管用,好像实际上没有替换,为什么,可能的原因是什么?请高手指点!
|
|
沙发#
发布于:2004-11-23 22:48
不知道,关注。
|
|
板凳#
发布于:2004-11-24 08:33
请教问题:我找到了NTDLL.DLL的地址,也把我自己的函数替换了原来的函数(ZwSetValue),可就是不管用,好像实际上没有替换,为什么,可能的原因是什么?请高手指点! 你是怎么替换的呢,替换成功了吗 |
|
|
地板#
发布于:2004-11-24 14:19
应该就是API HOOK吧,可以试试用一下Detours。
|
|
|
地下室#
发布于:2004-11-24 19:58
我是先找到NTDLL.DLL在内存中的地址,然后找到函数在其输出节中的地址,进行替换。替换应该是成功了,这种方法对替换后的新进程应该起作用,可为什么不起作用。
我已经用替换全局变量表的方法替换成功,想学习多种替换方法。 另外,对于换全局变量表中没有输出的函数,如何找到其地址进行替换。 哪位高手能提供些例子! 谢谢!!!!!!!!!!!!! |
|
5楼#
发布于:2004-11-25 00:58
1. How do you verify your hooking? tracing with Softice/WinDbg or just assume that your hook is successfully? You should debug it with softice/visual softice with MS symbol server enable to verify your hooking, set breakpoint on ZwSetValue and YourZwSetValue. In fact, Copy on write might affect your hooking, which makes your hooking will be good only in the process you run your hooking engine.
2. One useful but ugly way to hook non-export functions.(I suppose that 全局变量表 means PE export table in your post.) If the function you want to hook is not in export table, but you can retrieve symbol , then you can get an offset of this function, then looking for the close export function, and find a unique bytes pattern, like "55 8b ec ..." (push ebp; mov ebp, esp; ...). Then in your hooking engine, you'll first look for the export function, then search forward for the pattern. However, the start searching export function and the pattern need to be kept update witht the hooked PE file, a big support shortcoming for a commercial software. |
|
6楼#
发布于:2004-11-25 11:04
楼上的兄弟能否给个例子,这里先谢谢了
|
|
7楼#
发布于:2004-11-25 13:53
有些概念你必须清楚,不同于WIN9X,2X下有COW机制,虽然你可以在自己的进程里写DLL,但由于COW,你所写的地址仅对你本进程有效,而对其他进程无效.
所以你必须在驱动中,或通过CALLGATE进入RING0后先修改CR0的WP位,OS就是通过他来捕获COW异常的,然后再往相应的地址里写入你的东西即可.我测试过,写入的东西可以适用于所有的进程,完事后别忘了恢复WP位的保护. |
|
|
8楼#
发布于:2004-11-25 21:01
我是在驱动中替换了NTDLL.DLL中的函数,系统中所有进程都有它的拷贝,为什么还是不行?
Ntdll.dll函数进入核心态时要接受Kisystemservice的检查,不合法的将不起作用,是这个原因吗? 在Ntdll.dll中替换其输出函数能对系统中其它进程其作用吗? 楼上兄弟能给个简单的例子吗?谢谢!!! |
|
9楼#
发布于:2004-12-01 05:36
For example, accoding to ntoskrnl.exe 5.1.2600.1151
I want to hook MiCopyOnWrite, which is on offset 0x414e2 (in VSI), then I open this file with Depends.exe (in SDK), and find out that MmTrimAllSystemPagableMemory is on offset 0x38a56 (the next export function is ObReferenceObjectByPointer with offset 0x41d42). So startSearchFunction=MmTrimAllSystemPagableMemory BytesToSearch = 0x55 0x8b 0xec 0x83 0xec 0x24 0x53 0x56 (Must be unique in your search range) MaxBytes = 0x0x414e2 - 0x38a56 + 0x8 (BytesToSearch or more) SI>exp MmTrimAllSystemPagableMemory Address Tag Name 0x00438a56 Export MmTrimAllSystemPagableMemory SI>u 0x004414e2 +i ntoskrnl!MiCopyOnWrite 004414e2 55 push ebp 004414e3 8b ec mov ebp, esp 004414e5 83 ec 24 sub esp, 24 004414e8 53 push ebx 004414e9 56 push esi 004414ea 57 push edi |
|