首页
社区
课程
招聘
[求助]safeseh和DEP都开启了,有办法破吗
发表于: 2011-7-20 11:37 12701

[求助]safeseh和DEP都开启了,有办法破吗

2011-7-20 11:37
12701

发现一个栈溢出
是memmove函数引起的
复制可控内容到栈里,可以覆盖掉SEH,但是覆盖不了RET地址
下一段内存不可写,长度覆盖到那里可以触发异常,但是由于DEP执行保护
用CALL [EBP+N]等方法无法执行shellcode
有高手能给点指点吗?


[注意]看雪招聘,专注安全领域的专业人才平台!

收藏
免费 7
支持
分享
赞赏记录
参与人
雪币
留言
时间
Youlor
为你点赞~
2024-5-31 07:45
伟叔叔
为你点赞~
2024-5-31 01:41
心游尘世外
为你点赞~
2024-2-26 00:29
飘零丶
为你点赞~
2024-2-17 05:17
QinBeast
为你点赞~
2024-1-27 01:37
shinratensei
为你点赞~
2024-1-22 03:08
PLEBFE
为你点赞~
2023-3-7 06:28
最新回复 (20)
雪    币: 393
活跃值: (150)
能力值: (RANK:110 )
在线值:
发帖
回帖
粉丝
2
[QUOTE=举剑问天;982637]发现一个栈溢出
是memmove函数引起的
复制可控内容到栈里,可以覆盖掉SEH,但是覆盖不了RET地址
下一段内存不可写,长度覆盖到那里可以触发异常,但是由于DEP执行保护
用CALL [EBP+N]等方法无法执行shellcode
有高手能给点指点吗?[/QUOTE]

无样本,无真相。
2011-7-20 15:00
0
雪    币: 230
活跃值: (164)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
可以。 比如ROP shellcode 类似于return2lib
2011-7-20 15:42
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
ROP或ret2lib过DEP还好,但同时过safeseh的话就有点难度
在nosafeseh模块和其他区域又没找到合适的类似
pop/pop/pop esp/retn的跳板地址
请高手指点迷津
2011-7-20 16:51
0
雪    币: 678
活跃值: (101)
能力值: ( LV2,RANK:150 )
在线值:
发帖
回帖
粉丝
5
有没有使用过mona.py插件,没有去试试看。
2011-7-20 17:04
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
应该和ollyfindaddr插件用法差不多吧?我试试
2011-7-20 18:09
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
谢谢.,用了mona.py插件,貌似那个是定位溢出点的
现在能够覆盖SEH,但是覆盖不了ret地址,而我需要过safeseh+DEP,
真心求教高手指点
2011-7-21 14:14
0
雪    币: 433
活跃值: (1890)
能力值: ( LV17,RANK:1820 )
在线值:
发帖
回帖
粉丝
8
赞同wingdbg兄弟的观点!
2011-7-21 18:25
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
#######################################################################

                             Luigi Auriemma

Application:  Microsoft HTML Help
              http://www.microsoft.com
Versions:     <= 6.1
Platforms:    Windows (any version included the latest Windows 7)
Bug:          stack overflow
Date:         12 Apr 2011 (found 20 Feb 2011)
Author:       Luigi Auriemma
              e-mail: aluigi@autistici.org
              web:    aluigi.org

#######################################################################

1) Introduction
2) Bug
3) The Code
4) Fix

#######################################################################

===============
1) Introduction
===============

From http://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help:
"A CHM Help file name has a ".chm" extension. It has a set of web pages
written in a subset of HTML and a hyperlinked table of contents. CHM
format is optimized for reading, as files are heavily indexed. All
files are compressed together with LZX compression. Most CHM browsers
have the capability to display a table of contents outside of the body
text of the Help file."

#######################################################################

======
2) Bug
======

itss.dll is affected by a stack overflow caused by the copying of an
arbitrary amount of data into a stack buffer during the decompression
of the content.
The following dump comes from the Windows XP 5.2.3790.2847 version:

  65E3B12B  |. 8B87 28010000  MOV EAX,DWORD PTR DS:[EDI+128]
  65E3B131  |. 0345 0C        ADD EAX,DWORD PTR SS:[EBP+C]
  65E3B134  |. 56             PUSH ESI                  ; our custom size
  65E3B135  |. 50             PUSH EAX                  ; our source (decompressed)
  65E3B136  |. FF75 08        PUSH DWORD PTR SS:[EBP+8] ; stack destination
  65E3B139  |. E8 01CDFEFF    CALL itss.65E27E3F        ; memmove or memcpy on Windows 7

The data that will be copied in this stack buffer is just one of the
decompressed LZX chunks (0x7ffe bytes) of the files embedded in the
input chm.

For reaching the vulnerable code I have modified the two dynamic
numbers after the "/#WINDOWS" tag setting the first to 0 (a value
smaller than the original) and the second to the amount of bytes to
copy, anyway note that the function is used also in other places.

Creating the malformed file from scratch is really a joke:
- get HTML Help Workshop
  http://download.microsoft.com/download/0/a/9/0a939ef6-e31c-430f-a3df-dfae7960d564/htmlhelp.exe
- start HTML Help Workshop, create a new project and choose a name
- enable "HTML Help table of contents (.hhc)" and "HTML files (.htm)"
- select the provided test.hhc and then test.htm
- select the third button "Add/Modify window definitions", give a name
  and then OK
- select File->Compile
- open the generated chm file with a hex editor
- search the text /#WINDOWS
- go after the 0x01 byte that follows it and place the bytes 00 ff 7f

I have noticed that it's a bit chaotic to debug this vulnerability
through an user-mode debugger, anyway without it attached the code
execution is correctly reported at the specified address of the
proof-of-concept (0x41414141) and our code is referenced in various
places ([ebp-c], [ebp-4], [ebp+c] and so on).
With the debugger attached is possible to see the new EIP only if it's
higher than 0x7fffffff otherwise it's necessary to guess the correct
16bit canary (destination+0x1c8) and specifying an amount of bytes that
will not be written over the available stack (like 00 83 7f) to see it.

The provided chm_1.chm proof-of-concept contains the address where will
continue the code execution at offset 0x17 of test.gif (set to
0x41414141, you can use any value because it's binary data) and I have
placed a bindshell (w32-bind-ngs-shellcode by SkyLined) at offset 0x200
of the same image file only as reference during my tests.

The folder build_chm_1 instead contains the original files from which
has been created chm_1.chm using the steps listed above.

#######################################################################

===========
3) The Code
===========

http://aluigi.org/poc/chm_1.zip

#######################################################################

======
4) Fix
======

No fix.

#######################################################################
2011-7-22 14:41
0
雪    币: 3162
活跃值: (1314)
能力值: ( LV8,RANK:120 )
在线值:
发帖
回帖
粉丝
10
这个不晓得有没谁做出来,ROP需要一个 不兼容safeseh的模块。不过对于这个漏洞暂时还找不到这样的模块。
强制加载也不行。因为加载代码还没执行之前漏洞就触发了。
2011-7-23 13:55
0
雪    币: 411
活跃值: (262)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
11
[QUOTE=举剑问天;982637]发现一个栈溢出
是memmove函数引起的
复制可控内容到栈里,可以覆盖掉SEH,但是覆盖不了RET地址
下一段内存不可写,长度覆盖到那里可以触发异常,但是由于DEP执行保护
用CALL [EBP+N]等方法无法执行shellcode
有高手能给点指点吗?[/QUOTE]

貌似你说的全都不对,RET是都能覆盖的,但是在hhctrl.7E71EF1A函数内部使用了栈cookie:

代码:

函数头部:

7E71EF1A  /$  B8 6A54737E   mov     eax, 7E73546A                    ;  异常处理地址
7E71EF1F  |.  E8 B4440100   call    7E7333D8                         ;  设置SEH链
7E71EF24  |.  81EC 78020000 sub     esp, 278
7E71EF2A  |.  A1 DCB2737E   mov     eax, dword ptr [7E73B2DC]        ;  获取栈cookie随机数
7E71EF2F  |.  53            push    ebx
7E71EF30  |.  56            push    esi
7E71EF31  |.  57            push    edi
7E71EF32  |.  8B7D 08       mov     edi, dword ptr [ebp+8]
7E71EF35  |.  68 BC020000   push    2BC
7E71EF3A  |.  8945 F0       mov     dword ptr [ebp-10], eax          ;  在返回地址减0x14字节处存放栈cookie

函数尾部:

7E71F06B  |.  8B4D F0       mov     ecx, dword ptr [ebp-10]          ;  取出栈cookie
7E71F06E  |.  5B            pop     ebx
7E71F06F  |.  E8 B63F0100   call    7E73302A                         ;  检测栈cookie是否被改动,是则退出进程
7E71F074  |.  C9            leave
7E71F075  |.  C2 0400       retn    4

而栈溢出正好发生在该函数内部,所以如果通过覆盖RET实现攻击,则会被栈cookie干掉,如果通过超长串覆盖栈底触发SEH,则会被safeseh干掉,所以,咋一看,无法利用
2011-7-24 17:09
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
12
是啊,谢谢指点,但是利用起来太蛋疼了
2011-7-25 15:17
0
雪    币: 196
活跃值: (20)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
本人就一大菜鸟,希望各位大牛看了愚见不要大笑-_-
pop pop pop ret的返回方法是利用SEH攻击跳入shellcode的常规办法。考察shellcode在堆栈上由于DEP的原因无法执行。而由于safeSEH,只能在nosafeSEH模块寻找指令序列。不知道我理解的对不对。
那么可以考察N pop ret指令序列,因为原来被利用来指向shellcode的地址无法使用,而shellcode就位于栈中该地址之后,可以选择更多的pop指令序列之后的ret,这样可以用我们选择的地址提供给ret指令。这个时候,由于指令序列在nosafeSEH中,所以绕过了safeSEH,而我们此时就可以通过ROP的方法来想办法绕过DEP。另外,这时LoadLibraryA的方法,也值得一试了。
2011-9-5 01:58
0
雪    币: 146
活跃值: (182)
能力值: ( LV13,RANK:220 )
在线值:
发帖
回帖
粉丝
14
最近也遇到个类似问题 不过没有dep,本来想搞定dep+safeseh的利用,不好搞,找n个pop ret 指令序列不好找啊,而且触发时esp离shellcode所在位置还很远....
2011-10-29 22:34
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
15
问题解决
绕过,bypass,Kill BillGates
2012-1-6 10:58
0
雪    币: 411
活跃值: (262)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
16
LZ牛B,咋弄的,难道真找到一长串POP RET 跳转?
2012-1-11 03:06
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
17
好久没看这个帖子了
以前解决是在nosafeSEH模块(悄悄的说,别的都不好使,就360的模块可以)找跳板
现在有了别的办法了,还是老外牛,惭愧一个
2012-2-13 12:53
0
雪    币: 48
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
老外咋弄得?求细节!求资料!

关注ing~~~
2012-2-13 17:10
0
雪    币: 62
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
19
呼唤帖子主人···
2013-1-10 15:48
0
雪    币: 78
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
20
时间长,忘记了,记得好像是利用_except_handler3
2013-1-31 20:06
0
雪    币: 58
活跃值: (25)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
21
Mark留名,后续认真研究一下.
2013-2-1 09:03
0
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册