3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cuckoo Sandbox on KVM(実行編)

Last updated at Posted at 2014-11-02

前回と前々回で、Cuckoo Sandboxのホストとゲスト構築についての記事を書きました。
本記事はその続きで、実行編です。
設定ファイルを修正し終われば晴れてCuckooが動くと思います。
*2015/03/19に追記

環境

  • ホストOS
  • Ubuntu 14.04
  • ゲストOS
  • Windows 7
  • KVM
  • virsh 1.2.2
  • cuckoo
  • 1.2-dev

参考

前提

  • ホストの構築は完了している
  • ゲストの構築は完了している
  • ホームディレクトリ直下にcuckooをcloneしている

設定

cuckoo.conf

大元となるファイルです。
以下ホームディレクトリ直下にcuckooがあるとすると、~/cuckoo/conf/cuckoo.confにあります。
今回はhostonly0というネットワークを作成し、ホスト側のIPアドレスは192.168.124.1となっています。
なのでipのところを書き換えます。
また、今回はVirtualBoxではなくKVMなのでKVMを使うように変えます。

~/cuckoo/conf/cuckoo.conf
[cuckoo]
- machinery = virtualbox
+ machinery = kvm

[resultserver]
- ip = 192.168.56.1
+ ip = 192.168.124.1

auxiliary.conf

オプションのモジュールの設定です。
主にネットワークのトラフィック監視用の設定にになっています。
新しく作成したネットワークのホスト側のインタフェース名はhostonlly0なので、そのように直します。

~/cuckoo/conf/auxiliary.conf
[sniffer]
- interface = vboxnet0
+ interface = hostonly0

kvm.conf

KVMの設定を書く場所です。
今回、ゲスト側のIPアドレスは192.168.124.2にしたので書き換えます。
また、VM名はWindows7にしたのでそちらも同様に書き換えます。

~/cuckoo/conf/kvm.conf
[kvm]
- machines = cuckoo1
+ machines = Windows7

- [cuckoo1]
+ [Windows7]

- label = cuckoo1
+ label = Windows7

- ip = 192.168.122.105
+ ip = 192.168.124.2

# 追記(platformも書いておかないとダメでした)
platform = windows

実行

タスクを待ち受ける

上の設定が終わっていれば実行できるはずです。
では実行してみましょう。
~/cuckoo/cuckoo.pyが実行ファイルになっています。

$ python cuckoo/cuckoo.py

            _       _                   _             _              _            _
          /\ \     /\_\               /\ \           /\_\           /\ \         /\ \
         /  \ \   / / /         _    /  \ \         / / /  _       /  \ \       /  \ \
        / /\ \ \  \ \ \__      /\_\ / /\ \ \       / / /  /\_\    / /\ \ \     / /\ \ \
       / / /\ \ \  \ \___\    / / // / /\ \ \     / / /__/ / /   / / /\ \ \   / / /\ \ \
      / / /  \ \_\  \__  /   / / // / /  \ \_\   / /\_____/ /   / / /  \ \_\ / / /  \ \_\
     / / /    \/_/  / / /   / / // / /    \/_/  / /\_______/   / / /   / / // / /   / / /
    / / /          / / /   / / // / /          / / /\ \ \     / / /   / / // / /   / / /
   / / /________  / / /___/ / // / /________  / / /  \ \ \   / / /___/ / // / /___/ / /
  / / /_________\/ / /____\/ // / /_________\/ / /    \ \ \ / / /____\/ // / /____\/ /
  \/____________/\/_________/ \/____________/\/_/      \_\_\\/_________/ \/_________/

 Cuckoo Sandbox 1.2-dev
 www.cuckoosandbox.org
 Copyright (c) 2010-2014

 Checking for updates...
 Good! You have the latest version available.

2014-10-23 02:13:06,966 [lib.cuckoo.core.scheduler] INFO: Using "kvm" machine manager
2014-10-23 02:13:07,370 [lib.cuckoo.core.scheduler] INFO: Loaded 1 machine/s
2014-10-23 02:13:07,374 [lib.cuckoo.core.scheduler] INFO: Waiting for analysis tasks.

エラーが出ていなければ正常に実行できています。
今タスクを待ち受ける状態になっています。
ここでマルウェアをsubmitしてあげると自動でVMが立ち上がり解析を始めてくれます。

タスクを登録する

~/cuckoo/util/submit.pyで解析のタスクに追加することが出来ます。
今は適当なマルウェアのバイナリを解析させてみます。

$ python ~/cuckoo/utils/submit.py ~/malware/9c7e7f47cee611b4190c7fe581699c5f1802e38ad14344146388f3d4ab7c50ea.bin
Success: File "/home/cuckoo/malware/9c7e7f47cee611b4190c7fe581699c5f1802e38ad14344146388f3d4ab7c50ea.bin" added as task with ID 9

Successと出ていれば成功です。
あとは解析が終わるのを待ちます。
デフォルトだと解析時間120秒になっているので120秒待ちます。

Webで表示

解析結果をWebで見ることが出来ます。
~/cuckoo/util/web.pyを使うとWebで表示できます。

$ python ~/cuckoo/utils/web.py
Bottle v0.12.7 server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.

このように8080番ポートで待ち受けます。
そこで
http://ホストマシンのIPアドレス:8080
でアクセスしてみます。

kobito.1413998587.297291.png

このような画面が表示されたら成功です。
Web画面からタスクを登録することも出来ます。
上の「Browse」から解析結果一覧を見ることが出来ます。

kobito.1413998647.824112.png

ということで無事に動きました!!

MongoDBに解析結果を保存する

デフォルトだと有効になっていないのですが、解析結果をMongoDBに入れることも出来ます。
ホストマシンにMongoDBをインストール済みであれば設定ファイルを書き換えるだけです。
デフォルトだとenabled = noになっているのでyesに変えて下さい。

~/cuckoo/conf/reporting.conf
[mongodb]
- enabled = no
+ enabled = yes
host = 127.0.0.1
port = 27017

次から解析結果をMongoDBにも保存してくれます。

外部のIPv6オンリーのMongoDBを使う

これはさらに余談ですが、外部のMongoDBに保存したいという欲求があると思います。
この際、上記のreporting.confhostを変えれば良いだけですが、更にIPv6で使いたい場合があるかもしれません。
その場合は

~/cuckoo/conf/reporting.conf
[mongodb]
enabled = yes
host = [IPv6のアドレス]
port = 27017

こんな感じでアドレスをブランケットで囲えばIPv6として認識されます。
MongoDB側をIPv6で利用する設定はIPv6ネットワーク経由で外部のMongoDBに接続するに書きました。

3
5
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
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?