Discuz vs Phpwind -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【meiwen.anslib.com - 电脑资料】

    编外:尊重作者,不改题目了,不太直观

    By;superhei

    这几天领导为了抢病人把我们120急救中心搬到院外,本来偷偷在院长办公室接来的网线现在也用不上了.到外面了就没办法上网了...没想到dz vs pw的进一步升级.

    .最开始pw的'冰封浪子'在他的blog上发了一个dz sql注射的隐藏日志,结果被ring04h黑了,结果传来传去到处都是... dz的'剑心'看到并且证实了该漏洞..于是'冰封浪子'

    就公布了他的exp,但是很奇怪的是Phpwind也存在类似的漏洞[虽然Phpwind6补丁了,但是以前的版本并没有补丁],于是被'剑心'抓到了..........

    现在时间回到几年前,dz的'小戴'还是很有眼光的,'剑心'和'9xiao'黑了dz后,然后把'剑心'引进了dz,并且负责dz的安全,这样dz就偷偷的补丁了很多bug :) 并且安全部门

    得到发展,同时他们利用'业余时间',发布了很多Phpwind的漏洞... Phpwind在安全上一直处于下风,到了phpwind6把代码结构重新整理,并且加强了安全性,到了今年才引进专门的安全人员[一切都是被逼的~~~~~~~~~被逼的]

    感叹下,杂看别人的代码都那么厉害呢? :)

    最后我们来具体说说这个漏洞的一些细节[Thx Ryat]

    具体原理还是宽字节编码之间转换导致的安全问题.

    这里看个代码:

   

    //gpc=on

    $id1=mb_convert_encoding($_GET['a'], 'utf-8', 'gbk');

    $id2=iconv('gbk//IGNORE', 'utf-8', $_GET['a']);

    $id3=iconv('gbk', 'utf-8', $_GET['a']);

    print "select * from test where id='$id1'";

    print "select * from test where id='$id2'";

    print "select * from test where id='$id3'";

    ?>

    提交a=%bf%27 然后查看原代码可以看到:

    select * from test where id='縗''

    select * from test where id='縗''

    select * from test where id='縗''

    以上gbk转utf-8导致安全问题,但是dz不完全是这样.

    \wap\index.php里

    if($_POST && $charset != 'utf-8') {

    $chs = new Chinese('UTF-8', $charset);// 这里是utf-8转gbk

    foreach($_POST as $key => $value) {

    $$key = $chs->Convert($$key);

    }

    unset($chs);

    }

    include\chinese.class.php里:

    function Chinese($SourceLang, $TargetLang) {

    $this->config['SourceLang'] = $this->_lang($SourceLang);

    $this->config['TargetLang'] = $this->_lang($TargetLang);

    if(function_exists('iconv')) {

    $this->iconv_enabled = true; //如果存在iconv()就使用iconv

    } else {

    $this->iconv_enabled = false; //如果不存在dz就自己实现了一个转换,但是这个转换导致的bug

    $this->OpenTable();

    }

    }

    .........

    ($this->iconv_enabled) {

    if($this->config['TargetLang'] <> 'UNICODE') {

    return iconv($this->config['SourceLang'], $this->config['TargetLang'], $SourceText); //使用iconv转换

    } else {

    $return = '';

    while($SourceText) {

    if(ord(substr($SourceText, 0, 1)) > 127) {

    $retur

    ..........

    于是我们看看php手册对iconv的描叙:

    安装

    To use functions provided by this module, the PHP binary must be built with the following configure line: --with-iconv[=DIR].

    Note to Windows(R) Users: In order to enable this module on a Windows(R) environment, you need to put a DLL file named iconv.dll or iconv-1.3.dll (prior to 4.2.1) which is bundled with the PHP/Win32 binary package into a directory specified by the PATH environment variable or one of the system directories of your Windows(R) installation.

    This module is part of PHP as of PHP 5 thus iconv.dll and php_iconv.dll is not needed anymore.

    也就是说在win系统上php5以后系统默认就有iconv(),但是php4需要设置php.ini,对于*uix系统,自己编译php不管是5 都需要自己设置php.ini加载iconv.so才行,而dz上面那个漏洞的条件是目标系统上不支持iconv才行.这个也是很多人测试不成功的原因. [并不是人家给的假的exp,而且需要登陆后才触发].

    对于dz和pw不知道是代码抄写还是怎么的,很多功能和代码很类似,所以导致的漏洞也类似[可以参考我以前的blog],下面我看看phpwind5的代码:

    \wap\global.php里

    if($charset != 'utf8'){

    $chs = new Chinese('UTF8',$charset);

    foreach($_POST as $key=>$value){

    $$key=$chs->Convert($$key);

    }

    }

    但是\wap\chinese.php里并没有使用iconv,而是完全自己写的代码实现[代码基本和dz一样].

最新文章