首页
社区
课程
招聘
[原创]凑热闹 - III
2008-10-8 17:57 2919

[原创]凑热闹 - III

2008-10-8 17:57
2919

这题难度稍微低一点吧。
1、定位最终出错的函数位置,文档给出详细跟踪过程。
2、分析根本出错原因,给出分析文档和修复方法。
3. 将分析文档和相关测试源代码一起上传,同时描述一下分析过程。
4. 上传方式:将分析文档和相关测试源代码打包后,一起上传到“看雪论坛.腾讯公司2008软件安全竞赛答案提交区”。

1.出错位置
00420D81   |.  E8 7CE0FEFF  call <TestFloa.__snwprintf>
-〉
00413DDB   |> \8B03         |mov eax,dword ptr ds:[ebx]
00413DDD   |.  83C3 08      |add ebx,8
00413DE0   |.  8945 88      |mov [local.30],eax
00413DE3   |.  8B43 FC      |mov eax,dword ptr ds:[ebx-4]
00413DE6   |.  8945 8C      |mov [local.29],eax
00413DE9   |.  8D45 9C      |lea eax,[local.25]
00413DEC   |.  50           |push eax
00413DED   |.  FF75 94      |push [local.27]
00413DF0   |.  0FBEC2       |movsx eax,dl
00413DF3   |.  FF75 E8      |push [local.6]
00413DF6   |.  895D D8      |mov [local.10],ebx
00413DF9   |.  50           |push eax
00413DFA   |.  FF75 E0      |push [local.8]
00413DFD   |.  8D45 88      |lea eax,[local.30]
00413E00   |.  56           |push esi
00413E01   |.  50           |push eax
00413E02   |.  FF35 C8A0420>|push dword ptr ds:[42A0C8]
00413E08   |.  E8 3FEFFFFF  |call <TestFloa.__decode_pointer>
00413E0D   |.  59           |pop ecx
00413E0E   |.  FFD0         |call eax

对因的_woutput_l 函数对于   encoded_pointer出错。

跟踪过程 :
下断MessageBoxA  回溯即可找到出错来源。

.data:0042A0C8 off_42A0C8      dd offset __fptrap

此时   decode_pointer函数解码为 fptrap 为默认值,显然是错误的。

2、分析根本出错原因,给出分析文档和修复方法。

出错原因是

.text:00411DC6 __cfltcvt_init  proc near               ; CODE XREF: __fpmathp
.text:00411DC6                 mov     eax, offset __cfltcvt
.text:00411DCB                 mov     off_42A0B0, eax
.text:00411DD0                 mov     off_42A0B4, offset loc_4184EB
.text:00411DDA                 mov     off_42A0B8, offset __fassign
.text:00411DE4                 mov     off_42A0BC, offset __forcdecpt
.text:00411DEE                 mov     off_42A0C0, offset __positive
.text:00411DF8                 mov     off_42A0C4, eax
.text:00411DFD                 mov     off_42A0C8, offset __cfltcvt_l
.text:00411E07                 mov     off_42A0CC, offset __fassign_l
.text:00411E11                 mov     off_42A0D0, offset __cropzeros_l
.text:00411E1B                 mov     off_42A0D4, offset __forcdecpt_l
.text:00411E25                 retn
.text:00411E25 __cfltcvt_init  endp

没有被正确调用。

查找相关refs可以找到

.text:0040F618 __cinit         proc near               ; CODE XREF: ___tmainCRTStartup+144p
.text:0040F618
.text:0040F618 arg_0           = dword ptr  4
.text:0040F618
.text:0040F618                 cmp     ds:off_42405C, 0
.text:0040F61F                 jz      short loc_40F63B
.text:0040F621                 push    offset off_42405C
.text:0040F626                 call    __IsNonwritableInCurrentImage
.text:0040F62B                 test    eax, eax
.text:0040F62D                 pop     ecx
.text:0040F62E                 jz      short loc_40F63B
.text:0040F630                 push    [esp+arg_0]
.text:0040F634                 call    ds:off_42405C
.text:0040F63A                 pop     ecx

此时
.text:0040F621                 push    offset off_42405C
.text:0040F626                 call    __IsNonwritableInCurrentImage
这里所在的区段为可写,因此不会调用下面的初始化函数

/***
*BOOL _IsNonwritableInCurrentImage
*
*Purpose:
*       Check if an address is located within the current PE image (the one
*       starting at __ImageBase), that it is in a proper section of the image,
*       and that section is not marked writable.  This routine must be
*       statically linked, not imported from the CRT DLL, so the correct
*       __ImageBase is found.
*
*Entry:
*       pTarget - address to check
*
*Return:
*       0        Address is either not in current image, not in a section, or
*                in a writable section.
*       non-0    Address is in a non-writable section of the current image.
*
*******************************************************************************/
函数说明如上。
因此很明显这里的区段属性有问题

源代码 就算了吧。

拿loadpe改下段属性得了 把 writeable属性去掉吧



为了方便评委,还是上传一个修改好的文件吧。

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

上传的附件:
收藏
点赞0
打赏
分享
最新回复 (1)
雪    币: 264
活跃值: (30)
能力值: ( LV12,RANK:250 )
在线值:
发帖
回帖
粉丝
kangaroo 6 2008-10-14 16:02
2
0
结果提交时间 5 小时 57 分钟
结果提交时间长度 = 357 分钟
结果提交次数 = 1
结果提交为根本原因
得分 = [(2880 - 357)/2880]^1/5 x 1.0 x 100 - (1 -1 ) x 5 = 97.39
游客
登录 | 注册 方可回帖
返回