Splunkbase に Shodan へのアクセスする為にaddon がなかったので、インターネットの情報を見ながら Splunk Addon Builder を使って作ってみました。
REST APIへのアクセスし定期的にデータを取ってくるだけであれば30分くらいで作成できたので共有しておきます。
1.新しいAddonの作成
Splunk Addon Builderの画面から「New Add-on」を選択します。

すると以下の画面が表示されるので、「Configure Data Collection」を選択します。

次にAddonの名前を決めます。

そしてデータのインプット方法を聞かれるので左端の「REST API」を選択します。

次に、sourcetypeなどを設定していきます。

そして、REST APIでどんな情報をサーバに投げてデータをGETするかを設定します。
ここではサンプルとして2つ記載しておきます。
(1)指定したIPアドレスの情報を取得するサンプル
https://api.shodan.io/shodan/host/8.8.8.8?key=(API Kye)

(2)ポート22が空いている日本のドメイントップ100を取得する場合
https://api.shodan.io/shodan/host/count?key=(API Key)&query=port:22 country:JP&facets=domain:100

「テスト」ボタンでデータが正しく取得できることを確認したが、「保存」ボタンを押します。
この後、Splunkの再起動を手動で行う必要がありますので注意してください。
ちなみに私の環境(Mac)では以下のコマンドでSplunkの再起動を行いました。
/Applications/Splunk/bin/splunk restart
2.新しいインプットの作成
「Create New Input」ボタンを押し、入力の名前やデータ取得間隔をあらためて設定します。(なぜあらためて入力させているのかは不明。。。)

3.サーチの実行
すると指定した間隔でデータを取得してくれるので、トップのメニューバーから「サーチ」を選択し、以下のようなサーチ文を入力します。
sourcetype="shodan-ssh" | table facets.domain{}.value, facets.domain{}.count
すると定期的に取得したデータを元に以下のような検索結果を表示してくれます。

参考サイト:
・SplunkのAdd-on Builderで自前のアドオンを作成してみる(REST API編)-クラスメソッド株式会社-(https://dev.classmethod.jp/articles/splunk-add-on-builder-rest-api/)
・Shodan API Reference – Shodan- (https://developer.shodan.io/api)

コメントを残す