0394-CVE2014-6287分析报告

# CVE2014-6287分析报告

0x00 写在前面
———

* * *

在乌云zone里看到了《HFS 2.3x 远程命令执行(抓鸡黑客末日)》的文章,以前只是分析二进制漏洞,这种命令注入漏洞还是第一次分析,从网上下了HFS 2.3.279这个版本,运行起来之后,执行POC,四个calc就执行起来了。

poc:

“`
http://localhost:80/?search==%00{.exec|calc.}

“`

PS:分析到最后,google查找可执行模块中的字符串“`parserLib`”,才知道这个漏洞是CVE2014-6287。。。。。。一种淡淡的忧伤。不过还是说一下分析的过程吧。

0x01 准备工作
———

* * *

首先是分析前的一些准备工作,用PEiD查看了一下文件,加了asp的壳,通过PEiD通用脱壳器简单的进行脱壳。

![enter image description here](http://drops.javaweb.org/uploads/images/be8d6e9e9df1343c08e512919420367a8821f73c.jpg)

![enter image description here](http://drops.javaweb.org/uploads/images/cd6c2afd131967e5369577cbeaa0daf2807cdbb5.jpg)

通过IDA加载脱壳后的文件,看到一些函数如图,根据之前对c++中string类实现的认识,看来应该是使用了静态编译,字符串处理的库代码被静态链接到了可执行文件中。

![enter image description here](http://drops.javaweb.org/uploads/images/262d1f121809e1bfcb94ea646cd6986b56da406f.jpg)

通过PEid对脱壳后的文件进行编译器识别,识别为Borland Delphi 6.0 – 7.0,通过IDA加载相应的签名库,对函数进行签名,这样就能识别出大量的内联函数,方便分析。通过签名,已经可以识别出5636个内联函数,这样分析起来就方便很多。

![enter image description here](http://drops.javaweb.org/uploads/images/af5de85a60d179cd83a7fe175802cf6399a950b7.jpg)

![enter image description here](http://drops.javaweb.org/uploads/images/c86f68818a921bc9424fa24a858e4be8bc28a672.jpg)

0x02 分析过程
———

* * *

通过IDA查看文件导入函数,查找WinExec、ShellExecuteA等进程启动相关函数,通过交叉引用找到函数调用点,通过windbg设置断点,观察参数,确实是由ShellExecuteA启动了计算器。同时查看程序的调用栈。

![enter image description here](http://drops.javaweb.org/uploads/images/5befaf780a5b3d703813e2f840f9b2dba0333316.jpg)

![enter image description here](http://drops.javaweb.org/uploads/images/30114683a9f246e4efa6a71962adabe8a7d035ea.jpg)

通过调用栈,可已找到sub_531438函数,该函数解释了exec|calc命令,并启动了calc。对函数进行分析,可知该函数是对用户的命令进行解释执行的函数,相关代码如下。

![enter image description here](http://drops.javaweb.org/uploads/images/facabe74aa413799c1c1ae877f7da4a6ae728ba4.jpg)

继续通过调用栈,结合IDA对“exec|calc”的传递过程进行分析,找到

“`
int __stdcall sub_51E268(signed char *** a1, int a2)

“`

函数,**a1指向需要解释的字符串“\x00{.exec|calc.}”,其中`int __cdecl sub_51DFA0(int a1)`函数对“`\x00{.exec|calc.}`”对其进行分析并执行。

![enter image description here](http://drops.javaweb.org/uploads/images/01364b50e27ab48035166b3e887be9e5bf21214a.jpg)

![enter image description here](http://drops.javaweb.org/uploads/images/edff9df227680a5fa7cf82a46ce22cffe7708816.jpg)

对于

“`
http://localhost:80/?search=%20{.exec|calc.}

“`

通过对比sub_51E268处**a1指向需要解释的字符串,可以看到`{.|`等字符都被编码了。

![enter image description here](http://drops.javaweb.org/uploads/images/3e79ff59036bfafa62c6370343cb0790121b19ee.jpg)

可见

“`
http://localhost:80/?search=%00{.exec|calc.}

“`

中`%00`导致了`{.exec|calc.}`中的特殊字符转换失败,因此需要对转换函数进行定位。在模块中对“&#”字符串进行查找,定位得到

“`
int __fastcall sub_528EB0(int a1, int a2)

“`

完成对{|等字符进行转换。

![enter image description here](http://drops.javaweb.org/uploads/images/d2d405e16006cfde81c3f849fc0e2bac6729bc68.jpg)

sub_51E390做正则表达式匹配,查找`{|`等字符,当`%20{.exec|calc.}`传递给该函数时,该函数返回值为2。下面由

“`
sub_4B827C、Sysutils::IntToStr

“`

将字符转换为10进制字符串形式,最终替换掉原始字符串中的{。

![enter image description here](http://drops.javaweb.org/uploads/images/de98ecc79552878f61d02a278b6708ecddd2a587.jpg)

![enter image description here](http://drops.javaweb.org/uploads/images/637d7a793b3784f7b54b075c7afde8bfcf03674b.jpg)

对于

“`
http://localhost:80/?search=%00{.exec|calc.}

“`

sub_51E390返回值为0,因此后面的{|等字符不会被转换,最终导致了后面的命令执行。

![enter image description here](http://drops.javaweb.org/uploads/images/796dabc65bf42e23f477331644c242090ff23b05.jpg)

查看

“`
int __fastcall sub_51E390(int a1, int a2)

“`

函数,可以看到“`\\{[.:]|[.:]\\}|\\|`”和“`m!`”,在分析的过程中,看到过字符串“`parserLib`”,就google一下。。。。。。。

![enter image description here](http://drops.javaweb.org/uploads/images/e9fe45ccf88dda05aa3dae577e1bef975c051311.jpg)

![enter image description here](http://drops.javaweb.org/uploads/images/4c269cb392dedf51a39caac6c18aa7410797419f.jpg)

查看该漏洞详情,可以看到和分析的结果一致,由于正则表达式的问题,导致了最终的远程代码执行。

![enter image description here](http://drops.javaweb.org/uploads/images/8075fb0915a6d6fe35875341627ad7712f96e26e.jpg)

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容