Niktoとは #
Nikto(ニクト) は、オープンソースで開発されているWebサーバー向けの脆弱性スキャナとなります。
Perl
言語で実装されており7,000以上の危険なファイルやスクリプトを検知できます。
検査対象や検出ロジックは頻繁にアップデートされており、新しい脆弱性情報に基づいた診断を実施する事が可能です。
以下はNiktoの特徴となります。
- 7,000以上の既知脆弱性チェック
- SSL/TLS対応
- IPv6対応
- 多様な出力形式(プレーンテキスト / HTML / XML / JSON / CSVなど)
- 複数ポートのスキャン
- 最大実行時間の指定および自動停止
以下はNiktoの公式リポジトリとなっております。
Nikto web server scanner
1.Niktoの導入 #
NiktoをLinux環境に導入するには以下の2種類の方法があります。
特段のこだわりがない場合はGitでの導入をお勧めいたします。
導入方法 | メリット | デメリット |
---|---|---|
Gitでのclone | 更新が容易 | Gitコマンドと基礎知識が必要 |
ソースの取得 | Git不要で環境を固定しやすい | 手動による更新が必要 |
Gitでクローンする方法 #
Gitコマンドを利用してリポジトリをクローンするには任意のディレクトリ階層で以下のコマンドを実行します。
git clone https://github.com/sullo/nikto.git
上記を実行すると以下の用に表示されます。
クローンが完了すると「nikto
」ディレクトリが作成されます。
$ git clone https://github.com/sullo/nikto.git
Cloning into 'nikto'...
remote: Enumerating objects: 7524, done.
remote: Counting objects: 100% (515/515), done.
remote: Compressing objects: 100% (236/236), done.
remote: Total 7524 (delta 420), reused 279 (delta 279), pack-reused 7009 (from 3)
Receiving objects: 100% (7524/7524), 4.86 MiB | 25.41 MiB/s, done.
Resolving deltas: 100% (5458/5458), done.
ローカルリポジトリを最新の状態にするには以下のコマンドを実行します。
git pull
ソースを取得する方法 #
ソースコードを直接取得するには任意のディレクトリ階層でwget
コマンドを利用し以下のURLを指定します。
wget https://github.com/sullo/nikto/archive/refs/heads/master.zip
上記を実行すると以下のファイルが保存されます。
master.zip
ソースコードの取得はZIP形式となる為、以下のコマンドを利用し解凍します。
unzip master.zip
解凍が完了すると「nikto-master
」ディレクトリが作成されます。
不要となったZIPファイルは削除を実施する事を推奨いたします。
unlink master.zip
ファイル構成 #
以下はniktoのファイル構成となります。
脆弱性スキャン実施時には「program
」ディレクトリ内にある「nikto.pl
」を指定します。
nikto/
├── documentation/ # ドキュメント
├── devdocs/ # 開発者向けドキュメント
├── program/ # 実行に必要な本体ファイル群
│ ├── nikto.pl # メインスクリプト(実行ファイル)
│ ├── nikto.conf.default # 設定ファイルの雛形
│ ├── replay.pl # リクエスト再実行スクリプト
│ ├── databases/ # チェック対象の定義データベース
│ ├── plugins/ # チェック実行用のPerlプラグイン
│ ├── templates/ # レポート出力用テンプレート
│ └── docs/ # 補足説明ファイル
├── Dockerfile # コンテナ構築用ファイル
├── README.md # 基本的な使い方などの説明
├── COPYING # ライセンス
├── COPYING.LibWhisker # LibWhiskerのライセンス
└── その他設定ファイル群
2.脆弱性スキャンの実施 #
基本 #
Niktoの基本的な利用方法は以下となります。
「-h
」オプションを利用し「https://
」から始まるURLを指定してください。
デフォルトでは標準出力にスキャン結果が表示されます。
perl nikto.pl -h <対象URL>
実行例 #
今回は、私が運営・公開しているWebサービス「IPアドレス住所検索サービス」に対して、Niktoによる脆弱性スキャンを実施してみます。
実行には「perl
」環境が必要となります。
以下は実施コマンドとなります。
perl nikto.pl -h https://ip.r1999.com/
以下はスキャン結果となります。
perl nikto.pl -h https://ip.r1999.com/
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: XXXX.XXXX.XXXX
+ Target Hostname: ip.r1999.com
+ Target Port: 443
---------------------------------------------------------------------------
+ SSL Info: Subject: /CN=ip.r1999.com
Ciphers: TLS_AES_256_GCM_SHA384
Issuer: /C=US/O=Let's Encrypt/CN=R10
+ Start Time: 2025-05-20 09:00:00 (GMT9)
---------------------------------------------------------------------------
+ Server: nginx
+ /sitemap.xml: This gives a nice listing of the site content.
+ /icons/: Directory indexing found.
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8056 requests: 0 error(s) and 3 item(s) reported on remote host
+ End Time: 2025-05-20 09:05:49 (GMT9) (353 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
今回、検出された内容は以下の3件となりました。
また実行時間は「353」秒となりました。
以下は検出項目を表にした内容となります。
検出項目 | 内容 |
---|---|
/sitemap.xml | サイト構造の一覧が取得可能 |
/icons/ | ディレクトリインデックスが有効 |
/icons/README | Apacheのデフォルトファイルがそのまま存在 |
「sitemap
」については、Google等の検索エンジンのクローラー向けに意図的に公開しているものであり、情報の性質上、問題はないと判断できます。
一方で、「icons
」ディレクトリおよび「README
」ファイルについては、利用しているWebサーバーの構成情報が第三者に推測される可能性があります。
一般的には深刻ではない脆弱性とされており、安全のため無効化する対応が望ましい設定となっております。
一部の環境(クラウドサービスや共用レンタルサーバーなど)においては、権限によりWebサーバーの設定変更や不要ファイルの削除ができないケースがあります。
HTMLレポートの出力方法 #
HTML形式でのレポートを出力を行うには「-o
」と「-Format
」オプションを利用します。
以下のように「-o
」の後に「出力ファイル名」指定し、「-Format
」の後に「html
」タイプを指定します。
perl nikto.pl -h <対象URL> -o <出力ファイル名.html> -Format html
スキャン結果には内部構成やセキュリティ上のヒントとなる情報が含まれるため、Web公開領域には配置しないように注意してください。
その他にも「xml
」や「json
」、「csv
」形式で結果を保存する事ができます。
スキャン対象をファイルから読み込む方法 #
Niktoでは、複数のホストを一括でスキャンしたい場合に、スキャン対象をテキストファイルから読み込むことが可能です。
テキストファイルから実施する場合は以下の形式で指定します。
perl nikto.pl -h <ファイル名>
例えば「target-list.txt
」を作成し利用する場合は以下のコマンドとなります。
perl nikto.pl -h target-list.txt
オプション #
以下は「Nikto」のオプション一覧となります。
詳細につきましては公式ドキュメントまたはヘルプコマンドをご確認お願いいたします。
オプション | 説明(簡易) |
---|---|
-h |
スキャン対象のホストまたはURLを指定 |
-host |
-h の別名(同様に対象ホスト指定) |
-o |
スキャン結果の出力ファイル名 |
-Format |
出力形式(txt, html, csv, json など) |
-Tuning |
スキャン項目のカテゴリを指定 |
-Plugins |
実行するプラグインを指定 |
-Display |
出力内容の制御(リダイレクト、エラーなど) |
-vhost |
ホストヘッダーの指定(共用サーバーで利用) |
-port |
スキャン対象ポート(デフォルトは80) |
-ssl |
SSL(HTTPS)強制 |
-useproxy |
プロキシ経由でのスキャン |
-output |
出力ファイル名を指定(-o と同様) |
-nointeractive |
対話モードを無効化 |
-timeout |
リクエストのタイムアウト時間(秒) |
-maxtime |
スキャンの最大実行時間を指定(例:1h, 60m) |
-Save |
検出結果をファイルとして保存(レスポンス含む) |
-useragent |
User-Agent を上書き |
-id |
ベーシック認証情報(id:pass 形式) |
-nossl |
SSL を無効にする |
-ipv4 |
IPv4 のみ使用 |
-ipv6 |
IPv6 のみ使用 |
-check6 |
IPv6 が利用可能かを確認 |
-Cgidirs |
CGIディレクトリのスキャン対象を指定 |
-evasion |
IDS回避のためのエンコード手法を指定 |
-followredirects |
リダイレクト先を追跡する |
-nolookup |
DNS逆引きを無効化 |
-noslash |
URL末尾のスラッシュを除去 |
-no404 |
独自404ページの検出を無効化 |
-dbcheck |
データベースファイルの整合性をチェック |
-Option |
nikto.conf の設定を上書き |
-list-plugins |
利用可能なプラグイン一覧を表示 |
-mutate |
追加のパスやファイル名の推測スキャンを有効化 |
-mutate-options |
-mutate 使用時の詳細情報 |
-Pause |
各リクエスト間の待機時間を指定(秒) |
-key |
クライアント証明書の秘密鍵ファイル |
-RSAcert |
クライアント証明書(RSA形式)ファイル |
-root |
すべてのリクエストにプレフィックスとしてパス追加 |
-ask |
アップデート送信の可否を指定(yes/no/auto) |
-url |
-host の別名(同じ意味) |
-Version |
プラグインとDBのバージョン情報を表示 |
-Help |
オプションのヘルプを表示 |
-until |
指定時間までスキャンを継続 |
-404code |
無視するHTTPステータスコードを指定 |
-404string |
無視する文字列(404ページ識別用) |
-Userdbs |
ユーザー定義DBのみ読み込み(標準DB無効化) |
以下はHelpによるオプションの出力となります。
$ perl nikto.pl -Help
Options:
-ask+ Whether to ask about submitting updates
yes Ask about each (default)
no Don't ask, don't send
auto Don't ask, just send
-check6 Check if IPv6 is working (connects to ipv6.google.com or value set in nikto.conf)
-Cgidirs+ Scan these CGI dirs: "none", "all", or values like "/cgi/ /cgi-a/"
-config+ Use this config file
-Display+ Turn on/off display outputs:
1 Show redirects
2 Show cookies received
3 Show all 200/OK responses
4 Show URLs which require authentication
D Debug output
E Display all HTTP errors
P Print progress to STDOUT
S Scrub output of IPs and hostnames
V Verbose output
-dbcheck Check database and other key files for syntax errors
-evasion+ Encoding technique:
1 Random URI encoding (non-UTF8)
2 Directory self-reference (/./)
3 Premature URL ending
4 Prepend long random string
5 Fake parameter
6 TAB as request spacer
7 Change the case of the URL
8 Use Windows directory separator (\)
A Use a carriage return (0x0d) as a request spacer
B Use binary value 0x0b as a request spacer
-followredirects Follow 3xx redirects to new location
-Format+ Save file (-o) format:
csv Comma-separated-value
json JSON Format
htm HTML Format
nbe Nessus NBE format
sql Generic SQL (see docs for schema)
txt Plain text
xml XML Format
(if not specified the format will be taken from the file extension passed to -output)
-Help This help information
-host+ Target host/URL
-id+ Host authentication to use, format is id:pass or id:pass:realm
-ipv4 IPv4 Only
-ipv6 IPv6 Only
-key+ Client certificate key file
-list-plugins List all available plugins, perform no testing
-maxtime+ Maximum testing time per host (e.g., 1h, 60m, 3600s)
-mutate+ Guess additional file names:
1 Test all files with all root directories
2 Guess for password file names
3 Enumerate user names via Apache (/~user type requests)
4 Enumerate user names via cgiwrap (/cgi-bin/cgiwrap/~user type requests)
5 Attempt to brute force sub-domain names, assume that the host name is the parent domain
6 Attempt to guess directory names from the supplied dictionary file
-mutate-options Provide information for mutates
-nointeractive Disables interactive features
-nolookup Disables DNS lookups
-nossl Disables the use of SSL
-noslash Strip trailing slash from URL (e.g., '/admin/' to '/admin')
-no404 Disables nikto attempting to guess a 404 page
-Option Over-ride an option in nikto.conf, can be issued multiple times
-output+ Write output to this file ('.' for auto-name)
-Pause+ Pause between tests (seconds)
-Plugins+ List of plugins to run (default: ALL)
-port+ Port to use (default 80)
-RSAcert+ Client certificate file
-root+ Prepend root value to all requests, format is /directory
-Save Save positive responses to this directory ('.' for auto-name)
-ssl Force ssl mode on port
-Tuning+ Scan tuning:
1 Interesting File / Seen in logs
2 Misconfiguration / Default File
3 Information Disclosure
4 Injection (XSS/Script/HTML)
5 Remote File Retrieval - Inside Web Root
6 Denial of Service
7 Remote File Retrieval - Server Wide
8 Command Execution / Remote Shell
9 SQL Injection
0 File Upload
a Authentication Bypass
b Software Identification
c Remote Source Inclusion
d WebService
e Administrative Console
x Reverse Tuning Options (i.e., include all except specified)
-timeout+ Timeout for requests (default 10 seconds)
-Userdbs Load only user databases, not the standard databases
all Disable standard dbs and load only user dbs
tests Disable only db_tests and load udb_tests
-useragent Over-rides the default useragent
-until Run until the specified time or duration
-url+ Target host/URL (alias of -host)
-usecookies Use cookies from responses in future requests
-useproxy Use the proxy defined in nikto.conf, or argument http://server:port
-Version Print plugin and database versions
-vhost+ Virtual host (for Host header)
-404code Ignore these HTTP codes as negative responses (always). Format is "302,301".
-404string Ignore this string in response body content as negative response (always). Can be a regular expression.
+ requires a value