Dionaea(捕蠅草) 低交互式蜜罐(http://dionaea.carnivore.it) 是 Honeynet Project 的開源項目,起始于 Google Summer of Code 2009,是Nepenthes(豬籠草)項目的后繼。Honeynet Project 是成立于 1999 年的國際性非盈利研究組織,致力于提高因特網的安全性,在蜜罐技術與互聯網安全威脅研究領域具有較大的影響力。
Dionaea 蜜罐的設計目的是誘捕惡意攻擊,獲取惡意攻擊會話與惡意代碼程序樣本。它通過模擬各種常見服務,捕獲對服務的攻擊數據,記錄攻擊源和目標IP、端口、協議類型等信息,以及完整的網絡會話過程,自動分析其中可能包含的 shellcode 及其中的函數調用和下載文件,并獲取惡意程序。
有別于高交互式蜜罐采用真實系統與服務誘捕惡意攻擊,Dionaea 被設計成低交互式蜜罐,它為攻擊者展示的所有攻擊弱點和攻擊對象都不是真正的產品系統,而是對各種系統及其提供的服務的模擬。這樣設計的好處是安裝和配置十分簡單,蜜罐系統幾乎沒有安全風險,不足之處是不完善的模擬會降低數據捕獲的能力,并容易被攻擊者識別。
Dionaea是運行于Linux上的一個應用程序,將程序運行于網絡環境下,它開放Internet上常見服務的默認端口,當有外來連接時,模擬正常服務給予反饋,同時記錄下出入網絡數據流。網絡數據流經由檢測模塊檢測后按類別進行處理,如果有 shellcode 則進行仿真執行;程序會自動下載 shellcode 中指定下載或后續攻擊命令指定下載的惡意文件。從捕獲數據到下載惡意文件,整個流程的信息都被保存到數據庫中,留待分析或提交到第三方分析機構。
Dionaea 整體結構和工作機制如圖:
Dionaea 目前版本是 0.1.0,采用源碼安裝。軟件運行依賴于以下庫:
libev,libglib,libssl,liblcfg,libemu,python,sqlite,readline,cython,lxml,libudns,libcurl,libpcap。
安裝過程詳見http://dionaea.carnivore.it/#compiling,需要注意的是安裝 Python-3.2 時注意按說明修改 setup.py 以確保 zlib 庫能正確安裝。
安裝時要注意依賴庫成功安裝,否則 Dionaea 可能不能正常工作。
OS:ubuntu 12.04 (32-bit)
# 安裝依賴
apt-get update
apt-get install aptitude
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
其余的依賴,必須從源代碼安裝,我們將安裝到路徑/opt/dionaea,所以請確保該目錄存在,并允許讀寫權限。
mkdir /opt/dionaea cd /opt/dionaea
liblcfg
git clone git://git.carnivore.it/liblcfg.git liblcfg
cd liblcfg/code
autoreconf -vi
./configure --prefix=/opt/dionaea
make install
cd ..
cd ..
libemu
git clone git://git.carnivore.it/libemu.git libemu
cd libemu
autoreconf -vi
./configure --prefix=/opt/dionaea
make install
cd ..
libnl
apt-get install libnl-3-dev libnl-genl-3-dev libnl-nf-3-dev libnl-route-3-dev
libev
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
make install
cd ..
Python 3.2
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/i386-linux-gnu/"
make
make install
cd /opt/dionaea/bin
ln python3.2 /usr/bin/python3
cd ..
sqlite 3.3.7
wget http://www.sqlite.com.cn/Upfiles/source/sqlite-3.3.7.tar.gz
tar xzf sqlite-3.3.7.tar.gz
cd sqlite-3.3.7
mkdir /home/sqlite-3.3.7
./configure --prefix=/home/sqlite-3.3.7
make && make install && make doc
cd /home/sqlite-3.3.7/bin/
ln sqlite3 /usr/bin/sqlite3
Cython
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
cd ..
libpcap
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
make install
cd ..
編譯安裝dionaea
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-udns-include=/opt/dionaea/include/ \
--with-udns-lib=/opt/dionaea/lib/ \
--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-nl-include=/opt/dionaea/include \
--with-nl-lib=/opt/dionaea/lib/ \
--with-curl-config=/usr/bin/ \
--with-pcap-include=/opt/dionaea/include \
--with-pcap-lib=/opt/dionaea/lib/
make
make install
安裝結束
Dionaea 根據命令參數運行,可選擇不同的運行環境、任務和篩選事件記錄內容。配置文件則具體規定蜜罐運行后開啟的模塊,記錄文件的保存位置和擴展功能的參數等信息。默認配置下 Dionaea 自動選擇一個網絡接口進行監聽。
Dionaea 具體的命令格式如下:
dionaea?[-c, --config=FILE] [-D, --daemonize] [-g, --group=GROUP]
[-G, --garbage=[collect|debug]] [-h, --help] [-H, --large-help]
[-l, --log-levels=WHAT] [-L, --log-domains=WHAT] [-u, --user=USER]
[-p, --pid-file=FILE] [-r, --chroot=DIR] [-V, --version] [-w, --workingdir=DIR]
選項的意義分別是:
-c:指定運行程序所使用的配置文件,默認下配置文件是/opt/dionaea/etc/dionaea.conf。
-D:后臺運行。
-g:指定啟動后切換到某個用戶組,默認下保持當前組。
-G:收集垃圾數據,用于調試內存泄露。不能用于 valgrind 軟件。
-h:幫助信息。
-H:幫助信息,包括默認值信息。
-l:選擇事件記錄級別,可以選擇 all, debug, info, message, warning, critical, error 這些值,多選使用“,”做分隔,排除使用“-”。
-L:選擇域,支持通配符“*”和“?”,多選使用“,”,排除使用“-”。
-u:指定啟動后切換到某個用戶,默認下保持當前用戶。
-p:記錄 pid 到指定文件。
-r:指定啟動后切換根目錄到指定目錄,默認下不切換。
-V:顯示版本信息。
-w:設定進程工作目錄,默認下為/opt/dionaea。
例子:
切換到 cd?/opt/dionaea/bin
# ./dionaea -l all,-debug -L '*'
# ./dionaea -l all,-debug -L 'con*,py*'
# ./dionaea -u nobody -g nogroup -r /opt/dionaea/ -w /opt/dionaea -p /opt/dionaea/var/dionaea.pid
DionaeaFR(https://github.com/RootingPuntoEs/DionaeaFR)是用于前端web展示Dionaea的數據。
安裝詳細過程:
ubuntu 12.04 默認已安裝 python 2.7.3
切換到cd /opt/,下載DionaeaFR
git clone https://github.com/RootingPuntoEs/DionaeaFR.git
安裝pip,django,nodejs
apt-get install python-pip
pip install Django
pip install pygeoip
pip install django-pagination
pip install django-tables2
pip install django-compressor
pip install django-htmlmin
pip install django-filter
django-tables2-simplefilter:
https://github.com/benjiec/django-tables2-simplefilter
python setup.py install
SubnetTree:
git clone git://git.bro-ids.org/pysubnettree.git
python setup.py install
nodejs:
http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
tar xzvf node-v0.8.16.tar.gz
cd node-v0.8.16
./configure
make
make install
npm install -g less
apt-get install python-netaddr
下載GeoIP 和 GeoLiteCity
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
解壓GeoIP 和 GeoLiteCity
gunzip GeoLiteCity.dat.gz
gunzip GeoIP.dat.gz
移動GeoIP 和 GeoLiteCity到 /opt/DionaeaFR/DionaeaFR/static
mv GeoIP.dat /opt/DionaeaFR/DionaeaFR/static
mv GeoLiteCity.dat /opt/DionaeaFR/DionaeaFR/static
修改SQLite路徑
cd /opt/DionaeaFR/DionaeaFR
vim settings.py
第17行,SQLite路徑更改為
/opt/dionaea/var/dionaea/logsql.sqlite
如果你安裝dionaea的目錄不在/opt/,那就find下。
find / -name?logsql.sqlite
把查找到的路徑替換到17行中。
運行
cd /opt/DionaeaFR
python manage.py collectstatic python manage.py runserver 0.0.0.0:8000
瀏覽器訪問:http://你的IP:8000
低交互式蜜罐的普遍弱點,即對網絡服務的模擬與真實服務存在差距,可能無法捕獲某些對環境敏感的攻擊,可以搭配其他專用服務蜜罐一起使用,來不斷進行完善。
Kippo(SSH蜜罐開源軟件)
Glastopf(Web應用攻擊誘捕軟件)
參考文檔:
本文基本上參考代恒,諸葛建偉前輩下面這2篇文章。
http://netsec.ccert.edu.cn/zhugejw/files/2011/09/Dionaea低交互式蜜罐介紹.pdf http://netsec.ccert.edu.cn/zhugejw/files/2011/09/Dionaea低交互式蜜罐部署實踐.pdf