はじめに#
今回はTryHackMeのBasic Pentestingを解いてみたので、そのWriteUPを書いていきたいと思います。
自分は約2時間程度で全ての問題を解き終わることが出来ましたので、時間の参考にしてみてください。
WriteUP#
Find the services exposed by the machine#
攻略するマシンのサービスの列挙です。 nmapを使ってポートスキャンをしていきます。
nmap -v -p-10000 10.10.xxx.xxxこれでポートの列挙が出来ました。

What is the name of the hidden directory on the web server(enter name without /)?#
hidden derectoryを探す問題です。 gobusterを実行してあげます。
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.xxx.xxx無事hidden directoryを見つけることが出来ました。

User brute-forcing to find the username & password#
まずは、ポートスキャンで得た情報から、SMBが動いていることがわかります。 そのため、smbからUsernameを獲得しようと考え、今回はenum4linuxを使用しました。
enum4linux -a 10.10.xxx.xxxWhat is the username?#
enum4linuxからの情報で、2つのユーザーを見つけることが出来ました。

What is the password?#
nmapにてSSHのポートが開いていることが確認できたので、hydraを使ってパスワードのブルートフォースを試していきます。
hydra -l jan -P /usr/share/wordlists/rockyou.txt 10.10.xxx.xxx sshEnumerate the machine to find any vectors for privilege escalation#
まずは先程獲得した他のユーザのディレクトリを確認し、特権昇格できそうな情報を探していきます。

最終的にpass.bakの中身を確認できればこのRoomは完了しそうだなぁというのを頭にいれつつ、.sshディレクトリの中身を見ていきます。

id_rsaが読み取り可能になっているので、そこから特権昇格を狙っていこうと思います。
If you have found another user, what can you do with this information?#
獲得したid_rsaでssh接続を試みてみます。

しかし、パスフレーズを求められてしまいました。
ここで、SSH2Johnを使って、SSH Key Passwordの解析を試みます。
python2 /usr/share/john/ssh2john.py id_rsa > id_rsa_hash.txtjohn --wordlist=/usr/share/wordlists/rockyou.txt --format=SSH id_rsa_hash.txt無事パスワードがわかったので、ログインしていきます。
ssh -i id_rsa [email protected]What is the final password you obtain?#
ログインが出来たので、最終的なフラグをゲットして終わりです。
cat pass.bakまとめ#
今回はTryHackMeのBasic Pentestingを解いてみました。
これを解く前にLeaning PathのCOMPLETE BEGINNERを全て解いていたので、詰まりそうになったときはヒントを見たり、前の章をさらっと復習をすることをオススメします。