TryHackMe(THM):Web Scanning

目次

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

www.deepl.com

Task 1  Pull the lever, Kronk!

Web scanning represents one of the core constructs of modern pen testing. Quite simply, most of what we interact with on a daily basis is the internet, and therein there is a multitude of ever-widening number of vulnerabilities. Within this room, we will investigate two of the most common scanners: Nikto and Zap. 

ウェブスキャンは、現代のペンテストの中核を成すものの一つです。簡単に言えば、私たちが日常的に接しているもののほとんどはインターネットであり、そこには増え続ける数多くの脆弱性が存在しています。この部屋では、最も一般的なスキャナのうちの2つを調査します。NiktoとZapです。

 

Task 2  ...I'm supposed to scan with that?

A short quiz over the various switches used with Nikto as well as a quick scan against our target. All you'll need for this is the help menu for nikto. Include all parts of the switch unless otherwise specified, this includes -

Niktoで使われる様々なスイッチについての簡単なクイズと、ターゲットに対するクイックスキャンです。これに必要なのはniktoのヘルプメニューです。特に指定のない限り、スイッチのすべての部分を含みますが、これには以下のものが含まれます。

First and foremost, what switch do we use to set the target host?

まず第一に、ターゲットとなるホストをどのスイッチで設定するか。

Niktoには2種類のヘルプがあるようです。

 -h (ショートバージョン)

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

-H (フルバージョン)

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

Websites don't always properly redirect to their secure transport port and can sometimes have different issues depending on the manner in which they are scanned. How do we disable secure transport?

Webサイトがセキュアトランスポートポートに適切にリダイレクトされないことがあり、スキャンの方法によっては異なる問題が発生することがあります。セキュアトランスポートを無効にするには?

上の画像のフルバージョンから見つけてください。

How about the opposite, how do we force secure transport?

逆に、セキュアなトランスポートをどうやって実現するか。

これも上の画像のフルバージョンから見つけてください。

What if we want to set a specific port to scan?

特定のポートをスキャンするように設定したい場合は?

これも上の画像のフルバージョンから見つけてください。

As the web is constantly evolving, so is Nikto. A database of vulnerabilities represents a core component to this web scanner, how do we verify that this database is working and free from error?

ウェブが常に進化しているように、Niktoも常に進化しています。脆弱性のデータベースは、このウェブ・スキャナーの中核を成すものですが、このデータベースが動作し、エラーがないことをどのようにして確認するのでしょうか。

これも上の画像のフルバージョンから見つけてください。

If instructed to, Nitko will attempt to guess and test both files within directories as well as usernames. Which switch and numerical value do we use to set Nikto to enumerate usernames in Apache? Keep in mind, this option is deprecated in favor of plugins, however, it's still a great option to be aware of for situational usage.

指示があれば、Nitkoはユーザー名だけでなく、ディレクトリ内のファイルも推測してテストしようとします。Apacheのユーザー名を列挙するようにNiktoを設定するには、どのスイッチと数値を使用すればよいでしょうか?このオプションはプラグインに移行したため非推奨となっていますが、状況に応じて使い分けることができる素晴らしいオプションであることに留意してください。

 

これも上の画像のフルバージョンから見つけてください。と言いたいところですが、オプションのあるので説明をつけます。

-mutateオプション

  1. すべてのファイルとすべてのルートディレクトリをテスト
  2. パスワードのファイル名を推測する
  3. Apacheを介したユーザ名の列挙 (/~userタイプのリクエスト)
  4. cgiwrapを介したユーザー名の列挙 (/cgi-bin/cgiwrap/~userタイプのリクエスト)
  5. ホスト名が親ドメインであると仮定して、サブドメイン名のブルートフォースを試みる
  6. 与えられた辞書ファイルからディレクトリ名を推測しようとする

Suppose we know the username and password for a web forum, how do we set Nikto to do a credentialed check? Suppose the username is admin and the password is PrettyAwesomePassword1234

ウェブフォーラムのユーザー名とパスワードを知っているとしたら、Niktoに資格者チェックを行うように設定するにはどうすればよいでしょうか。ユーザー名がadminで、パスワードがPrettyAwesomePassword1234だとします。

これも上の画像のフルバージョンから見つけてください。

Let's scan our target machine, what web server do we discover and what version is it?

対象となるマシンをスキャンしてみましょう。どんなウェブサーバーが見つかり、そのバージョンは?

コンソール上でnikto -h <$IP>を実行します。

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

This box is vulnerable to very poor directory control due to it's web server version, what directory is indexed that really shouldn't be?

このボックスは、ウェブサーバのバージョンにより、非常に貧弱なディレクトリコントロール脆弱性があります。実際にはインデックスされるべきではない、どのようなディレクトリがインデックスされていますか?

ヒントには...

This directory allows for settings to potentially be changed remotely, allowing for us to do silly things just as just removing the metaphorical lock from the door.

このディレクトリでは、遠隔操作で設定を変更できる可能性があり、ドアのロックを外すような愚かなことも可能になります。

 

これも上の画像のフルバージョンから見つけてください。

Nikto scans can take a while to fully complete, which switch do we set in order to limit the scan to end at a certain time?

Niktoのスキャンは完全に終了するまでに時間がかかりますが、スキャンを一定の時間で終了させるためにはどのスイッチを設定すればよいのでしょうか?

これも上の画像のフルバージョンから見つけてください。

But wait, there's more! How do we list all of the plugins are available?

でも、待ってください、まだあります すべてのプラグインをリストアップするには?

nikto -list-pluginsを実行してみます。 f:id:akebono-haze:20210419224115p:plain

On the flip-side of the database, plugins represent another core component to Nikto. Which switch do we use to instruct Nikto to use plugin checks to find out of date software on the target host? Keep in mind that when testing this command we need to specify the host we intend to run this against. For submitting your answer, use only the base command with the out of date option. 

データベースとは逆に、プラグインはNiktoのもう一つのコアコンポーネントです。ターゲットホスト上の古くなったソフトウェアを見つけるためにプラグインチェックを使用するようにNiktoに指示するには、どのスイッチを使用すればよいでしょうか。このコマンドをテストする際には、このコマンドを実行する予定のホストを指定する必要があることに留意してください。回答を送信するには、out of date オプション付きの基本コマンドのみを使用してください。

 

nikto -list-pluginsの出力結果に答えがありました。

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

Finally, what if we'd like to use our plugins to run a series of standard tests against the target host?

最後に、プラグインを使って、ターゲットとなるホストに対して一連の標準的なテストを実行したい場合はどうでしょうか。

これもnikto -list-pluginsの出力結果に答えがありました。 f:id:akebono-haze:20210419224259p:plain

Task 3  Zip ZAP!

A brief quiz and tutorial over using the OWASP Zap Scanner

OWASP Zap Scanner の使用に関する簡単なクイズとチュートリアルです。

 ↓↓↓設定の参照で使う(最後には削除)

†OWASP ZAP入門-設定から診断まで-† - Qiita

Let's start simple and launch zap. This can be done in a number of ways (Commands: owasp-zap, zaproxy) or through launching it in the Kali gui

まずは簡単に、zap を起動してみましょう。これにはいくつかの方法があります (コマンド: owasp-zap, zaproxy)、または Kali ガイドで起動します。

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

OWASP ZAP起動時、以下のダイアログが出現します。

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

  • Yes, I want to persist this session with name based on the current timestamp
    現在のタイムスタンプでファイル名を付けてセッションを保存
  • Yes, I want to persist this sessin but I want to specify the name and location
    保存先のパスとファイル名を指定してセッションを保存
  • No, I do not want to persist this session at time moment in time
    継続的に保存せず、必要に応じてセッションを保存

 

ver2.4以降、セッションの保持方法が選択可能となりました。

セッションにより保持されるデータは、アクセス/スキャンしたURL、そのリクエスト/レスポンス、発見された脆弱性などです。スパイダーや動的スキャンそのもののデータは保持されません。
セッションデータを読み込むことで、設定や診断結果を再現することが可能となります。全ての場面ではなく、必要に応じて保存すればよいケースがほとんどだと思うので、「継続的に保存せず、必要に応じてセッションを保存」を選択すれば事足りると思います。
また、ダイアログ内メッセージにもある通り、この設定は「オプション > データベース」から変更が可能です。 f:id:akebono-haze:20210420222225p:plain

 

Launch ZAP, what option to we set in order to specify what we are attacking?

ZAPを起動して、攻撃対象を指定するにはどのようなオプションを設定すればよいのでしょうか。

起動した画面上の[Automated Scan]ボタンを押下します。

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

表示された画面から答えが見つかります。

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

Launch the attack against our target! Throughout the course of this attack you may notice this is very similar to Nikto. Similar to Nessus vs. OpenVAS, Nikto and ZAP and both offer different perspectives on a host and, as such, it's useful to know how to leverage both scanning tools in order to maximize your own visibility in a situation wherein 'noise' doesn't particularly matter.

ターゲットへの攻撃を開始します。この攻撃の過程で、これがNiktoと非常によく似ていることに気づくかもしれません。NessusとOpenVASの違いと同様に、NiktoとZAPはホストに対して異なる視点を提供します。そのため、「ノイズ」が特に問題にならない状況で自分の可視性を最大化するために、両方のスキャンツールを活用する方法を知っておくと便利です。

 

ZAP will discover a file that typically contains pages which well-behaved web indexing engines will read in order to know which sections of a site to avoid. What is the name of this file? (Lucky for us, our scanner isn't what we would call 'well-behaved'!)

ZAPは、お行儀の良いウェブインデックスエンジンが、サイトのどのセクションを避けるべきかを知るために読むページを含むファイルを発見します。このファイルの名前は何ですか?幸運なことに、私たちのスキャナーは「お行儀が良い」とは言えません。

 

ウィンドウの下部には、たくさんのタブがあります。[Spider]タブを選択するとhttp応答にOKを返したURIのリストが表示されます。この中に答えがあります。

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

One entry is included in the disallow section of this file, what is it?

このファイルのdisallowセクションには1つのエントリが含まれていますが、それは何ですか?

 

ブラウザでrobots.txtファイルにアクセスします。

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

ZAP will find a directory that contains images for our application, what is the path for that directory? (This is what will follows the name/ip of the website)

ZAPは、アプリケーション用の画像を含むディレクトリを見つけますが、そのディレクトリのパスはどうなっていますか?ウェブサイトの名前/IPに続くものです。

 

上の[Spider]タブの画像内に「images」の文字列があるディレクトリが答えになります。 

このウェブサイトはデフォルトで安全な接続を強制しておらず、ZAPはそれを快く思っていません。ZAPが怒っているのはどの関連クッキー?

 

ウィンドウの下部の[Alert]タブを選択すると、設問にあるcookieに関連の問題点が抽出されています。 

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

TryHackMeの様々な部屋で紹介されたクロスサイトスクリプティングは、オープンウェブ上でますます一般的になってきている悪質な攻撃です。このサイトがXSSに対して脆弱であることを知らせるために、ZAPはどのような警告を出しますか?注意していただきたいのは、このような場合にはいくつかの警告が出されることが多いのですが、ウェブクライアントに直接関係するような警告を探してください。

 

何度かOwasp ZapでAttackしてみたが、この設問の答えがわからなかったので先人の知恵を拝借しました。

が、自分のKaliでAttackしても回答の内容が出てこないので、「THM AttackBox」でOwaspを実行すると出力されました。

自分のKali ・・・ Owasp 2.10.0

THM AttackBox ・・・ Owasp 2.9.0

バージョンにより出力結果が違うかも...

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

The ZAP proxy spider represents the component responsible for 'crawling' the site. What site is found to be out of scope?

ZAPプロキシースパイダーは、サイトを「クロール」する役割を担うコンポーネントを表しています。どのサイトが対象外であることがわかりますか?

 

ウィンドウの下部の[Spider]タブを選択すると、対象のIPアドレスのサイト以外が表示されています。これが設問の答えです。

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

ZAP will use primarily two methods in order to scan a website, which of these two HTTP methods requests content?

ZAPはWebサイトをスキャンするために、主に2つの方法を使用しますが、コンテンツを要求するHTTPメソッドはどちらでしょうか?

Which option attempts to submit content to the website?

どのオプションがウェブサイトにコンテンツを提出しようとするか?

 

 GETメソッドとPOSTメソッドはどちらもHTTPプロトコルでクライアントからサーバーにデータを転送するときのプロトコルです。POSTメソッドとGETメソッドの主な違いは、

  • GETはクライアントがサーバーからデータを取得するときに使う。パラメータをURLに直接付加します。
  • POSTはクライアントがサーバーにデータを追加するときに使い、パラメータがボディに入ります。
HTTPリクエスト内にはヘッダとボディが用意されています。ヘッダは送信するときに目に見える部分であり、ボディは見えない部分です。GETとPOSTの例として、ページの情報をWebサーバーに送信するとき以下のようになります。

 

完了!