[NPUCTF2020]ezinclude 1

目录

  • 源码
  • 思路
  • 总结


源码


username/password error<html>
<!--md5($secret.$name)===$pass -->
</html>


思路

根据提示,先抓个包发现cookie里面有值 Hash=fa25e54758d5d5c1927781a6ede89f8a
根据md5($secret.$name)===$pass猜得这个应该为name的md5加密后的值,所以pass=fa25e54758d5d5c1927781a6ede89f8a

[NPUCTF2020]ezinclude 1_第1张图片
跳转后

<html>
<head>
<script language="javascript" type="text/javascript">
           window.location.href="404.html";
</script>
<title>this_is_not_fl4g_and_出题人_wants_girlfriend</title>
</head>
<>
<body>
include($_GET["file"])</body>
</html>

尝试了一下,发现filter没有被过滤,先读取一下源码看看

<html>
<head>
<script language="javascript" type="text/javascript">
           window.location.href="404.html";
</script>
<title>this_is_not_fl4g_and_出题人_wants_girlfriend</title>
</head>
<>
<body>
<?php
$file=$_GET['file'];
if(preg_match('/data|input|zip/is',$file)){
	die('nonono');
}
@include($file);
echo 'include($_GET["file"])';
?>
</body>
</html>

用wappalyzer可以得知中间件是nginx了,直接包含/var/log/nginx/access.log发现没有回显,应该不是考包含日志文件.

试着用fuzz一下flag的路径,返回429

字典 https://github.com/ev0A/ArbitraryFileReadList

[NPUCTF2020]ezinclude 1_第2张图片
尝试下session上传


DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>upload-POCtitle>
head>
<body>
<form action="http://0cd7c655-8ed0-49f3-84b0-a8a75ee85fee.node4.buuoj.cn:81/flflflflag.php" method="post" enctype="multipart/form-data">
    
    <input type="hidden" name="PHP_SESSION_UPLOAD_PROGRESS" value="'kradress']); ?>" >  
    

    <label for="file">文件名:label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="提交">
form>
body>
html>

session默认路径/tmp和/var/lib/php/session
都没有回显

[NPUCTF2020]ezinclude 1_第3张图片

看了下数据包提示版本是X-Fowared-By: PHP/7.0.33

这里我们可以用
flflflflag.php?file=php://filter/string.strip_tags/resource=/etc/passwd
参考博客: https://www.cnblogs.com/tr1ple/p/11301743.html

使用php://filter/string.strip_tags导致php崩溃清空堆栈重启,如果在同时上传了一个文件,那么这个tmp file就会一直留在tmp目录,再进行文件名爆破就可以getshell

把文件名设为sess_kradress,提示404,说明php崩溃了
[NPUCTF2020]ezinclude 1_第4张图片

看题解发现有个dir.php,但是自己扫不出来
在这里插入图片描述
试了很久,发现flag在phpinfo里面
[NPUCTF2020]ezinclude 1_第5张图片

总结

感觉踩了很多坑,一直以为sesion 的clean up机制会在浏览器崩溃时 不会清掉session,dir.php一直扫不出来,字典里也有,不知道为什么.文件上传的内容里面没有phpinfo,echo 123一直不回显,导致花了很长时间

不过学到了不少,知识点总结进我的博客了
https://kradress.github.io/2021/12/07/文件包含.html

你可能感兴趣的:(BUUCTF,nginx,html,运维)