文件上传传🐎
整个elf🐎来方便搞事
连上哩
进shell一眼看到find说不定可以提权,不过不管了,先试试能不能搭隧道打内网吧
ok隧道也是搭起来了
接下来扫一下就知道别的机器在哪里了
很容易知道在172.11.0.4:3000部署了一个web
在172.11.0.3部署了一个redis,还是没密码的
一万分?写脚本爆一下
import requests
url = r"http://172.11.0.4:3000/play.php"
res = requests.get(url,cookies={"PHPSESSID": "4c"})
data = "answer"
a = res.text.split(r'<h4 class="text-light mb-3">')[1].split(r' = ?</h4>')[0]
p = res.text.split(r'<p class="text-light">当前分数:')[1].split('</p>')[0]
p = int(p)
while p<=9999:
res = requests.post(url,data={data:eval(a)},cookies={"PHPSESSID": "4c"})
p = res.text.split(r'<p class="text-light">当前分数:')[1].split('</p>')[0]
p = int(p)
a = res.text.split(r'<h4 class="text-light mb-3">')[1].split(r' = ?</h4>')[0]
这时候想起了redis,数据应该是存在里面的我们看看
看起来可能是要把这个role改成admin就行了
那就改
跑了一万次还是这个结果
可能在别的地方吧
试了下admin.php发现能够访问了
这里可以翻看源码
<?php
require_once 'common.php';
$user = getCurrentUser();
if (!$user || $user['role'] !== 'admin') {
header('HTTP/1.1 403 Forbidden');
die('<h1 class="text-light">403 Forbidden - 权限不足</h1>');
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
define('REL_FILENAME', 'word/_rels/document.xml.rels');
function hellYeah($code, $msg): void
{
http_response_code($code);
die("<div class='neu-card'><div class='alert alert-danger'>$msg</div></div>");
}
if (!isset($_FILES['input'])) hellYeah(400, '请选择要上传的文件');
if ($_FILES['input']['error'] !== UPLOAD_ERR_OK) hellYeah(500, '文件上传错误');
if ($_FILES['input']['type'] != 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
hellYeah(400, '请上传Word文档 (.docx)');
$zip = new ZipArchive();
$zipFilename = $_FILES['input']['tmp_name'];
if ($zip->open($zipFilename) !== true || $zip->locateName(REL_FILENAME) === false)
hellYeah(400, '无效的Word文档格式');
$relsDom = simplexml_load_string($zip->getFromName(REL_FILENAME));
if ($relsDom === false) hellYeah(400, '文档关系表解析失败');
$tmpDir = exec("mktemp -d --tmpdir=/tmp");
shell_exec("unzip $zipFilename \"word/media*\" -d \"$tmpDir\"");
function cleanup($tmpDir): void
{
shell_exec("rm -rf $tmpDir");
}
register_shutdown_function('cleanup', $tmpDir);
@chdir("$tmpDir/word/media");
ini_set('open_basedir', '.');
$messages = [];
foreach($relsDom->Relationship as $rel) {
if($rel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') {
if (!str_starts_with($rel['Target'], 'media/'))
continue;
$filename = substr($rel['Target'], 6);
$file = @file_get_contents($filename);
if ($file === false)
break;
if ($result = @base64_encode($file))
$messages[] = $result;
}
}
system("rm -rf $tmpDir");
}
前面的都不重要,其实这里就是一个docx上传,仔细看其实就是压缩包解压的改版。
从docx文件的rel文件的Target行读取文件名,media/
后面就是文件名,然后用file_get_contents
函数读取后用base64编码读出来。
它使用ini_set('open_basedir', '.');
限制了访问路径,所以需要用软连接来绕过。
但尝试了之后只用软连接是不行的,需要软连接+php伪协议。
所以最终的成果是
media
连接到根目录
这是rels文件,最后上传成功得到flag
评论列表(1条)