nmap扫描

image-20250112024516495image-20250112024516495

直接访问ip会301到域名,需要添加一下hosts规则

image-20250112173150853

dirsearch扫到robots.txt

image-20250112172324510

image-20250112041707648

ghost 5.58,CVE-2023-40028任意文件读取,但需要登入

image-20250112172516710

根据发布的文章得知用户名是admin,登录页面Forgot?可测试邮箱是否存在

存在邮箱admin@linkvortex.htb,密码报不出来

image-20250112184906557

gobuster或ffuf扫描子域

gobuster vhost -u http://linkvortex.htb -w /usr/share/wordlists/amass/subdomains-top1mil-110000.txt --append-domain
或
ffuf -u http://linkvortex.htb/ -w /usr/share/wordlists/amass/subdomains-top1mil-110000.txt -H "Host:FUZZ.linkvortex.
htb"  -mc 200

image-20250112173252535

添加hosts

dirsearch发现git源码泄露

image-20250112174449402

git-dumper拉取源码

git-dumper http://dev.linkvortex.htb/.git ./git

image-20250112204209910

在源码中查找所有password字样

grep password -r ./

挨个尝试,发现OctopiFociPilfer45能够成功登入

image-20250112203938934

拿到账户和密码就可以利用CVE-2023-40028

POC:
monke443/CVE-2023-40028-Ghost-Arbitrary-File-Read: Arbitrary file read in Ghost-CMS allows an attacker to upload a malicious ZIP file with a symlink.

image-20250112204828220

读flag时候发现读不到,想到拉取的源码中有一个Dockerfile,web服务可能是运行在docker中的

/.dockerenv发现也是存在的

image-20250112213906897

docker与主机隔离,如何是好

回头再看这个Dockerfile与主机的交互信息,发现config.production.json从主机复制到docker中

image-20250112213215133

发现残存的邮件系统有用户密码bob:fibber-talented-worth

image-20250112214130414

尝试ssh连接

image-20250112213133040

sudo -l看一下,可以sudo执行

/usr/bin/bash /opt/ghost/clean_symlink.sh *.png

image-20250112214417523

/opt/ghost/clean_symlink.sh,功能是读一个png结尾的符号链接,且链接目标路径不能包含root和etc字符串,即不能直接链接到/root/root.txt

#!/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

image-20250112221444486

不过我们二重链接,这样检测到的目标路径即为第一个符号链接文件路径,但需要注意的是,由于clean_symlink.sh会把这个链接符号移动到/var/quarantined中,这样在第二次链接时候对于第一个参数(第一个链接符号文件路径)需要用绝对路径,不能用相对路径,否则移动后将相对是/var/quarantined的位置

image-20250112233905648

还有一点是对于CHECK_CONTENT变量是否为空的检测,可以直接设一个全局变量

image-20250112233233823