三个nop的玄机

2014-2-10 Nie.Meining Debug

最近百度卫士宣传力度挺大,春节在家闲来无事下载了一个看看。第一印象感觉界面简约,功能干净不臃肿,是我喜欢的风格。首先在x86环境下看看hook点:

1.png

跟360、金山卫士、QQ管家等其它主动防御一样,hook点选择了系统调用的分发函数KiSystemServiceRepeat。而且hook方式跟QQ管家很像,将mov edi, esp; cmp esi, xxx; 这两条指令替换成了三个nop和一个jmp,但是他们之间的区别是,QQ管家是先nop再jmp,百度卫士是先jmp再nop。其实这个顺序是有玄机的!(以前逆向过QQ管家,感谢sysnap大牛点拨)

我们先看看hook前的原始指令截图如下:

2.png

我们现在来考虑一个小概率的特殊情况,假如某个内核线程正好执行完图中的mov edi, esp指令(即将执行下一条指令cmp esi, xxx)时,hook操作发生了。在这种情况下,按照QQ管家的hook方式,该内核线程可以安全着陆(下一条指令变成了nop而已),但是百度卫士的hook方式可能会导致蓝屏。因此从hook安全的角度上来讲还是先nop后jmp好一些。不过这是个小概率事件。

接着看了看jmp到的地址,在bd0001.sys驱动中:

3.png

各种需要的信息压栈后,call过滤函数。过滤函数部分截图如下:

4.png

感觉跟其它主动防御的处理方式也差不多。由于曾经逆向过QQ管家(QQ电脑管家中的TsFltMgr Hook框架分析》、QQ电脑管家中的 Hook 过程分析》),这里就没再继续了。另外由于这种处理框架在现有的主动防御软件中非常流行,我曾经也自己手痒仿照这种框架完成过一个主动防御的雏形,开源放到了看雪上了:《发一个主动防御的代码》。

接下来用64位的win8系统也做了一下测试。由于PatchGuard的原因,64位主动防御目前主要采用对象钩子实现。测试的截图如下:

5.png

图中 CallbackDetect.sys 中的钩子是我的检测模块注册的假钩子;bd0001.sys 中的钩子是百度卫士注册的钩子;其它是360注册的钩子。对象钩子的检测方法可以参考我前几天写的《ObCallback 回调钩子检测》。不过该文章中有些结构逆向得不太精确,感谢FlowerCode大牛的讨论和补充,两个关键结构精确描述如下:

typedef struct _CALLBACK_BODY {
	LIST_ENTRY                  CallbackList;
	OB_OPERATION                Operations;
	ULONG                       Active;
	OB_HANDLE                   Handle;
	POBJECT_TYPE                ObjectType;
	POB_PRE_OPERATION_CALLBACK  PreOperation;
	POB_POST_OPERATION_CALLBACK PostOperation;
	EX_RUNDOWN_REF              RundownProtection;
} CALLBACK_BODY, *PCALLBACK_BODY;

typedef struct _CALLBACK_NODE {
	USHORT         Version;
	USHORT         OperationRegistrationCount;
	PVOID          RegistrationContext;
	UNICODE_STRING Altitude;
	CALLBACK_BODY  Entries[1];
} CALLBACK_NODE, *PCALLBACK_NODE;

评论:

Richardokpew
2018-08-15 19:17
drugs not to mix with viagra
http://viagrabs.com/ - buy viagra[/url]
how long will viagra keep me hard
Richardokpew
2018-08-15 19:02
best time to have viagra
http://viagrabs.com/ - viagra[/url]
how long for 50 mg viagra to work
Richardokpew
2018-08-15 18:45
viagra and sleep apnea
http://viagrabs.com/ - buy viagra[/url]
should diabetics take viagra
Richardokpew
2018-08-15 18:15
natural form of viagra
http://www.viagrabs.com/ - buy viagra online[/url]
wo bekomme viagra her
RMinmene
2018-08-15 17:07
http://sildenafilneu.com side effects of viagra https://viagrabez.com generic viagra without a doctor prescription http://viagraplc.com canadian viagra http://viagratph.com herbal viagra http://cialisviu.com cialis pills
Richardokpew
2018-08-15 16:11
can you take viagra while taking norvasc
http://viagrabs.com/ - buy viagra[/url]
if a girl takes viagra what happens
Richardokpew
2018-08-15 15:35
mekanisme kerja obat viagra
http://viagrabs.com/ - viagra online[/url]
how long will viagra keep me hard
Richardokpew
2018-08-15 13:26
is taking expired viagra bad
http://www.viagrabs.com/ - buy viagra[/url]
viagra through medicare
RMinmene
2018-08-15 07:57
http://sildenafilneu.com viagra pills https://viagrabez.com how much does viagra cost http://viagraplc.com best place to buy viagra online http://viagratph.com viagra coupon http://cialisviu.com cialis patent expiration 2017
ivvyiaqf
2018-08-14 23:28
http://sildenafilneu.com sildenafil side effects https://viagrabez.com viagra over the counter http://viagraplc.com homemade viagra http://viagratph.com sildenafil 20 mg http://cialisviu.com is cialis covered by insurance
Richardokpew
2018-08-11 17:57
provigil and viagra
http://www.viagrabs.com/ - generic viagra[/url]
viagra heart bypass surgery
Richardokpew
2018-08-11 17:39
taking viagra and smoking weed
http://viagrabs.com/ - buy generic viagra[/url]
what is the best place to buy viagra online forum
Richardokpew
2018-08-11 17:32
what happens female viagra
http://viagrabs.com/ - viagra online[/url]
price for viagra
Richardokpew
2018-08-11 16:33
giГЎ viagra thбєЈo dЖ°б»Јc
http://www.viagrabs.com/ - generic viagra[/url]
what is a good over the counter substitute for viagra
Richardokpew
2018-08-11 16:02
viagra for women
http://viagrabs.com/ - viagra online[/url]
viagra england kaufen

发表评论:

Powered by emlog