|
[讨论]一个关于过滤驱动的神奇问题
hips.sys的模块范围是 a21c5000 a21cc000 hips 出错地址是: hips+14e4 a21c64e4 ?? ??? 自己分析一下为什么出错了 |
|
[讨论]一个关于过滤驱动的神奇问题
自己拿Windbg分析一下啊。你自己有source,有binary,有symbol,别人什么都没有。不自己分析,拿个mini dump给别人,能看出什么东西? 以下是windbg分析的结果(摘取了重点)。 异常是Access Violation。从现状看,可能是你调用了非法的函数指针,或者栈溢出破坏了返回地址。 这是Windbg给出的推测: *** Possible invalid call from b6d4fc03 ( +0x20006e ) *** Expected target 9ef46eb0 ( +0x20006e ) 请结合下面的stack trace自己分析。你只给了一个dump,既无源代码又无符号,甚至连汇编、机器码都没有。没有什么好办法分析。 EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - 0x%08lx FAULTING_IP: hips+14e4 a21c64e4 ?? ??? eax=00000000 ebx=00000000 ecx=e81f72a8 edx=88b39180 esi=e81f72a8 edi=88b39180 eip=a21c64e4 esp=b6d4fbf0 ebp=b6d4fbf0 iopl=0 nv up ei ng nz na pe nc cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010286 LAST_CONTROL_TRANSFER: from b6d4fc08 to a21c64e4 POSSIBLE_INVALID_CONTROL_TRANSFER: from b6d4fc03 to 9ef46eb0 STACK_TEXT: 栈帧 返回地址 参数1~3 WARNING: Stack unwind information not available. Following frames may be wrong. b6d4fbec b6d4fc08 83c88747 e81f72a8 88b39180 hips+0x14e4 b6d4fbf0 83c88747 e81f72a8 88b39180 e8193f80 0xb6d4fc08 b6d4fc08 83ea9538 86fc5ac8 e8193f68 00000001 nt!IofCallDriver+0x63 b6d4fc48 83e70078 8ad32178 e8193f80 00000001 nt!IopCloseFile+0x2f3 b6d4fc94 83e92da2 8ad32178 b0c6d328 87beeae0 nt!ObpDecrementHandleCount+0x139 b6d4fcdc 83e945a2 b0c6d328 e56e41c0 8ad32178 nt!ObpCloseHandleTableEntry+0x203 b6d4fd0c 83e9471a 8ad32178 87beea01 0012f3ac nt!ObpCloseHandle+0x7f b6d4fd28 83c8f6ea 000000e0 0012f3b0 77c56194 nt!NtClose+0x4e b6d4fd28 77c56194 000000e0 0012f3b0 77c56194 nt!KiFastCallEntry+0x12a |
|
[求助]调试异常处理
自己搜索一下Windows的异常分发流程,两次通知调试器等机制吧 |
|
[原创]校园一卡通的快速破解
这么说就和那些洗衣卡电表卡差不多了,没有联网,可能存在漏洞。不过,如果干坏事的人多了,数额大了,那么财务在核算的时候还是比较容易发现的。 |
|
|
|
[求助][讨论]Mdl的疑惑
MDL创建完成后一定要Build。。。 |
|
[求助][求助]KiDebugService 究竟有些什么功能?
用ULONGLONG的话,32位就不太好了(效率,空间)。应该用ULONG_PTR。这样32位的环境自动是32位的,64位的就自动是64位的。其他的,比如说LONG -> LONG_PTR同理。 指针与整数的互相转换要用专用的,名字带_PTR后缀的类型。例如DWORD_PTR(应用程序),ULONG_PTR(应用程序,驱动)。 |
|
[求助][求助]KiDebugService 究竟有些什么功能?
这要看你怎么写的。普通的文件过滤驱动什么的可以直接重新编译了用。Hook SSDT等的不行。 另外64位系统的驱动必须有合法的数字签名,否则系统会拒绝加载。 |
|
|
|
[求助]关于系统回调 PsSetLoadImageNotifyRoutine 的时机问题。
你确定这个“Bug”一定不是由于Windows的虚存管理机制导致的?试过用.pagein命令装入页面数据么?试下!pte命令,检查一下这个地址的页面属性。 |
|
[求助]鼠标操作想到的问题
这不是一个很简单的问题,涉及到硬件和操作系统好几层。 现在鼠标应该都是USB的了吧。在USB协议中,鼠标属于HID设备,连接上电脑后,鼠标会把所有相关的操作按照USB协议的标准传输给电脑,Windows会建立相关的设备栈负责处理和鼠标设备的通讯,从最底层的USB通信编解码到最高层的各种USB请求过滤和处理。设备驱动处理完后,事件会分发给win32子系统,这个系统负责窗口管理和图形设备接口(GDI)。在这个子系统中,有一个RIT线程,负责读取设备驱动产生的原始的输入事件,然后生成消息,寄送到正确的线程消息队列中。用户态的代码就可以使用诸如GetMessage之类的函数负责处理了。 简单讲就是这样。具体细节非常复杂,一本书都未必能讲完。 |
|
ZwQuerySystemInformation调用然后调用GetLastError提示126指定的模块没有被找到是啥问题
大哥,Zw/Nt系列函数是系统调用的封装,User Mode部分实现在ntdll.dll里面 ; __stdcall NtQuerySystemInformation(x, x, x, x) public _NtQuerySystemInformation@16 _NtQuerySystemInformation@16 proc near mov eax, 0ADh ; NtQuerySystemInformation ; RtlGetNativeSystemInformation mov edx, 7FFE0300h call dword ptr [edx] retn 10h _NtQuerySystemInformation@16 endp 你看看,哪里来的LastError?你又没调用RtlNtStatusToDosError。 它的返回值是NTSTATUS,已经代表了成功和失败的状态信息,没必要再搞个LastError来多此一举。 |
|
[求助][求助]驱动中检测是否运行在虚拟机中的方法
1 似乎有VT的情况下检查不出来 4 不知道rtdsc时间差可以不可以 有时猥琐法检查效果比较好 虚拟化是趋势,各种云计算神马的,以后会有越来越多的应用跑在虚拟机上,因此检测虚拟机的意义会越来越小。 |
|
[求助]WIN7 64位下劫持如何做转向?
手工实现吧。或者自己写一个分析dll的工具。 |
|
[讨论]成员函数thiscall的堆栈是调用者还是被调用者来平衡
VC产生的代码才是这样的。其他编译器不保证也会产生这种代码。 另外不定参数的函数是调用者来平衡,还有就是可以显式指定成员函数的调用约定,如果指明了调用约定,那就会采用指明的约定而不是thiscall。 |
|
[原创]逆向beep.sys--异步处理IRP举例 (xp3 )
回家的路上想明白了,XP的beep驱动这样写是没问题的。这个的解释涉及2个标志以及3次锁操作,以及几个API的内部逻辑,非常复杂,我就不避细节了,正好可以给不了解相关内容的朋友参考参考。这里不得不再抱怨一下Legacy的驱动框架,表面上API封装得相当光鲜,用起来就知道陷阱和问题数不胜数。 如果没有耐心看长篇解释,请直接跳到本贴的末尾看蓝字部分。如果看不明白,请回来慢慢看解释。 首先我们需要回顾一下IRP的处理过程。我们都知道,如果IRP不能马上完成,那么通常的选择是采取异步处理机制。在派遣例程中,我们将IRP置为Pending,返回STATUS_PENDING以告诉调用者这个IRP会在将来的某时候完成。随后在某个时候我们调用IoStartPacket以将这个IRP排队或者开始处理。 IoStartPacket做的事情,概括讲就是(省略部分细节,如Cancel标志的检查),首先尝试将IRP排队,如果设备忙,则IRP进入队列,否则置该IRP为当前IRP(DeviceObject->CurrentIrp)并调用驱动的StartIo例程开始处理。 当一个IRP处理完成后,我们通常需要在合适的时候调用IoStartNextPacket以处理下一个IRP,它和IoStartPacket的区别是,它是从队列中取出已有的IRP,置IRP为当前IRP,然后交由StartIo例程进行处理,而不像StartPacket那样是处理新来的IRP。 我们最后再看看IoCancelIrp做的事情,简单讲就是置IRP的Cancel标志(Irp->Cancel)然后交由Cancel例程进行处理。 上面的解释很精简,想了解细节的话,可以自行查阅WRK或者逆向ntoskrnl(有符号的情况下,F5基本和源码一样)。 由于多处理器的环境下存在同步问题,因此需要使用取消锁进行同步。这样,原本清晰的流程中就插入了若干获取锁和释放锁的逻辑。我们先回顾一下MSDN推荐的“标准”流程,具体如下: IoStartNextPacket(假定该IRP允许Cancel) 获取锁(事件A) > 清空当前IRP > 从队列中取IRP > 置当前IRP > 释放锁(事件A') > 调用StartIo例程 > StartIo获取锁(事件B) > 检查Cancel标志 > 置CancelRoutine为NULL > 释放锁(事件B') > 处理或者返回 IoCancelIrp 获取锁(事件C) > 置Cancel标志 > 置CancelRoutine为NULL > 调用Cancel例程 > Cancel例程检查IRP是否是当前IRP > 如是,则释放锁(事件C')并且调用StartNextPacket;如否,则从队列中移除该IRP并释放锁(事件C'') > 以STATUS_CANCEL完成该IRP 当调用IoCancelIrp时,IRP有两种状态: 1. 还在队列中(事件C先发生) 2. 已经从队列里面出来成为当前IRP准备处理(事件A先发生) 如是情况1,则Cancel例程先得到处理,其中必然会走事件C''分支,也就是说,从队列中移除IRP,释放锁,完成。随后StartNextPacket才得到处理,此时,已经是开始处理队列中下一个IRP了。 如果是情况2,事件A先发生,随后A'释放锁,接着C发生,CancelIrp得到锁,Cancel标志设置,Cancel例程开始处理,此时IRP已经成为当前IRP,例程中走的分支是C',也就是说,释放锁并调用StartNextPacket。锁释放后,StartIo例程再次得到控制权,但它发现Cancel标志已经设置了,因此不做进一步处理即返回。 如果CancelIrp执行太晚,以至于StartNextPacket/StartIo已经第二次得到锁了,这时IRP的处理已不可取消(CancelRoutine被置为NULL),但CancelIrp仍然会设置Cancel标志,只不过StartIo已经不管它了而已。 这是“标准”的流程。我们回到原本的问题上来:beep的IRP处理,究竟和“标准流程”有何不同呢? 答案是:“标准流程”中,即使IRP已经成为当前IRP,仍有机会Cancel;而beep的这个无疑是简化的流程,IRP的两种状态中,只有还在队列中时才能被取消,一旦出了队列,成为了当前处理的IRP,则不可取消。 细节一点,这时的处理流程是: IoStartNextPacket 获取锁(事件A) > 清空当前IRP > 从队列中取IRP > 置当前IRP > 释放锁(事件A') > 调用StartIo例程 > StartIo获取锁(事件B) > 置CancelRoutine为NULL > 释放锁(事件B') > 开始处理 IoCancelIrp 获取锁(事件C) > 置Cancel标志 > 置CancelRoutine为NULL > 调用Cancel例程 > Cancel例程检查IRP是否是当前IRP > 如是,则释放锁(事件C')并且返回(标准流程中的这个分支已经没有意义了);如否,则从队列中移除该IRP并释放锁(事件C'')并以STATUS_CANCEL完成该IRP 可见 1. 如果调用CancelIrp的时候,IRP还在队列中,则和“标准流程”相同(Cancel例程C''分支); 2. 一旦IRP出队列成为当前IRP(进入了StartIo例程),StartIo例程就根本不管Cancel标志的设置,IRP必定会由StartIo完成,同时顺便StartNextPacket。所以,标准Cancel例程中的C'分支(当IRP不在队列中,为当前IRP时,调用StartNextPacket并且完成IRP)所做的事情已经被StartIo做了,那这个分支自然就成为多余的了,因此beep的做法是直接释放取消锁并且直接返回。 |
|
[原创]逆向beep.sys--异步处理IRP举例 (xp3 )
BeepCancelRoutine似乎有问题?既不StartNextPacket又不CompleteRequest? 取消了当前的IRP就应该Start下一个吧,IRP取消了就要以STATUS_CANCEL状态完成吧。 ------------------------------------------- EDIT: 我没看下面的代码,似乎和nt4代码里的beep还是有点不同的。 |
|
|
|
[求助]程序被金山毒霸误杀
加壳不一定有用,本身壳就是重点杀的对象,何况现在还有行为分析(金山的火眼)。 |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值