ウェブベース偵察フレームワーク「recon-ng」
2025年6月6日
セキュリティエンジニアの曽我です。今回のtoolsシリーズ第7回は、Webベースの偵察フレームワーク「recon-ng」に ついて詳しく解説します。このツールは、Metasploitに似た操作性を持ちながら、情報収集に特化したモジュール式の フレームワークとなっています。体系的な情報収集を効率的に行いたいセキュリティエンジニアにとって、非常に強力な ツールです。
本記事では、recon-ngの基本的な使い方から実践的な活用法まで、具体的なコマンド例と出力結果を交えながら 解説します。セキュリティテストやOSINT(Open Source Intelligence:公開情報収集)に携わるエンジニアの 方々に役立つ内容となっています。
目次
- recon-ngとは
- インストール方法
- 基本的な使い方 3.1. コンソールの起動と基本操作 3.2. ワークスペースの管理 3.3. モジュールの使用
- 高度な使用方法 4.1. APIキーの設定 4.2. スクリプトの作成 4.3. データの管理とエクスポート
- 実践的な活用例 5.1. ドメイン偵察 5.2. 人物情報収集 5.3. 脆弱性情報の収集
- データ分析と活用
- まとめ
- 参考資料
1. recon-ngとは
recon-ngは、Tim Tomes(LaNMaSteR53)氏によって開発されたPythonベースの情報収集フレームワークです。Kali Linuxに標準搭載されており、Webベースの偵察活動を体系的に実行するための多数のモジュールを提供します。
recon-ngの主な特徴:
- Metasploitに似た操作性とワークフロー
- モジュール式のアーキテクチャ
- 独立したワークスペース管理
- データベースへの自動保存
- 柔軟なデータのインポート・エクスポート
- 多様なAPIとの統合
- カスタムモジュールの開発が容易
OSINT(Open Source Intelligence)の実施、ドメイン・サブドメイン探索、コンタクト情報の収集、組織の情報収集など、様々な情報収集タスクを効率的に実行できます。
2. インストール方法
Kali Linuxには標準でインストールされていますが、他のディストリビューションへのインストール方法も記載します。
Debian/Ubuntuベースのシステム:
sudo apt update
sudo apt install recon-ng
GitHubからのインストール:
git clone https://github.com/lanmaster53/recon-ng.git
cd recon-ng
pip install -r REQUIREMENTS
インストールが完了したら、以下のコマンドでrecon-ngを起動できます:
recon-ng
出力例:
_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/
_/ _/ _/ _/ _/ _/ _/_/ _/ _/ _/
_/_/_/ _/_/_/ _/ _/ _/ _/ _/ _/ _/_/_/
_/ _/ _/ _/ _/ _/ _/ _/_/ _/ _/
_/ _/ _/_/_/_/ _/_/_/ _/_/_/ _/ _/ _/ _/
[recon-ng v5.1.2, Tim Tomes (@lanmaster53)]
[*] No modules enabled/installed.
[recon-ng][default] >
3. 基本的な使い方
3.1. コンソールの起動と基本操作
recon-ngを起動すると、対話型のコンソールが表示されます。基本的なコマンドは以下の通りです:
help # コマンド一覧の表示
marketplace info # インストール可能なモジュールの情報表示
marketplace search # モジュールの検索
marketplace install # モジュールのインストール
modules search # インストール済みモジュールの検索
modules load # モジュールのロード
back # モジュールからの戻る
exit # recon-ngの終了
例えば、利用可能なすべてのモジュールを確認するには:
[recon-ng][default] > marketplace search
特定のキーワードでモジュールを検索するには:
[recon-ng][default] > marketplace search whois
出力例:
+-----------------------------------------------------------------------------------+
| Path | Version | Status | Updated | D | K |
+-----------------------------------------------------------------------------------+
| recon/domains-contacts/whois_pocs | 1.0 | not installed | 2019-06-24 | | |
| recon/domains-domains/whois_pocs | 1.0 | not installed | 2019-06-24 | | |
+-----------------------------------------------------------------------------------+
D = Has dependencies. K = Requires keys.
3.2. ワークスペースの管理
recon-ngでは、異なるプロジェクトごとにワークスペースを作成して管理できます:
# ワークスペース一覧の表示
[recon-ng][default] > workspaces list
# 新しいワークスペースの作成
[recon-ng][default] > workspaces create example.com
# ワークスペースの切り替え
[recon-ng][default] > workspaces select example.com
[recon-ng][example.com] >
ワークスペースを作成することで、対象ごとに収集したデータを分離して管理できます。
3.3. モジュールの使用
モジュールをインストールしてロードするには:
# モジュールのインストール
[recon-ng][example.com] > marketplace install recon/domains-hosts/brute_hosts
# モジュールのロード
[recon-ng][example.com] > modules load recon/domains-hosts/brute_hosts
モジュールをロードしたら、そのモジュールのオプションを確認して設定します:
[recon-ng][example.com][brute_hosts] > info
Name: DNS Hostname Brute Forcer
Author: Tim Tomes (@lanmaster53)
Version: 1.0
Description:
Brute forces host names using DNS. Updates the 'hosts' table with the results.
Options:
Name Current Value Required Description
-------- ------------- -------- -----------
DOMAIN example.com yes domain to brute force
SOURCE default yes source of hosts input (default, <hostname>, DB)
WORDLIST default yes wordlist file of subdomains to test
[recon-ng][example.com][brute_hosts] > options set WORDLIST /usr/share/wordlists/subdomains.txt
オプションを設定したら、モジュールを実行します:
[recon-ng][example.com][brute_hosts] > run
出力例:
--------------
SUBDOMAIN1.EXAMPLE.COM
--------------
[*] www.example.com => 93.184.216.34
[*] mail.example.com => 93.184.216.36
[*] dev.example.com => 93.184.216.39
...
[*] 12 total (12 new) hosts found.
4. 高度な使用方法
4.1. APIキーの設定
多くのモジュールはAPIキーを必要とします。APIキーを設定するには:
# 必要なAPIキーの確認
[recon-ng][example.com] > marketplace search api
[recon-ng][example.com] > keys list
# APIキーの追加
[recon-ng][example.com] > keys add shodan_api 12345ABCDEF67890
# APIキーの確認
[recon-ng][example.com] > keys list
APIキーを設定することで、Shodan、VirusTotal、Hunter.ioなどの外部サービスを活用した高度な情報収集が可能になります。
4.2. スクリプトの作成
繰り返し実行する一連のコマンドを自動化するためのスクリプトを作成できます:
# スクリプトファイルの作成
cat > subdomain_enum.rc << EOF
workspaces select example.com
modules load recon/domains-hosts/brute_hosts
options set DOMAIN example.com
options set WORDLIST /usr/share/wordlists/subdomains.txt
run
modules load recon/domains-hosts/google_site_web
options set DOMAIN example.com
run
exit
EOF
# スクリプトの実行
recon-ng -r subdomain_enum.rc
これにより、複数のモジュールを順番に実行する作業を自動化できます。
4.3. データの管理とエクスポート
収集したデータはデータベースに保存され、様々な形式でエクスポートできます:
# テーブル一覧の表示
[recon-ng][example.com] > show
+-----------------------------------------------------------------------------+
| Tables |
+----------------------------------------------+------------------------------+
| hosts | Contains host/ip address information
| contacts | Contains contact/email information
| credentials | Contains credential information
| ...
+----------------------------------------------+------------------------------+
# テーブルの内容表示
[recon-ng][example.com] > show hosts
# CSVへのエクスポート
[recon-ng][example.com] > db export csv /path/to/export/hosts.csv
# HTML、XML、JSONなど他の形式でのエクスポート
[recon-ng][example.com] > db export xlsx /path/to/export/hosts.xlsx
エクスポートしたデータは、さらなる分析や報告書作成に活用できます。
5. 実践的な活用例
5.1. ドメイン偵察
企業のWebプレゼンスを包括的に把握するための偵察を行います:
# 新しいワークスペースの作成
[recon-ng][default] > workspaces create target-corp
# ドメイン情報の追加
[recon-ng][target-corp] > db insert domains
domain: target-corp.com
# サブドメイン探索モジュールのインストールと実行
[recon-ng][target-corp] > marketplace install recon/domains-hosts/brute_hosts
[recon-ng][target-corp] > modules load recon/domains-hosts/brute_hosts
[recon-ng][target-corp][brute_hosts] > options set DOMAIN target-corp.com
[recon-ng][target-corp][brute_hosts] > run
# Netcraftからのサブドメイン収集
[recon-ng][target-corp] > marketplace install recon/domains-hosts/netcraft
[recon-ng][target-corp] > modules load recon/domains-hosts/netcraft
[recon-ng][target-corp][netcraft] > options set SOURCE target-corp.com
[recon-ng][target-corp][netcraft] > run
# 発見したホストの情報表示
[recon-ng][target-corp] > show hosts
これにより、対象企業のドメインとサブドメイン、関連するIPアドレスなどを包括的に収集できます。
5.2. 人物情報収集
企業の従業員やコンタクト情報を収集します:
# WHOISからの連絡先収集
[recon-ng][target-corp] > marketplace install recon/domains-contacts/whois_pocs
[recon-ng][target-corp] > modules load recon/domains-contacts/whois_pocs
[recon-ng][target-corp][whois_pocs] > run
# HunterからのEメール収集(APIキーが必要)
[recon-ng][target-corp] > keys add hunter_api YOUR_API_KEY
[recon-ng][target-corp] > marketplace install recon/domains-contacts/hunter_io
[recon-ng][target-corp] > modules load recon/domains-contacts/hunter_io
[recon-ng][target-corp][hunter_io] > run
# 収集した連絡先情報の表示
[recon-ng][target-corp] > show contacts
これにより、対象組織の連絡先情報を収集し、潜在的な攻撃ベクトル(フィッシングなど)のリスク評価が可能になります。
5.3. 脆弱性情報の収集
収集したホスト情報を基に、潜在的な脆弱性を探索します:
# Shodanを使用した脆弱性スキャン(APIキーが必要)
[recon-ng][target-corp] > keys add shodan_api YOUR_API_KEY
[recon-ng][target-corp] > marketplace install recon/hosts-ports/shodan_ip
[recon-ng][target-corp] > modules load recon/hosts-ports/shodan_ip
[recon-ng][target-corp][shodan_ip] > run
# 結果の表示
[recon-ng][target-corp] > show ports
これにより、対象組織のインターネットに露出しているサービスとその潜在的な脆弱性を特定できます。
6. データ分析と活用
recon-ngで収集したデータは、様々な形で分析・活用できます:
6.1. データの統合と可視化
収集したデータをエクスポートし、他のツールと連携して可視化します:
# すべてのデータをJSONでエクスポート
[recon-ng][target-corp] > db export json /path/to/export/all.json
# 特定のテーブルをCSVでエクスポート
[recon-ng][target-corp] > db export csv /path/to/export/hosts.csv
# Maltego、Neo4jなどの可視化ツールでの活用
エクスポートしたデータは、Maltegoなどのリンク分析ツールやNeo4jなどのグラフデータベースで可視化することで、複雑な関係性を理解しやすくなります。
6.2. レポート生成
収集したデータを基に、標準的なレポートを生成します:
# HTMLレポートの生成
[recon-ng][target-corp] > marketplace install reporting/html
[recon-ng][target-corp] > modules load reporting/html
[recon-ng][target-corp][html] > options set CREATOR "Security Engineer"
[recon-ng][target-corp][html] > options set CUSTOMER "Example Corp"
[recon-ng][target-corp][html] > options set FILENAME /path/to/report.html
[recon-ng][target-corp][html] > run
生成されたレポートは、クライアントへの報告やチーム内での情報共有に活用できます。
6.3. 攻撃ベクトルの特定
収集したデータを分析して、潜在的な攻撃ベクトルを特定します:
- メールアドレスのパターン分析(ユーザー名の命名規則など)
- 外部公開されている内部システム(開発環境、テスト環境など)
- 古いまたは脆弱なソフトウェアを実行しているサーバー
- 従業員のSNSアカウントや個人情報の露出
これらの情報は、セキュリティ改善のための推奨事項として活用できます。
7. まとめ
recon-ngは、情報収集フェーズを効率化し、体系化するための強力なフレームワークです。モジュール式のアーキテクチャと一貫したインターフェースにより、複雑な情報収集タスクを簡単に実行できます。
特に注目すべき点は、データベースへの自動保存とエクスポート機能です。これにより、収集した情報を失うことなく、後続の分析や報告書作成に活用できます。また、APIキーを設定することで、様々な外部サービスを活用した高度な情報収集が可能になります。
セキュリティエンジニアを目指す方は、recon-ngの使い方を習得することで、情報収集の効率と質を大幅に向上させることができるでしょう。このツールは、ペネトレーションテストやOSINT活動における強力な武器となります。
なお、recon-ngを含む情報収集ツールの使用は、必ず適切な許可を得た上で行い、プライバシーと法的制約を尊重することが重要です。教育目的や許可された環境でのみ使用し、倫理的なセキュリティ実践を心がけましょう。
8. 参考資料
- recon-ng 公式GitHub リポジトリ
- recon-ng Wiki
- Kali Linux Tools: recon-ng
- Black Hat USA: Advanced Reconnaissance with recon-ng
- SANS: Open Source Intelligence Gathering with recon-ng
- OSINT Framework
- The Hacker Playbook 3: Practical Guide to Penetration Testing
※本記事の内容は、教育目的および正当なセキュリティテストのためのものです。recon-ngの使用は、自分が所有または正当な許可を得た対象に限定してください。許可なく他者の情報を収集することは、プライバシー侵害や法律違反となる可能性があります。必ず適切な許可を得た上で実行してください。