Visualize timeline using ElasticSearch/Kibana/plaso on SIFT

2014年6月にリリースされたplaso 1.1.0で、psortの出力形式としてElasticSearchが追加されました。

2013年後半頃から、OSSの検索エンジンであるElasticSearch(http://www.elasticsearch.org/)とそのフロントエンドのKibana(http://www.elasticsearch.org/overview/kibana/)、そしてログデータを収集、管理するlogstath(http://logstash.net/)またはfluentd(http://www.fluentd.org)を組み合わせて、データを可視化するという取り組みが注目を集めています。

plasoがElasticSearchの出力をサポートしたことにより、ElasticSearch, Kibana, plasoの組み合わせでタイムライン解析の可視化が可能となります。同様の位置づけにあるプロダクトとしてSplunk(http://www.splunk.com)が有名ですが、ElasticSearch & KibanaはSplunkの代替になるともいわれています。

ここでは、SIFT 3.0(http://digital-forensics.sans.org/community/downloads)上で、ElasticSearch & kibana & plasoをセットアップするまでの手順を紹介します。基本的には以下のURLに記載されている内容がベースとなっています。

Visualize the Output
http://blog.kiddaland.net/2013/11/visualize-output.html

  1. plasoを1.1.0以上にする
    SIFT 3.0にインストールされているplasoのバージョンが1.0.2のため、1.1.0以上にアップデートする必要があります。SIFTのaptレポジトリを追加すれば関連ライブラリを全てaptで扱うことができます。以下のコマンドを実行してaptレポジトリを追加します(参考: http://plaso.kiddaland.net/developer/building-the-tool/linux)。
    $ sudo add-apt-repository ppa:sift/stable
    You are about to add the following PPA to your system:

    More info: https://launchpad.net/~sift/+archive/ubuntu/stable
    Press [ENTER] to continue or ctrl-c to cancel adding it

    gpg: keyring `/tmp/tmpDduw9z/secring.gpg' created
    gpg: keyring `/tmp/tmpDduw9z/pubring.gpg' created
    ...(略)
    gpg:               imported: 1  (RSA: 1)
    OK
    以下のコマンド実行は必須ではありませんが、インストールされているplasoのバージョンとアップデート可能なバージョン情報を確認することができます。
    $ sudo apt-cache policy python-plaso
    python-plaso:
      Installed: 1.0.2-3
      Candidate: 1.1.0-release-20140605-1ubuntu1
      Version table:
        1.1.0-release-20140605-1ubuntu1 0
            500 http://ppa.launchpad.net/sift/stable/ubuntu/ precise/main amd64 Packages
    *** 1.0.2-3 0
            100 /var/lib/dpkg/status
    現在は1.0.2-3がインストールされており、1.1.0へのアップグレードが可能なことがわかります。
    apt-getコマンドを使ってplasoをアップデートします。
    $ sudo apt-get update
    $ sudo apt-get install python-plaso
    (出力結果は長いため省略)
    この時点でアップデートが完了し、バージョンが1.1.0以上になっているはずです。
    $ log2timeline.py -v
    log2timeline - plaso back-end 1.1.0
  2. ElasticSearchをインストール、起動する
    ElasticSearch公式サイトのダウンロードページからDEBパッケージを入手します。
    以下はwgetで直接取得する例です。
    $ wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elastics…
    --2014-08-16 05:54:05--  https://download.elasticsearch.org/elasticsearch/elasticsearch/elastics…
    Resolving download.elasticsearch.org (download.elasticsearch.org)... 54.243.77.158, 54.225.133.195, 107.22.222.16
    Connecting to download.elasticsearch.org (download.elasticsearch.org)|54.243.77.158|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 26930866 (26M) [application/x-debian-package]
    Saving to: `elasticsearch-1.3.2.deb'

    100%[================...(略)...========>] 26,930,866  1.26M/s   in 38s     

    2014-08-16 05:54:43 (698 KB/s) - `elasticsearch-1.3.2.deb' saved [26930866/26930866]
     
    バージョンの部分1.3.2は2014/08/16時点でリリースされている最新のバージョンです。入手したdebパッケージをインストールします。
    $ sudo dpkg -i elasticsearch-1.3.2.deb 
    Selecting previously unselected package elasticsearch.
    (Reading database ... 184251 files and directories currently installed.)
    Unpacking elasticsearch (from elasticsearch-1.3.2.deb) ...
    Setting up elasticsearch (1.3.2) ...
    Adding system user `elasticsearch' (UID 121) ...
    Adding new user `elasticsearch' (UID 121) with group `elasticsearch' ...
    Not creating home directory `/usr/share/elasticsearch'.
    ### NOT starting elasticsearch by default on bootup, please execute
    sudo update-rc.d elasticsearch defaults 95 10
    ### In order to start elasticsearch, execute
    sudo /etc/init.d/elasticsearch start
    Processing triggers for ureadahead ...
    インストール後に起動します。
    $ sudo /etc/init.d/elasticsearch start
    * Starting Elasticsearch Server                                                                                               [ OK ] 
    正しく起動できていればデフォルトポートの9200, 9300番でリッスンしているはずです。
    $ sudo netstat -antlp
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    ...(略)
    tcp6       0      0 :::9200                 :::*                    LISTEN      7915/java       
    tcp6       0      0 :::9300                 :::*                    LISTEN      7915/java       
    ...(略)
  3. PyElasticSearchモジュールをインストールする
    plasoのElasticSearch形式の出力を扱うためにpyelasticsearchが必要です。
    まず、gitレポジトリを取得します。
    $ git clone https://github.com/rhec/pyelasticsearch.git
    Cloning into 'pyelasticsearch'...
    remote: Counting objects: 1582, done.
    remote: Total 1582 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (1582/1582), 376.54 KiB | 87 KiB/s, done.
    Resolving deltas: 100% (948/948), done.
    次にビルドします。
    $ cd pyelasticsearch/
    $ python setup.py build
    running build
    ...(略)
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pyelasticsearch.egg-info/SOURCES.txt'
    root権限でインストールします。
    $ sudo python setup.py install
    running install
    Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
    /usr/bin/python -E -c pass
    TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
    ...(略)
    Using /usr/lib/python2.7/dist-packages
    Finished processing dependencies for pyelasticsearch==0.6.1
    この段階でElastiSearchのOutputモジュールが有効になっているはずです。
    $ psort.py -o list

    ******************************** Output Modules ********************************
        L2tcsv : CSV format used by log2timeline, with 17 fixed fields.
        L2ttln : Extended seven field pipe deliminated TLN; L2T 0.65 style.
      Elastic : Saves the events into an ElasticSearch database.
      Dynamic : Dynamic selection of fields for a separated value output format.
        Rawpy : Prints out a "raw" interpretation of the EventObject.
          Raw : Prints out a "raw" interpretation of the EventObject protobuf.
        Sql4n6 : Saves the data in a SQLite database, used by the tool 4n6Time.
      Pstorage : Dumps event objects to a plaso storage file.
          Tln : Five field TLN pipe deliminated outputter.
    --------------------------------------------------------------------------------
    Elasticの行があればここまでの手順は正しくできています。
  4. Kibanaをインストールする
    KibanaはWebアプリケーションでありWebサーバが必要なため、nginxをインストールします。
    $ sudo apt-get install nginx
    (出力結果は省略)
    ElasticSearch公式サイト内のKibanaのページからtar.gzパッケージを入手します。
    以下はwgetで直接取得する例です。
    $ wget https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
    --2014-08-16 06:19:21--  https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
    Resolving download.elasticsearch.org (download.elasticsearch.org)... 54.243.77.158, 107.22.222.16, 54.225.133.195, ...
    Connecting to download.elasticsearch.org (download.elasticsearch.org)|54.243.77.158|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1073033 (1.0M) [application/zip]
    Saving to: `kibana-3.1.0.tar.gz'

    100%[================...(略)...========>] 1,073,033    123K/s   in 11s     

    2014-08-16 06:19:44 (95.6 KB/s) - `kibana-3.1.0.tar.gz' saved [1,073,033/1,073,033]

    バージョンの部分3.1.0は2014/08/16時点でリリースされている最新のバージョンです。入手したtar.gzを展開してアクセ
    可能な場所に配置します(ここでは/usr/share/kibana3に配置)。
    $ tar xvzf kibana-3.1.0.tar.gz 
    kibana-3.1.0/app/app.js
    kibana-3.1.0/app/components/require.config.js
    kibana-3.1.0/app/dashboards/blank.json
    ...(略)...
    kibana-3.1.0/LICENSE.md
    kibana-3.1.0/README.md
    $ sudo mv kibana-3.1.0 /usr/share/kibana3/
    nginxのサンプル用設定ファイルを取得し、有効にします。
    $ wget https://raw.github.com/elasticsearch/kibana/master/sample/nginx.conf
    --2014-08-16 06:37:13--  https://raw.github.com/elasticsearch/kibana/master/sample/nginx.conf
    ...(略)
    Saving to: `nginx.conf'

    100%[================...(略)...========>] 1,753       --.-K/s   in 0s      

    2014-08-16 06:37:35 (42.2 MB/s) - `nginx.conf' saved [1753/1753]

    $ sudo mv nginx.conf /etc/nginx/sites-available/kibana
    $ cd /etc/nginx/sites-enabled/
    $ sudo rm default 
    $ sudo ln -s ../sites-available/kibana .
     
    設定ファイルを編集してserver_name項目をホスト名に変更しておきます。
    $ sudo vi kibana

    (修正前) server_name   kibana.myhost.org
    (修正後) server_name   localhost
    変更後、nginxを起動します。
    $ sudo /etc/init.d/nginx start
    Starting nginx: nginx.
     

これで最低限の設定は完了です。本格的に運用するのであればリッスンしているポート(80, 9200, 9300)やWebサーバに対するアクセス制限を適切にしなければなりません。ブラウザでlocalhostにアクセスするとkibanaのスタート画面が表示されるはずです。

Kibana Startup

plaso用のサンプルダッシュボードのファイルを入手し、配置します。

$ wget https://plaso.googlecode.com/git/extra/plaso_kibana_example.json
--2014-08-16 07:01:47--  https://plaso.googlecode.com/git/extra/plaso_kibana_example.json
...(略)
    [                                                                                          ] 6,981       --.-K/s   in 0s      

2014-08-16 07:01:58 (40.1 MB/s) - `plaso_kibana_example.json' saved [6981]
$ cp plaso_kibana_example.json /usr/share/kibana3/app/dashboards/plaso.json

ブラウザでhttp://localhost/#/dashboard/file/plaso.jsonにアクセスするとplaso用のダッシュボード画面が出てきます。

Kibana for plaso

後は、log2timeline等で生成したplasoストレージに対して、psortをElastic出力モジュールに設定して実行します。以下はWindows 2008のサンプル証拠ファイルに対して実行した例です。

$ log2timeline.py win2008_plaso.dump win2008_sample.E01
(出力結果は省略)
$ psort.py -o Elastic win2008_plaso.dump 
[INFO] Starting new HTTP connection (1): 127.0.0.1
Inserting data............(略)................ [DONE]
ElasticSearch index name: cdbeef455c134a4898029901d70b3802
[INFO] Output processing is done.
[INFO] 
*********************************** Counter ************************************
[INFO]             Stored Events : 1515571
[INFO]           Events Included : 1515318
[INFO]        Duplicate Removals : 556038

ブラウザをリロードすればpsortで処理したイベントが読み込まれます。

Kibana plaso Analysis

この後の機能についてはまだ試していませんが、plaso用に用意されているサンプルの設定ファイルを用いた状態でもそれなりに解析等に使えそうです。注意点はplasoがアルファ版と強調しているため、正しくパースできていないイベントがあるということを考慮しなければなりません。

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.