TryHackMe(THM):AttackerKB

目次

この記事は、DeepL翻訳を利用して和訳しています。

www.deepl.com

Task 1 I'm attacking what now?

Ever caught wind of a new vulnerability on Twitter or found something weird when examining a box? Fear no more, AttackerKB is here to make sense of it all! Throughout this room, we'll be examining how we can leverage AttackerKB both as an attacker and defender to gain further insight into the ever-changing landscape of vulnerabilities.

Twitterで新しい脆弱性の情報を得たり、箱を調べていて変なものを見つけたりしたことはありませんか?そんな時はAttackerKBにお任せください。この部屋では、AttackerKBを攻撃者としても防御者としても活用し、刻々と変化する脆弱性の状況をより深く理解するための方法を検討します。

A standalone version of the virtual machine used in this room can be found in this room. Additionally, you can download the OVA of Source for offline usage from https://www.darkstar7471.com/resources.html

この部屋で使われている仮想マシンスタンドアロン版は、この部屋で見ることができます。さらに、オフラインで使用するSourceのOVAは、

https://www.darkstar7471.com/resources.html

からダウンロードできます。

Task 2 Discovering the Lay of the Land

Scan the machine with Nmap. What non-standard service can be found running on the high-port?

まずnmapを実行します。

# nmap -sV -sC <$IP>

f:id:akebono-haze:20210523170450p:plain

22番ポート(SSH)と10000番ポート(http)の2ポートが解放されています。

ハイポートで動作している非標準のサービスなので、httpポートのアプリケーション名を解答します。

Further enumerate this service, what version of it is running?

nmapの結果からアプリケーションのバージョン情報が表示されているのでそれを回答します。

Visit the webpage generated by this service. You should encounter an error due to SSL being present. Change the URL to use HTTPS and ignore the exception. After this, view the certificate. What hostname can we find on the cert details? On Firefox, you can view this by clicking on the 'i' in the URL, then the '>' in Connection, 'More Information', and then 'View Certificate' on the Security tab.

設問にあるように-ブラウザでWebページにアクセスします。そのときにポート番号を指定することを忘れずに。

f:id:akebono-haze:20210523172416p:plain

ブラウザのアドレス欄にある鍵マークをクリックします。

安全でない接続の右横の「>」をクリックします。

f:id:akebono-haze:20210523172951p:plain

画面下の「詳細を表示」をクリックします。

f:id:akebono-haze:20210523173047p:plain

ページ情報画面が表示されるので、[証明書を表示]ボタンを押下します。

f:id:akebono-haze:20210523173144p:plain

すると、設問の解答であるホスト名が表示されます。

f:id:akebono-haze:20210523173332p:plain

Adjust your /etc/hosts file accordingly to include the newly discovered hostname and revisit the webpage in question. Note, that this will confirm that the service we previously discovered using Nmap is correct. Once you've done this, move onto task three.

問題文にあるように/etc/hostsファイルを適宜修正します。

# vi /etc/hosts

f:id:akebono-haze:20210523173606p:plain

この修正は必要ないかな?

Task 3 Learning to Fly

AttackerKBにアクセスしてみます。

attackerkb.com

画面右上のSearchボックスに「Webmin」で検索します。

f:id:akebono-haze:20210523174414p:plain

検索結果から「password_change.cgi」をクリックしてください。

f:id:akebono-haze:20210526075011p:plain

Take a look through the Assessments for this vulnerability. As an attacker, we can use the information posted here by other members to determine how value an exploit might be and any tweaks we might have to make to exploit code. Similarly, as a defender we can leverage these comments to gain additional situational information for vulnerabilities, allowing us to gauge how quickly we need to patch them. Which version of Webmin is immediately vulnerable to this exploit?

この脆弱性の評価に目を通します。

攻撃側としては、他のメンバーが投稿した情報を利用して、脆弱性を利用するための価値や、脆弱性を利用するために必要なコードの調整を行うことができます。

防御側としては、これらのコメントを活用して、脆弱性に関する追加の状況情報を得ることができ、どの程度早くパッチを当てる必要があるかを判断することができます。

 

画面をスクロールすると、コメントにバージョン情報が書かれていました。

f:id:akebono-haze:20210526075800p:plain

What type of attack was this? Note, we're looking for how this was added to the code for Webmin, not how this results in remote code execution (RCE).

これも上の投稿内容に攻撃内容が書かれていました。

Can you find a link to a post on the webmin's website explaining what happened? What day was Webmin informed of an 0day exploit? Can you find a link to a post on the webmin's website explaining what happened? What day was Webmin informed of an 0day exploit?

webminのサイトで「1.890 Exploit」で検索すると0dayの日付がわかります。

www.webmin.com

f:id:akebono-haze:20210526081922p:plain

GitHubで「password_change.cgi backdoor exploit」をキーワードに検索すると設問の追加された番号の答えが見つかります。

github.com

f:id:akebono-haze:20210526082334p:plain

Task 4 Blasting Away

Now that we've selected our exploit, set the options provided appropriately. Beyond RHOSTS and LHOST, what is the third option we must set to 'True'?

今回はMetasploitモジュールを使用するので、Metasploitを起動してください。

# msfconsole

Metasploitが起動したら、searchコマンドでwebminで検索します。出力結果からbackdoorのコードを選択します。

f:id:akebono-haze:20210526083321p:plain

 optionコマンドで設定するコマンドを確認します。

f:id:akebono-haze:20210526083427p:plain

LHOSTに自分のIPアドレス 、RHOSTSにVirtualマシンのIPアドレス 、もう一つは設問の解答を設定します。

f:id:akebono-haze:20210526083510p:plain

Run the exploit. What is the user flag?

 exploitを実行します。

 コマンドが入力できる状態になったら、現在のディレクトリを確認します

lsコマンドでディレクトリやファイルを確認すると、意味深なディレクトリ名を発見しました。

ls -al

 そのディレクトリの中を確認するとuser.txtファイルを見つけました。

f:id:akebono-haze:20210526083942p:plain

 

How about the root flag?

最後にrootフラグなので、とりあえずlsコマンドでrootディレクトリを確認してみます。

なんと現在の権限で見ることができました。 ということは、このディレクトリにroot.txtファイルがあるので、中身を確認します。

f:id:akebono-haze:20210526084120p:plain

 

終了!