Watching the Bad Guys with Cowrie
Portholes
I can launch my shiny cowrie container with the following command, which exposes TCP port 2222 for my (non-public) SSH server, to query it locally:
$ docker run -d --restart=always -p 2222:2222 cowrie c52f9570af958069dba5ff5b13cf29751e7f71a689413a972b7a460b7a2f4516
The command above (with the -d switch) will keep the container running even if you log out.
I can then access the running container with the following command, which will offer a Bash prompt (abbreviate the hash if you like, which is c52f9570af95 in my case or any unique first few containers relative to other containers on the system):
$ docker exec -it c52f9570af95 bash
You can then log into and rummage around the container's filesystem. Note that you’ll connect as the cowrie user and not the superuser, root.
The next thing to do is ascertain the cowrie container’s IP Address with the output shown near the end having run the following command:
$ docker inspect c52f9570af95
As suspected (the first container often adopts this address by default), I can see this IP address (172.17.0.2) for my container as shown in Listing 3.
Listing 3: Honeypot IP Address
"Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null
Onwards now to see what’s being presented in terms of attack surface by Cowrie.
I’ll install the mighty nmap for a quick port scan (on my localhost) as follows:
$ apt install -y nmap
Next, I’ll run the port scan with this command:
$ nmap 172.17.0.2
In Figure 2, I can confirm firstly that I am connecting to the correct IP address for the container and secondly that I am only exposing TCP port 2222 from the container.

Rummaging Deeper
Now I need to try and get into the SSH daemon that is listening inside my container following the same approach (brute forcing passwords) that an attacker would if the container was publicly accessible.
Running local commands is easy as pie with the following command:
$ ssh root@172.17.0.2 -p2222
Figure 3 shows what to expect if I use root as the username and 123456 as the password. Success!
The default root user password, which I’ve just mentioned, would take a bot or attacker a few attempts to guess, but not long at all (root:root or admin:admin being more common probably).
If you edit the file cowrie.cfg inside the container, then you can affect a few config-related things, such as enabling the Telnet server, which can be found inside the etc volume in Docker. Switching on Telnet, for example, looks like this:
[telnet] enabled = yes
Now that I’ve got access to our honeypot SSH server, I'll analyze the logs that an attacker might leave behind.
Having run a few arbitrary commands inside the container, I then log back into the container through Docker. Cowrie provides the magical command, playlog, to look through what commands an attacker has run. You’ll find that running it offers an animated display of what was typed. I can choose between SSH sessions and view the animation as follows:
$ playlog /cowrie/cowrie-git/var/lib/cowrie/tty/f43b369f158dc632e06
When I was rummaging in the container over SSH, I typed the command hello, which I knew would fail as a marker. Next, having run playlog pointed at the path for the SSH session above, it’s clearly the correct SSH session that I’m watching as I’m greeted with a hello again.
Whaddaya Hear, Whaddaya Say?
You might be pleasantly surprised to hear that you can generate some pretty amazing graphs from your honeypot’s logs with Kippo-Graph. According to an online article, “The switch went real smooth as Cowrie is basically a drop in replacement for Kippo and scripts like Kippo-Graph work with it.” Cowrie will run with Kippo-Graph thanks for its Kippo provenance, so it’s worth having a look at the GitHub page. Figure 4 and Figure 5 show some examples from a website that focuses on Kippo-Graph.


As the sophisticated graphing software shows, there’s much more to Kippo and Cowrie than simply replaying commands when it comes to analysis of attacker trends.
« Previous 1 2 3 Next »
Buy Linux Magazine
Direct Download
Read full article as PDF:
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.
News
-
Armbian 23.05 is Now Available
Based on Debian 12, the latest version of the ARM/RISC-V distribution is now available to download and install.
-
Linux Mint Finally Receiving Support for Gestures
If you use the Linux Mint Cinnamon desktop, you'll be thrilled to know that 21.2 is getting support for gestures on touchscreen devices and touchpads.
-
An All-Snap Version of Ubuntu is In The Works
Along with the standard deb version of the open-source operating system, Canonical will release an-all snap version.
-
Mageia 9 Beta 2 Ready for Testing
The latest beta of the popular Mageia distribution now includes the latest kernel and plenty of updated applications.
-
KDE Plasma 6 Looks to Bring Basic HDR Support
The KWin piece of KDE Plasma now has HDR support and color management geared for the 6.0 release.
-
Bodhi Linux 7.0 Beta Ready for Testing
The latest iteration of the Bohdi Linux distribution is now available for those who want to experience what's in store and for testing purposes.
-
Changes Coming to Ubuntu PPA Usage
The way you manage Personal Package Archives will be changing with the release of Ubuntu 23.10.
-
AlmaLinux 9.2 Now Available for Download
AlmaLinux has been released and provides a free alternative to upstream Red Hat Enterprise Linux.
-
An Immutable Version of Fedora Is Under Consideration
For anyone who's a fan of using immutable versions of Linux, the Fedora team is currently considering adding a new spin called Fedora Onyx.
-
New Release of Br OS Includes ChatGPT Integration
Br OS 23.04 is now available and is geared specifically toward web content creation.