さくらのクラウドにハエトリグサ(Dionaea)を植えてみた

セキュリティミニキャンプin福岡の時、@connect24hさんにlow interactive型のハニーポットNepenthes(ウツボカヅラ)を教えていただきました。
調べてみたところ、Nepenthesは現在開発終了しており、その後継としてDionaea(ハエトリグサ)が開発されているようです。
ということで、勉強のためにさくらのクラウドにDionaeaをビルドし、インストールしてみました。

公式にインストール方法がありますが、一部うまくいかない部分があったので、そのあたりも含めて書いていきます。

環境は下記のとおりです。
・さくらのクラウド:1コア,1GB,ディスク容量20GB(最小プラン)
Ubuntu 13.04 64bit

OSは公式のマニュアルがUbuntuっぽかったので、Ubuntuを使用しました。
クラウドのパブリックアーカイブを使ってOSをインストールし、初期設定を済ませただけの状態です。



1.まずaptitudeを使って必要なパッケージをインストールします

$ sudo aptitude install libudns-dev libglib2.0-dev libssl-dev libcurl4-openssl-dev libreadline-dev libsqlite3-dev python-dev libtool automake autoconf build-essential subversion git-core flex bison pkg-config

aptitudeが入ってない場合はapt-getを使うか、

$ sudo apt-get install aptitude

としてaptitudeを入れてもOKです。


2.次に、/opt/dionaea以下にDionaeaに必要なものをビルド、インストールしていきます。
homeディレクトリに適当に作業用のディレクトリを作って、そこで作業していきます。

$ mkdir ~/temp
  • liblcfg
$ cd ~/temp
$ git clone git://git.carnivore.it/liblcfg.git liblcfg
$ cd liblcfg/code
$ autoreconf -vi
$ ./configure --prefix=/opt/dionaea
$ sudo make install
  • libemu
$ cd ~/temp
$ git clone git://git.carnivore.it/libemu.git libemu
$ cd libemu
$ autoreconf -vi
$ ./configure --prefix=/opt/dionaea
$ sudo make install
  • libnl
$ sudo apt-get install libnl-3-dev libnl-genl-3-dev libnl-nf-3-dev libnl-route-3-dev

apt-getで入れられます。

  • libev
$ cd ~/temp
$ wget http://dist.schmorp.de/libev/Attic/libev-4.04.tar.gz
$ tar xfz libev-4.04.tar.gz
$ cd libev-4.04
$ ./configure --prefix=/opt/dionaea
$ sudo make install
$ cd ~/temp
$ wget http://www.python.org/ftp/python/3.2.2/Python-3.2.2.tgz
$ tar xfz Python-3.2.2.tgz
$ cd Python-3.2.2/
$ ./configure --enable-shared --prefix=/opt/dionaea --with-computed-gotos --enable-ipv6 LDFLAGS="-Wl,-rpath=/opt/dionaea/lib/ -L/usr/lib/x86_64-linux-gnu/"
$ make
$ sudo make install
  • Cython
$ cd ~/temp
$ wget http://cython.org/release/Cython-0.15.tar.gz
$ tar xfz Cython-0.15.tar.gz
$ cd Cython-0.15
$ /opt/dionaea/bin/python3 setup.py install
  • libpcap
$ cd ~/temp
$ wget http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
$ tar xfz libpcap-1.1.1.tar.gz
$ cd libpcap-1.1.1
$ ./configure --prefix=/opt/dionaea
$ make
$ sudo make install
  • OpenSSL
$ git clone git://git.openssl.org/openssl.git
$ cd openssl
$ ./Configure shared --prefix=/opt/dionaea linux-x86_64
$ make SHARED_LDFLAGS=-Wl,-rpath,/opt/dionaea/lib
$ sudo make install

公式ではcvsで取ってきていますが、うまくいかなかったのでgitで取ってきました。

  • glib
$ apt-get install libffi-dev gettext
$ wget http://ftp.acc.umu.se/pub/gnome/sources/glib/2.31/glib-2.31.22.tar.xz
$ tar Jxvf glib-2.31.22.tar.xz
$ cd glib-2.31.22
$ ./configure --prefix=/opt/dionaea/
$ make
$ sudo make install

公式では入れていませんが、最新バージョンではDionaeaのビルド時にエラーが出たので、glib2.31.22を使いました。
詳しくは後述します。


3.最後にDionaea本体をビルド、インストールします。

$ cd ~/temp
$ git clone git://git.carnivore.it/dionaea.git dionaea
$ cd dionaea
$ autoreconf -vi
$ ./configure --with-lcfg-include=/opt/dionaea/include/ \
              --with-lcfg-lib=/opt/dionaea/lib/ \
              --with-python=/opt/dionaea/bin/python3.2 \
              --with-cython-dir=/opt/dionaea/bin \
              --with-emu-include=/opt/dionaea/include/ \
              --with-emu-lib=/opt/dionaea/lib/ \
              --with-gc-include=/usr/include/gc \
              --with-ev-include=/opt/dionaea/include \
              --with-ev-lib=/opt/dionaea/lib \
              --with-curl-config=/usr/bin/ \
              --with-ppcap-include=/opt/dionaea/include \
              --with-pcap-lib=/opt/dionaea/lib/ \
              --with-glib=/opt/dionaea/ \
              --with-ssl-lib=/opt/dionaea/lib/
$ make
$ sudo make install

以上でインストール完了です。
あとは、

sudo /opt/dionaea/bin/dionaea -l all,-debug -L '*'

とすれば起動できます。

*glibについて
バージョンは忘れましたが、aptで入れたglibを使ってDionaeaをビルドしようとすると、

dionaea.c: In function ‘main’:
dionaea.c:686:3: error: ‘g_thread_init’ is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:260) [-Werror=deprecated-declarations]
dionaea.c:689:2: error: ‘g_mutex_new’ is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:272) [-Werror=deprecated-declarations]

エラーが出て止まってしまいます。
どうやら、dionaeaのソースで使われているg_thread_initはglib-v2.3.2からなくなっているようです。
https://developer.gnome.org/glib/2.34/glib-Deprecated-Thread-APIs.html#g-thread-init
そのため、今回はglib-v2.31.22を利用しました。




記事を書いている間にDionaeaについてわかりやすく説明している記事を見つけました。
日本語の詳しい資料は少ないので、参考になると思います。
http://www.morihi-soc.net/?p=96
aptで入れられたんですね・・・

次はDionaeaのログをいい感じで見やすく表示してくれるDionaeaFRについて書こうと思います。
こっちはそんなにエラーもなく楽にできました。
また、Dionaeaで観測したログなども紹介しようと思っています。