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
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
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.