The HackerNoon Newsletter How I Set Up a Cowrie Honeypot to Capture Real SSH Attacks 8/9/2025

Deploying a Cowrie Honeypot for Real-Time SSH Attack Analysis: A Comprehensive Guide by revWhiteShadow
In the ever-evolving landscape of cybersecurity, understanding the methodologies employed by malicious actors is paramount. At revWhiteShadow, we believe that proactive defense and in-depth analysis of attack vectors are crucial for safeguarding our digital infrastructure. This article delves into the intricacies of setting up and operating a Cowrie honeypot, a powerful tool designed to simulate realistic SSH attack scenarios and meticulously capture attacker behavior. Our objective is to provide a comprehensive, hands-on guide that not only details the technical implementation but also explores the analytical insights derived from the data collected, ultimately aiming to outrank existing content on this vital cybersecurity topic.
The digital world on August 9, 2025, mirrors the historical significance of technological advancements and pivotal moments. While on this very day in 1945, the devastating “Fat Man” nuclear bomb was dropped on Nagasaki, Japan, marking a somber chapter in human history, our focus within the tech realm is on innovation and understanding. We also recognize the birth of Computer Pioneer Marvin Minsky in 1927, a figure whose contributions laid the groundwork for artificial intelligence, and the historic transmission of the First Email Sent From Space in 1991, a testament to humanity’s reach into the cosmos.
This past week in technology, as highlighted by the HackerNoon Newsletter, has presented a diverse array of critical discussions. From the practical deployment of honeypots to protect against SSH attacks, to the foundational concepts of Immutable Backups for cloud security, and the burgeoning world of Real-World Assets (RWAs) on blockchain facilitated by platforms like Pharos and Morpho, the technological discourse is robust. Furthermore, advancements in Mobile AI with ONNX Runtime offer exciting possibilities for real-time applications, while discussions around the future of AI, such as Meta’s perspective on LLMs, continue to shape the field.
At revWhiteShadow, we are committed to dissecting these developments and providing actionable intelligence. Our journey into the world of honeypots begins with the Cowrie framework, a sophisticated tool for capturing the tactics, techniques, and procedures (TTPs) of attackers targeting SSH services.
Understanding the Cowrie Honeypot: A Foundation for Cyber Defense
The Cowrie honeypot is an open-source, medium-interaction honeypot designed to emulate an SSH server and, optionally, an FTP server. Its primary purpose is to attract and record the activities of unauthorized users attempting to gain access to a system. Unlike low-interaction honeypots that merely simulate banners and log connection attempts, Cowrie provides a more convincing environment, logging a wide range of attacker actions, including login attempts, commands executed, files downloaded, and credentials used. This detailed logging capability makes it an invaluable asset for security researchers and organizations seeking to understand and defend against evolving cyber threats.
The framework itself is built upon Python and is highly configurable, allowing for customization of the emulated system’s responses, the services it exposes, and the data it collects. By presenting a seemingly vulnerable system, Cowrie acts as a lure, drawing in attackers and providing a safe, controlled environment to observe their modus operandi. The data collected can then be analyzed using frameworks like the MITRE ATT&CK® to map attacker behaviors to known adversarial tactics and techniques, thereby enhancing our threat intelligence capabilities.
Why Deploy a Cowrie Honeypot? The Strategic Imperative
The decision to deploy a Cowrie honeypot stems from a strategic imperative to gain a deeper understanding of the threat landscape targeting SSH (Secure Shell) services. SSH is a critical protocol for remote server administration, but its ubiquitous use also makes it a prime target for brute-force attacks, credential stuffing, and exploitation of vulnerabilities. By deploying Cowrie, we aim to:
- Proactively Identify Attack Patterns: Observe real-time attack attempts, including the IP addresses, usernames, passwords, and commands used by attackers. This allows us to identify emerging attack trends and targeted vulnerabilities.
- Gather Threat Intelligence: Collect valuable data that can be fed into threat intelligence platforms, enriching our understanding of attacker origins, tools, and motivations.
- Develop Effective Defenses: Use the captured data to refine firewall rules, intrusion detection systems (IDS), and access control policies. Understanding how attackers attempt to bypass security measures is key to strengthening our defenses.
- Enhance Incident Response: Familiarize security teams with the types of attacks they might encounter, improving their ability to detect, respond to, and recover from actual security incidents.
- Academic and Research Purposes: Contribute to the broader cybersecurity community by sharing anonymized data and analysis of attacker behavior, fostering collaborative efforts in combating cybercrime.
Setting Up Your Cowrie Honeypot: A Step-by-Step Implementation
The deployment of a Cowrie honeypot requires careful planning and execution to ensure it is both effective in attracting attacks and secure enough not to become a compromised asset itself. We will walk through the essential steps for a robust setup.
Prerequisites: Essential System Requirements and Dependencies
Before commencing the installation of Cowrie, ensuring the system meets the necessary prerequisites is vital. We recommend a dedicated Linux-based operating system, such as Ubuntu LTS (Long Term Support) or Debian, for its stability and extensive package availability.
The core dependencies include:
- Python: Cowrie requires a recent version of Python (typically Python 3.6 or higher). It’s advisable to have Python installed system-wide.
- Pip: The Python package installer is essential for installing Cowrie and its Python dependencies.
- Virtual Environment: Using a Python virtual environment (e.g.,
venv
) is highly recommended to isolate Cowrie’s dependencies from the system’s Python packages, preventing conflicts. - Build Essentials: Various development libraries and tools are needed for compiling certain Python packages. These can usually be installed via the system’s package manager. For Ubuntu/Debian, this would be
sudo apt update && sudo apt install build-essential python3-dev python3-pip libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev
. - Git: Required for cloning the Cowrie repository from its source.
- Database (Optional but Recommended): While Cowrie can log to flat files, integrating with a database like PostgreSQL or MySQL can significantly enhance data management, querying, and analysis capabilities.
Installation and Configuration: Crafting Your Honeypot Environment
Our approach to setting up Cowrie prioritizes clarity and thoroughness. We will cover the installation from source, which offers the most flexibility.
Step 1: System Preparation and Dependency Installation
Begin by updating your system’s package list and installing the necessary development tools and Python libraries.
sudo apt update
sudo apt upgrade -y
sudo apt install -y git python3 python3-pip python3-venv build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev
Step 2: Create a Dedicated User for Cowrie
For security best practices, it is strongly advised to run Cowrie under a dedicated, non-privileged user. This limits the potential impact if the honeypot were to be compromised.
sudo adduser cowrie --disabled-password
sudo su - cowrie
Step 3: Clone the Cowrie Repository
Navigate to the home directory of the cowrie
user and clone the official Cowrie repository.
git clone https://github.com/cowrie/cowrie.git
cd cowrie
Step 4: Create and Activate a Python Virtual Environment
Inside the cowrie
directory, create a virtual environment and activate it.
python3 -m venv cowrie-env
source cowrie-env/bin/activate
Step 5: Install Cowrie and its Python Dependencies
With the virtual environment activated, install Cowrie and its required Python packages.
pip install --upgrade pip
pip install -r requirements.txt
Step 6: Configure Cowrie
The heart of Cowrie’s customization lies in its configuration files.
- Copy the Sample Configuration: Cowrie provides a sample configuration file. Copy it to create your own active configuration.
cp cowrie.cfg.dist cowrie.cfg
- Edit
cowrie.cfg
: Opencowrie.cfg
in your preferred text editor and make the following key modifications:[ssh]
Section:listen_ports
: By default, Cowrie listens on port 2222. For a more convincing honeypot, you might want to bind it to port 22. This requires running Cowrie with root privileges or using port forwarding. We recommend starting with a non-standard port like 2222 and later usingiptables
for redirection to 22 if desired.banner
: Customize the SSH banner to make it appear as a legitimate server.
[ftp]
Section: If you wish to emulate an FTP server, uncomment and configure these settings.[output_jsonlog]
Section: Enable JSON logging for structured data output, which is ideal for automated analysis.[output_textlog]
Section: Ensure text logging is also enabled for human-readable logs.[custom_files]
and[custom_commands]
: These sections allow you to define files that attackers might find and commands that Cowrie will simulate executing, adding realism.
Step 7: Setting Up Port Forwarding (Optional but Recommended)
To have attackers connect to the standard SSH port 22, you’ll need to redirect traffic from port 22 to Cowrie’s listening port (e.g., 2222). This requires root privileges.
# Assuming Cowrie listens on 2222 and you want to forward port 22
sudo iptables -t nat -A PREROUTING -p tcp --dport 22 -j REDIRECT --to-port 2222
Important Note: Persistent firewall rules require saving them. The exact method depends on your Linux distribution (e.g., iptables-persistent
on Debian/Ubuntu).
Step 8: Running Cowrie
You can run Cowrie manually for testing:
bin/cowrie start
To run Cowrie as a service for continuous operation, you can utilize systemd. Create a service file (e.g., /etc/systemd/system/cowrie.service
):
[Unit]
Description=Cowrie SSH Honeypot
After=network.target
[Service]
User=cowrie
WorkingDirectory=/home/cowrie/cowrie
ExecStart=/home/cowrie/cowrie/cowrie-env/bin/python /home/cowrie/cowrie/bin/cowrie start
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Then, enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable cowrie
sudo systemctl start cowrie
Analyzing Cowrie Data: Extracting Actionable Insights
The true value of a Cowrie honeypot lies in its ability to generate data that can be analyzed to understand attacker methodologies. Our approach focuses on turning raw logs into actionable intelligence.
Log File Locations and Formats
Cowrie logs are typically found in the log/
directory within your Cowrie installation. You will find:
cowrie.log
: A general log file with informational messages and connection details.cowrie.json
: This file contains detailed, structured JSON logs for each session, including all attacker commands, credentials, and downloaded files. This is the primary source for in-depth analysis.tty/
: This directory contains captured TTY session recordings, which are raw terminal outputs of attacker interactions.
Leveraging MITRE ATT&CK for Threat Analysis
The MITRE ATT&CK framework is an indispensable tool for categorizing and understanding the TTPs observed in our Cowrie logs. By mapping the commands and actions recorded by Cowrie to specific ATT&CK techniques, we can gain a standardized and comprehensive understanding of the threats.
For instance, an attacker attempting to gain elevated privileges might execute commands like sudo su
or exploit known privilege escalation vulnerabilities. These actions can be mapped to techniques such as T1068 - Exploitation for Privilege Escalation. Similarly, attempts to download malware or reconnaissance tools can be mapped to T1105 - Ingress Tool Transfer.
Tools and Techniques for Data Analysis
To efficiently analyze the vast amount of data generated by Cowrie, we utilize several tools and techniques:
jq
for JSON Processing: Thejq
command-line JSON processor is invaluable for filtering, transforming, and extracting specific data points fromcowrie.json
. For example, to extract all usernames and passwords used in login attempts:jq -c '{username: .username, password: .password}' log/cowrie.json | grep '"password":'
- Elasticsearch and Kibana: For more advanced analysis and visualization, we ingest Cowrie’s JSON logs into an Elasticsearch cluster and visualize the data using Kibana. This allows for interactive dashboards, time-series analysis of attack volumes, geographical mapping of attacker origins, and detailed drill-downs into specific attack sessions.
- Custom Python Scripts: We develop custom Python scripts to parse logs, correlate events, identify unique attacker fingerprints, and automatically map observed TTPs to the MITRE ATT&CK framework.
- Malware Analysis (for downloaded files): Any files downloaded by attackers are isolated and analyzed in a secure sandbox environment to understand their nature and purpose.
Common Attack Vectors Observed and Their MITRE ATT&CK Mapping
Our deployments have consistently highlighted several common attack patterns:
- Brute-Force SSH Logins: Attackers systematically try common username/password combinations.
- MITRE ATT&CK: T1110 - Brute Force (specifically variations like T1110.001 - Password Guessing).
- Exploitation of Weak Credentials: Using leaked or default credentials to gain access.
- MITRE ATT&CK: T1110 - Brute Force (specifically T1110.002 - Password Spraying) and T1078 - Valid Accounts.
- Command Execution for Reconnaissance: Running commands like
uname -a
,ls
,whoami
,id
to gather information about the system.- MITRE ATT&CK: T1082 - System Information Discovery, T1007 - System Service Discovery, T1033 - System Owner/User Discovery.
- Download of Malicious Payloads: Attempting to download scripts or binaries for further exploitation or persistence.
- MITRE ATT&CK: T1105 - Ingress Tool Transfer.
- Privilege Escalation Attempts: Trying to gain root access.
- MITRE ATT&CK: T1068 - Exploitation for Privilege Escalation, T1548 - Abuse Elevation Control Mechanisms.
- Port Scanning and Lateral Movement: Using the compromised system to scan other internal networks.
- MITRE ATT&CK: T1595 - Active Scanning, T1046 - Network Service Scanning, T1021 - Remote Services.
Advanced Cowrie Deployment Strategies and Best Practices
To maximize the effectiveness and security of our honeypot deployments, we adhere to several advanced strategies.
Honeypot Placement and Network Segmentation
The strategic placement of the Cowrie honeypot is critical. We deploy honeypots in DMZs or on segregated network segments, isolated from production systems. This ensures that any compromise of the honeypot does not directly impact sensitive internal resources. Furthermore, using dedicated IP addresses that are not associated with legitimate services can sometimes attract more opportunistic attackers.
Securing the Honeypot Host
While the honeypot itself is designed to be attacked, the underlying host system must be secured. This includes:
- Regular Patching: Keeping the host OS and all installed software up-to-date.
- Firewall Configuration: Implementing strict firewall rules on the host to only allow necessary inbound traffic to the honeypot service and outbound traffic for legitimate honeypot operations (e.g., for downloading legitimate files if configured, though this should be minimized).
- Intrusion Detection/Prevention Systems (IDS/IPS): Deploying IDS/IPS on the network segment or host to monitor for any unusual activity that might indicate a compromise beyond the honeypot’s emulation.
- Minimize Installed Software: Install only the absolute minimum software required for Cowrie to run, reducing the attack surface of the host.
Data Exfiltration and Security
Sensitive data collected by the honeypot, such as attacker credentials, must be handled with care. We ensure that logs are:
- Encrypted in Transit: When transferring logs to a secure analysis server, use encrypted protocols like SFTP or HTTPS.
- Stored Securely: The analysis server and any databases used for storing honeypot data should have robust security measures, including access controls, encryption at rest, and regular backups.
- Anonymized Appropriately: For sharing or public release of data, thorough anonymization is crucial to protect privacy and prevent re-identification.
Legal and Ethical Considerations
It is imperative to be aware of the legal and ethical implications of operating a honeypot. This includes:
- Jurisdictional Laws: Understanding the laws regarding data collection and monitoring in your specific region.
- Entrapment Concerns: Designing the honeypot to attract rather than lure individuals into illegal activity. The honeypot should appear as a passive target.
- Privacy: Handling collected data, especially if it contains personally identifiable information (PII), with strict adherence to privacy regulations.
Conclusion: Fortifying Our Defenses Through Proactive Understanding
The deployment and analysis of a Cowrie honeypot is a proactive and essential strategy for understanding the sophisticated threats that target our digital assets. By simulating realistic attack scenarios, meticulously capturing attacker TTPs, and leveraging frameworks like MITRE ATT&CK, we at revWhiteShadow gain invaluable insights that directly inform and strengthen our cybersecurity posture.
The ability to see firsthand how attackers probe systems, attempt to breach defenses, and exploit vulnerabilities provides a tangible advantage in developing robust countermeasures. The detailed logs, command captures, and file interactions observed through Cowrie allow us to refine our security policies, tune our intrusion detection systems, and develop more effective incident response plans.
As the threat landscape continues to evolve, so too must our methods of defense. The Cowrie honeypot serves as a critical intelligence-gathering tool, transforming passive observation into active defense preparation. We are committed to continuously exploring, implementing, and sharing our findings to contribute to a more secure and resilient digital future for all. This comprehensive approach to SSH attack simulation and analysis is a cornerstone of our security philosophy at revWhiteShadow.