这次红帽杯只有web4挺有意思,也拿了个一血。

find_it

robots提示了1ndexx.php,在.1ndexx.php.swp看到源码。

<?php

#Really easy...

$file=fopen("flag.php","r") or die("Unable 2 open!");

$I_know_you_wanna_but_i_will_not_give_you_hhh = fread($file,filesize("flag.php"));

$hack=fopen("hack.php","w") or die("Unable 2 open");

$a=$_GET['code'];

if(preg_match('/system|eval|exec|base|compress|chr|ord|str|replace|pack|assert|preg|replace|create|function|call|\~|\^|\`|flag|cat|tac|more|tail|echo|require|include|proc|open|read|shell|file|put|get|contents|dir|link|dl|var|dump/',$a)){
    die("you die");
}
if(strlen($a)>33){
    die("nonono.");
}
fwrite($hack,$a);
fwrite($hack,$I_know_you_wanna_but_i_will_not_give_you_hhh);

fclose($file);
fclose($hack);
?>

读flag

image-20210509171327716

framework

about路由存在反序列化

image-20210509171352225

可以看到yii版本Yii Framework/2.0.32

phpggc中存在pop链,直接打

image-20210509171512819

蚁剑绕disable_function

image-20210509171424187

WebsiteManger

注入获得账号密码admin/0e41ee97bb4e54f9a1cbe

在curl.php中可以crlf,应该是攻击内网,但是可以直接用file协议读flag,应该是非预期吧

image-20210509171931099

ezlight

源码下载下来是一个cms

在github可以找到对应的 cms https://github.com/eddy8/lightCMS

用bc4比较了一下,没啥区别,修改的地方不太重要。

在issue中看到了gml师傅在二月份提交的rce漏洞https://github.com/eddy8/LightCMS/issues/19。

原来的版本可以在NEditorController中任意文件读和任意文件上传,具体可以查看该issue。

在补丁中限制了远程下载的内容和后缀。

image-20210509163952802

一开始以为可以通过imagecreatefromwebp函数触发phar反序列化

image-20210509164035172

但是isWebp限制了curl了url的内容

image-20210509164125674

但是观察到Image::make($data)$data是可控的,Image::make看上去像是图片处理函数,那么也有可能也能触发phar反序列化。

跟进Image::make,应该是Facade模式动态调用的。动态调试找到make函数

image-20210509165341244

直接看init函数,在判断输入的$data内容的类型。

image-20210509165857958

在initFromUrl中使用了file_get_contents,自此我们可以实现触发phar反序列化

image-20210509165703132

最后就是利用了,已知为laravel6.0,可以直接用phpggc中的gadget。所以我们需要先上传一个phar文件,然后让远程curl的时候回复phar://xxx,那么就可以触发了。

image-20210509170200924

先整生成payload

image-20210509170337075

admin/admin登陆后台,上传使用/admin/neditor/serve/uploadFile接口,返回文件地址。

image-20210509170441939

http://119.3.31.90:30000远程回显一个phar payload触发反序列化。

image-20210509170529495 image-20210509170639735