Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1172978
  • 博文数量: 272
  • 博客积分: 3899
  • 博客等级: 中校
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-15 14:53
文章分类

全部博文(272)

文章存档

2012年(272)

分类: 网络与安全

2012-06-26 11:11:13

今天SWIblog上发了篇新文章,阐述了一个在微软新的OS中加入安全功能:SEHOP

http://blogs.technet.com/swi/archive/2009/02/02/preventing-the-exploitation-of-seh-overwrites-with-sehop.aspx

全名是:Structured Exception Handler Overwrite Protection

从名字看,就知道是为了对抗覆盖SEH这种攻击。

这个新功能在 Windows Server 2008 以及 Vista SP1 中加入,2008中默认开启,Vista SP1 中默认关闭,因为还需要实践的检验。

覆盖SEH是一种在/GS的保护出来以后,无法覆盖函数返回地址时,攻击者常用的技巧。以前我在写很多EXP的时候都使用了这种技巧。

微软后来出来了一种保护,在新版本 Visual Studio 进行link的时候多了一个 /safeseh 的选项。但是/safeseh 的保护原理是基于2进制文件里的一个元数据(metadata),所以在很多时候还能够通过跳转到内存中某些地方(比如没有保护的dll里)成功实施攻击。

幻影的void以前专门写了篇blog讲这个问题:(被和谐了,需要穿墙访问)

http://pstgroup.blogspot.com/2007/08/tipssafeseh.html

所以,SEHOP/safeseh的保护最大的区别就在于,SEHOP的保护是系统级别的,将更难绕过去。

其保护原理是插入一个硬地址(symbolic exception registration record)到SEH链的末尾,这样通常覆盖SEH后,为了稳定溢出而使用的payload(通常都是把shellcode或者是egghunter写在栈中,紧跟seh handler之后),就会破坏掉SEH链,从而导致SEH链找不到末尾的地址,系统就会认为SEH被覆盖了,从而终止掉进程。

这个过程用原文的话表述就是:

From an implementation perspective, SEHOP achieves this functionality in two distinct steps. The first step involves the insertion of a symbolic exception registration record as the tail record in a thread’s exception handler list. This step occurs when a thread first begins executing in user mode. Since exception registration records are always inserted at the head of the exception handler list, the symbolic record is guaranteed to be the final exception registration record.

The second step consists of walking the exception handler list at the time that an exception is being dispatched to ensure that the symbolic record can be reached and that it is valid. This step happens when the exception dispatcher is notified that an exception has occurred in user mode. If the symbolic record cannot be reached, the exception dispatcher can assume that the exception handler list is corrupt and that an SEH overwrite may have occurred. The exception dispatcher is then able to safely terminate the process. If the symbolic record is found, the exception dispatcher is able to proceed as it normally would and call each of the registered exception handlers. 


所以,覆盖SEH的方法在未来将会越来越难以利用了。当然也并非完全不可能,如果能事先通过内存信息泄露(infomation disclosure)之类的漏洞获取这个地址,则还是有可能攻击成功的。

微软在系统层面是做了非常多的工作,从战略上来说,在平台上使用的是对抗exploit技术的思想,所以有了DEPASLR/GS、以及今天的SEHOP

阅读(1912) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~