LoginSignup
29
37

More than 5 years have passed since last update.

Recon-ngの使い方

Last updated at Posted at 2016-11-12

少し前のセキュリティツールのベスト10に入っており、Kali Linuxにも入っているツールなのですが、調べてもあまり情報が出てこないので、忘れないようにメモを残しておきます。
モジュールが多くあり、全ては把握できないので一部だけを書いています。
CLIから操作するのが好きな自分にとっては、Maltegoよりも使いやすく感じました。

Recon-ngとは

OSINT用のツールです。
そもそもOSINTが何かというと、以下の様なものです。

オープン・ソース・インテリジェンス(英: open-source intelligence)は諜報活動の分野のひとつで、他のHUMINT(ヒューミント)やSIGINT(シギント)と呼ばれる分野が主として「秘密の情報をなんとかして得る」ことを旨とするのに対し、公然に公開される情報を情報源とすることが特徴である。OSINT(オシント)と略す。

参考:オープン・ソース・インテリジェンス

Recon-ngはPythonで書かれており、フル機能を備えたWeb調査のフレームワークです。
ドメイン名を与えるとサブドメインを調べたりWHOIS情報を調べてくれたりします。
他にもTwitterやFacebookのAPIキーを与えることで投稿などを調べたりも出来るようです。
多機能なのでいまいち全部は分かってないです。

Metasploitライクに作られているので、Metasploitを使ったことがあれば何とかなると思います。

環境

本記事での出力などは以下の環境で試したものになります。

  • Kali Linux
  • Recon-ng
    • 4.6.3

使い方

分かりやすい動画があったので、それを書き起こした感じになってます。
動画見たほうが分かりやすいんですが、あとで簡単に調べようと思ったときに動画だと検索しにくいので一応残しておきます。
OSINT - recon-ng information gathering example tutorial

起動

Kali Linuxだと最初から入っているのでコマンドを打つだけで起動します。
対話式のシェルに入るので、そこでコマンドを打っていきます。

vagrant@vagrant-kali2:~$ recon-ng

    _/_/_/    _/_/_/_/    _/_/_/    _/_/_/    _/      _/            _/      _/    _/_/_/
   _/    _/  _/        _/        _/      _/  _/_/    _/            _/_/    _/  _/
  _/_/_/    _/_/_/    _/        _/      _/  _/  _/  _/  _/_/_/_/  _/  _/  _/  _/  _/_/_/
 _/    _/  _/        _/        _/      _/  _/    _/_/            _/    _/_/  _/      _/
_/    _/  _/_/_/_/    _/_/_/    _/_/_/    _/      _/            _/      _/    _/_/_/

     +---------------------------------------------------------------------------+
     |  _                     ___    _                        __                 |
     | |_)| _  _|_  |_|.|| _   |  _ |_ _  _ _  _ _|_o _  _   (_  _  _    _o_|_   |
     | |_)|(_|(_|\  | ||||_\  _|_| || (_)| |||(_| | |(_)| |  __)(/_(_|_|| | | \/ |
     |                                                                        /  |
     |              Consulting | Research | Development | Training               |
     |                     http://www.blackhillsinfosec.com                      |
     +---------------------------------------------------------------------------+

                      [recon-ng v4.6.3, Tim Tomes (@LaNMaSteR53)]

[71] Recon modules
[7]  Reporting modules
[2]  Import modules
[2]  Exploitation modules
[2]  Discovery modules

[recon-ng][default] >

ワークスペースの作成

最初にワークスペースを作ります。
何でも良いはずですが、調査対象が分かるようにすると良いかと思います。
例ではドメイン名になってました。
追加すると自動でそのワークスペース内に入ります。

[recon-ng][default] > workspaces add booking.com
[recon-ng][booking.com] >

ドメイン名の追加

調査対象となるドメイン名を追加します。

[recon-ng][booking.com] > add domains booking.com
[recon-ng][booking.com] >

サブドメインを調べる

サブドメインを調べるためのモジュールが複数用意されています。
load したあとに show info することで説明を見ることが可能です。

[recon-ng][booking.com] > load brute_hosts
[recon-ng][booking.com][brute_hosts] > show info

      Name: DNS Hostname Brute Forcer
      Path: modules/recon/domains-hosts/brute_hosts.py
    Author: Tim Tomes (@LaNMaSteR53)

Description:
  Brute forces host names using DNS. Updates the 'hosts' table with the results.

Options:
  Name      Current Value                           Required  Description
  --------  -------------                           --------  -----------
  SOURCE    default                                 yes       source of input (see 'show info' for details)
  WORDLIST  /usr/share/recon-ng/data/hostnames.txt  yes       path to hostname wordlist

Source Options:
  default        SELECT DISTINCT domain FROM domains WHERE domain IS NOT NULL
  <string>       string representing a single input
  <path>         path to a file containing a list of inputs
  query <sql>    database query returning one column of inputs

netcraft

Netcraft.comではインターネット上にあるhttpサーバのOSやuptimeを知ることが出来るので、それを使ってサブドメインを調べられるようです。

[recon-ng][booking.com] > load netcraft
[recon-ng][booking.com][netcraft] > run

-----------
BOOKING.COM
-----------
[*] URL: http://searchdns.netcraft.com/?{'restriction': 'site+ends+with', 'host': 'booking.com'}
[*] secure.booking.com
[*] m.booking.com
[*] suite.booking.com
[*] news.booking.com
[*] blog.booking.com
[*] www.booking.com
[*] suiteoffice.booking.com
[*] info.suite.booking.com
[*] your.booking.com
[*] xml.booking.com
[*] admin.booking.com
[*] sg.booking.com

-------
SUMMARY
-------
[*] 12 total (12 new) hosts found.
[recon-ng][booking.com][netcraft] >

bing

loadしようとすると複数候補がある場合は、それらが表示されます。
その中から使いたいモジュールを選んでloadすると使えます。
bing_domain_api の方はAPI keyを登録しないと使えないようなので、今回は bind_domain_web を使います。

[recon-ng][booking.com][netcraft] > load bing
[*] Multiple modules match 'bing'.

  Recon
  -----
    recon/companies-profiles/bing_linkedin
    recon/domains-hosts/bing_domain_api
    recon/domains-hosts/bing_domain_web
    recon/hosts-hosts/bing_ip

[recon-ng][booking.com][netcraft] > load recon/domains-hosts/bing_domain_web
[recon-ng][booking.com][bing_domain_web] > run

-----------
BOOKING.COM
-----------
[*] URL: https://www.bing.com/search?first=0&q=domain%3Abooking.com
[*] suitehelp.booking.com
[*] www.booking.com
[*] partnerhelp.booking.com
[*] suiteoffice.booking.com
[*] admin.booking.com
[*] m.booking.com
[*] blog.suite.booking.com
[*] workforce.booking.com
[*] federate.booking.com
[*] globalnews.booking.com
[*] suite.booking.com
[*] ask.booking.com
...
-------
SUMMARY
-------
[*] 28 total (20 new) hosts found.
[recon-ng][booking.com][bing_domain_web] >

新しく20個のサブドメインが見つかったようです。

Google

基本的にはBingと同じです。

[recon-ng][booking.com][bing_domain_web] > load google
[*] Multiple modules match 'google'.

  Recon
  -----
    recon/domains-hosts/google_site_api
    recon/domains-hosts/google_site_web

[recon-ng][booking.com][bing_domain_web] > load recon/domains-hosts/google_site_web
[recon-ng][booking.com][google_site_web] > run
(省略)

ブルートフォース

サブドメインを総当りするようです。
ですが見た感じは辞書攻撃のような感じでした。

[recon-ng][booking.com][google_site_web] > load brute_hosts
[recon-ng][booking.com][brute_hosts] > run

-----------
BOOKING.COM
-----------
[*] No Wildcard DNS entry found.
[*] 0.booking.com => No record found.
[*] 01.booking.com => No record found.
[*] 12.booking.com => No record found.
[*] 10.booking.com => No record found.
...
[*] zm.booking.com => No record found.
[*] zlog.booking.com => No record found.
[*] zulu.booking.com => No record found.
[*] zw.booking.com => No record found.

-------
SUMMARY
-------
[*] 111 total (54 new) hosts found.
[recon-ng][booking.com][brute_hosts] >

新しく54個のサブドメインが見つかりました。

ホスト一覧の確認

何のモジュールで得られたサブドメインかなどが表示可能です。

[recon-ng][booking.com][brute_hosts] > show hosts

  +------------------------------------------------------------------------------------------------------------------------------------------+
  | rowid |                           host                          | ip_address | region | country | latitude | longitude |      module     |
  +------------------------------------------------------------------------------------------------------------------------------------------+
  | 1     | secure.booking.com                                      |            |        |         |          |           | netcraft        |
  | 2     | m.booking.com                                           |            |        |         |          |           | netcraft        |
  | 3     | suite.booking.com                                       |            |        |         |          |           | netcraft        |
  | 4     | news.booking.com                                        |            |        |         |          |           | netcraft        |
  | 5     | blog.booking.com                                        |            |        |         |          |           | netcraft        |
  | 6     | www.booking.com                                         |            |        |         |          |           | netcraft        |
  | 7     | suiteoffice.booking.com                                 |            |        |         |          |           | netcraft        |
  | 8     | info.suite.booking.com                                  |            |        |         |          |           | netcraft        |
  ...
    | 80    | vpn.booking.com                                         |            |        |         |          |           | brute_hosts     |
  | 81    | w1.booking.com                                          |            |        |         |          |           | brute_hosts     |
  | 82    | w2.booking.com                                          |            |        |         |          |           | brute_hosts     |
  | 83    | w3.booking.com                                          |            |        |         |          |           | brute_hosts     |
  | 84    | facebook.itspublic.booking.com                          |            |        |         |          |           | brute_hosts     |
  | 85    | work.booking.com                                        |            |        |         |          |           | brute_hosts     |
  | 86    | xml.c.booking.com                                       |            |        |         |          |           | brute_hosts     |
  +------------------------------------------------------------------------------------------------------------------------------------------+

[*] 86 rows returned

VPNサーバの検索

僕の手元では動きませんでしたが、VPNサーバのドメイン名を探してくれるようです。

[recon-ng][booking.com] > load vpnhunter
[recon-ng][booking.com][vpnhunter] > run

-----------
BOOKING.COM
-----------
[!] IndexError: list index out of range

名前解決する

上記までの手順でドメイン名は得られましたが、IPアドレスがわからないので調べてみます。

[recon-ng][booking.com][vpnhunter] > load recon/hosts-hosts/resolve
[recon-ng][booking.com][resolve] > run
[*] secure.booking.com => 185.28.222.12
[*] m.booking.com => 185.28.222.11
[*] suite.booking.com => 54.72.150.83
[*] suite.booking.com => 52.31.1.125
[*] news.booking.com => 54.171.251.154
[*] news.booking.com => 52.18.186.198
[*] news.booking.com => 54.194.27.143
[*] blog.booking.com => 87.233.215.183
[*] www.booking.com => 185.28.222.11
[*] suiteoffice.booking.com => 52.222.205.119
[*] suiteoffice.booking.com => 52.222.205.56
...
[*] v.booking.com => 5.57.16.220
[*] video.itspublic.booking.com => 5.57.21.205
[*] video.booking.com => 5.57.21.205
[*] vpn.booking.com => 5.57.21.11
[*] w1.booking.com => 5.57.16.239
[*] w2.booking.com => 5.57.16.115
[*] w3.booking.com => 5.57.16.119
[*] facebook.itspublic.booking.com => 5.57.20.147
[*] work.booking.com => 5.57.20.147
[*] xml.c.booking.com => 5.57.16.237

-------
SUMMARY
-------
[*] 23 total (23 new) hosts found.

recon/hosts-hosts/reverse_resolve を使うことで逆引きも可能です。

地理情報を調べる

GeoIPが利用できるようですが、API keyが必要だったので検証はしてません。
必要になった人は試してみてください。

[recon-ng][booking.com] > load ipinfodb
[recon-ng][booking.com][ipinfodb] > run
[!] FrameworkException: API key 'ipinfodb_api' not found. Add API keys with the 'keys add' command.

コンタクト情報を調べる

WHOIS情報などからPOC(point of contact)を調べてくれます。
他にもPGP keyサーバから検索したり、色々な方法で連絡先を取得することが可能です。

[recon-ng][booking.com][ipinfodb] > load contact
[*] Multiple modules match 'contact'.

  Recon
  -----
    recon/companies-contacts/facebook
    recon/companies-contacts/jigsaw/point_usage
    recon/companies-contacts/jigsaw/purchase_contact
    recon/companies-contacts/jigsaw/search_contacts
    recon/companies-contacts/jigsaw_auth
    recon/companies-contacts/linkedin_auth
    recon/contacts-contacts/mailtester
    recon/contacts-contacts/mangle
    recon/contacts-contacts/unmangle
    recon/contacts-credentials/hibp_breach
    recon/contacts-credentials/hibp_paste
    recon/contacts-credentials/pwnedlist
    recon/contacts-domains/migrate_contacts
    recon/contacts-profiles/fullcontact
    recon/domains-contacts/pgp_search
    recon/domains-contacts/salesmaple
    recon/domains-contacts/whois_pocs
    recon/profiles-contacts/dev_diver
    recon/profiles-contacts/linkedin

[recon-ng][booking.com][ipinfodb] > load recon/domains-contacts/whois_pocs
[recon-ng][booking.com][whois_pocs] > run

-----------
BOOKING.COM
-----------
[*] URL: http://whois.arin.net/rest/pocs;domain=booking.com
[*] URL: http://whois.arin.net/rest/poc/BECKG4-ARIN
[*] Georgia Beck (georgia.beck@booking.com) - Whois contact (Bellevue, WA - United States)
...
[*] URL: http://whois.arin.net/rest/poc/WONGN1-ARIN
[*] NANETTE WONG (nanette.wong@booking.com) - Whois contact (San Francisco, CA - United States)
[*] URL: http://whois.arin.net/rest/poc/WONGN2-ARIN
[*] NANETTE WONG (nanette.wong@booking.com) - Whois contact (San Francisco, CA - United States)

-------
SUMMARY
-------
[*] 10 total (7 new) contacts found.
[recon-ng][booking.com][whois_pocs] > show contacts

  +---------------------------------------------------------------------------------------------------------------------------------------------+
  | rowid | first_name | middle_name | last_name  |           email            |     title     |       region      |    country    |   module   |
  +---------------------------------------------------------------------------------------------------------------------------------------------+
  | 1     | Georgia    |             | Beck       | georgia.beck@booking.com   | Whois contact | Bellevue, WA      | United States | whois_pocs |
  | 2     | PETER      |             | KRAWITZ    | peter.krawitz@booking.com  | Whois contact | Las Vegas, NV     | United States | whois_pocs |
  | 3     | SHANE      |             | MOODY      | shane.moody@booking.com    | Whois contact | Houston, TX       | United States | whois_pocs |
  | 4     | TRACY      |             | NAUGLE     | tracy.naugle@booking.com   | Whois contact | Denver, CO        | United States | whois_pocs |
  | 5     | John       |             | Platillero | john@eventbooking.com      | Whois contact | Knoxville, TN     | United States | whois_pocs |
  | 6     | PAUL       |             | WAKEFIELD  | paul.wakefield@booking.com | Whois contact | Chicago, IL       | United States | whois_pocs |
  | 7     | NANETTE    |             | WONG       | nanette.wong@booking.com   | Whois contact | San Francisco, CA | United States | whois_pocs |
  +---------------------------------------------------------------------------------------------------------------------------------------------+

[*] 7 rows returned

流出情報を調べる

得たメールアドレスが過去の流出リストに入っていたかどうかも調べることが可能です。
具体的には haveibeenpwned.com を利用しているようです。

[recon-ng][booking.com][pgp_search] > load recon/contacts-credentials/hibp_paste
[recon-ng][booking.com][hibp_paste] > show info

      Name: Have I been pwned? Paste Search
      Path: modules/recon/contacts-credentials/hibp_paste.py
    Author: Tim Tomes (@LaNMaSteR53)

Description:
  Leverages the haveibeenpwned.com API to determine if email addresses have been published to various
  paste sites. Adds compromised email addresses to the 'credentials' table.

Options:
  Name      Current Value  Required  Description
  --------  -------------  --------  -----------
  DOWNLOAD  True           yes       download pastes
  SOURCE    default        yes       source of input (see 'show info' for details)

Source Options:
  default        SELECT DISTINCT email FROM contacts WHERE email IS NOT NULL ORDER BY email
  <string>       string representing a single input
  <path>         path to a file containing a list of inputs
  query <sql>    database query returning one column of inputs

Comments:
  * Paste sites supported: Pastebin, Pastie, or Slexy

Webサーバ上のファイルの検索

robots.txt など、Webサーバにあって閲覧可能なファイルを検索します。
niktoとかと似た機能かと思います。

[recon-ng][booking.com][hibp_paste] > load interesting
[recon-ng][booking.com][interesting_files] > run
[*] http://a1.booking.com:80/robots.txt => Error
[*] http://a1.booking.com:80/sitemap.xml => Error
[*] http://a1.booking.com:80/sitemap.xml.gz => Error
[*] http://a1.booking.com:80/crossdomain.xml => Error
...
[*] http://your.booking.com:80/robots.txt => 200. 'robots.txt' found!
[*] http://your.booking.com:80/server-status => Error
[*] http://your.booking.com:80/jmx-console/ => 301
[*] http://your.booking.com:80/admin-console/ => 301
[*] http://your.booking.com:80/web-console/ => 301
[*] 26 interesting files found.
[*] ...downloaded to '/home/vagrant/.recon-ng/workspaces/booking.com/'

結果は最後の行に書いてあるディレクトリに格納されています。

結果の確認

ダッシュボード

CLIから show コマンドを使うことで各結果を見ることが可能です。

[recon-ng][booking.com][interesting_files] > show dashboard

  +----------------------------------------------------+
  |                  Activity Summary                  |
  +----------------------------------------------------+
  |                    Module                   | Runs |
  +----------------------------------------------------+
  | discovery/info_disclosure/interesting_files | 1    |
  | recon/contacts-credentials/hibp_paste       | 1    |
  | recon/domains-contacts/whois_pocs           | 1    |
  | recon/domains-hosts/bing_domain_api         | 1    |
  | recon/domains-hosts/bing_domain_web         | 1    |
  | recon/domains-hosts/brute_hosts             | 1    |
  | recon/domains-hosts/google_site_api         | 1    |
  | recon/domains-hosts/google_site_web         | 1    |
  | recon/domains-hosts/netcraft                | 1    |
  | recon/domains-hosts/vpnhunter               | 3    |
  | recon/hosts-hosts/ipinfodb                  | 4    |
  | recon/hosts-hosts/resolve                   | 1    |
  | recon/locations-locations/geocode           | 2    |
  +----------------------------------------------------+


  +----------------------------+
  |      Results Summary       |
  +----------------------------+
  |     Category    | Quantity |
  +----------------------------+
  | Domains         | 1        |
  | Companies       | 0        |
  | Netblocks       | 0        |
  | Locations       | 0        |
  | Vulnerabilities | 0        |
  | Ports           | 0        |
  | Hosts           | 109      |
  | Contacts        | 7        |
  | Credentials     | 0        |
  | Leaks           | 0        |
  | Pushpins        | 0        |
  | Profiles        | 0        |
  +----------------------------+

HTML

結果をHTMLに出力することも可能です。

[recon-ng][booking.com][interesting_files] > load html
[recon-ng][booking.com][html] > set CUSTOMER booking.com
CUSTOMER => booking.com
[recon-ng][booking.com][html] > set CREATOR testuser
CREATOR => testuser
[recon-ng][booking.com][html] > run
[*] Report generated at '/home/vagrant/.recon-ng/workspaces/default/results.html'.

まとめ

Recon-ngの使い方を簡単ですがまとめました。
あくまで調査のツールであって、実際に攻撃など診断をしたいならMetasploit Frameworkを使うようにと書いてあります。
会社の人などは外から(つまり攻撃者が)どのぐらいの情報を取得可能なのか調べてみると良いかもしれません。

29
37
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
37