Location Research Breakthrough Possible @S-Logix pro@slogix.in

Llama 3.1-Based Adaptive SSH Honeypot Interaction Using Cowrie Against Unauthorized SSH Login and Command-Execution Attempts

Description

Organizations use Secure Shell (SSH) to administer Linux servers, manage remote systems, and perform authorized command-line operations. Because SSH provides remote access to system resources, publicly exposed SSH services are frequently targeted by unauthorized login attempts, password guessing, and suspicious command interactions.

A conventional SSH honeypot can record login attempts, submitted usernames and passwords, session information, and commands entered by an interacting user. However, its interaction behavior depends on the honeypot's configuration and implementation. A conventional honeypot may not provide context-aware responses that adapt to the sequence of interactions within a session.

In this use case, Cowrie SSH Honeypot is deployed on an Ubuntu Linux virtual machine inside an isolated VirtualBox laboratory. Kali Linux is used as the controlled security-testing environment for generating authorized SSH login attempts and simulated command interactions.

A publicly available SSH honeypot dataset is used to study existing SSH interaction patterns and support the preparation and evaluation of representative test cases. The dataset is kept separate from the records generated during the laboratory experiments.

Llama 3.1, executed locally through Ollama, is integrated with Cowrie using a Python-based response-generation workflow. The integration supplies relevant session context to the language model and receives candidate responses for validation before they are returned through the honeypot interaction.

The implementation must connect the model to Cowrie's actual interaction-handling workflow. Installing Ollama and Llama 3.1 alone does not make Cowrie adaptive. Python integration code is required to manage the interaction context, request model responses, validate the output, and handle failures safely.

Cybersecurity tools such as Wireshark and Suricata can support network-level observation and monitoring of the controlled testing environment. Cowrie session logs remain the primary source for examining the simulated SSH interactions and evaluating the generated responses.

The final assessment determines whether the integrated honeypot can generate context-aware responses, record interaction evidence, handle invalid model outputs, and continue operating without executing model-generated commands on the underlying host.

The complete security-validation workflow is:
SSH Honeypot Deployment
→
Public Dataset Review
→
Controlled SSH Interaction
→
Cowrie Session Logging
→
Session Context Extraction
→
Python Integration
→
Llama 3.1 Response Generation
→
Response Validation
→
Adaptive Honeypot Interaction
→
Security Monitoring
→
Response Evaluation
→
Final Security Validation

Existing Security Problem

Application/Service: Cowrie SSH Honeypot

Cowrie is an open-source SSH and Telnet honeypot designed to record and emulate interactions with a system that appears to provide remote access.

It can capture information about login attempts and user interactions, depending on its configuration and the interaction mode being used.

In this use case, Cowrie provides the SSH honeypot environment that receives controlled login attempts and records the resulting interactions.

Existing Problem :

A conventional honeypot may use predefined responses or a fixed set of emulated commands. This can limit its ability to produce context-aware responses when an interaction changes across multiple steps.

For example, an interacting user may attempt authentication, inspect the apparent system environment, enter commands, and modify their subsequent behavior according to earlier responses. A fixed response pattern may not maintain sufficient contextual continuity across these interactions.

A language model can potentially improve the interaction by generating responses based on relevant session context. However, unconstrained model output can also introduce inconsistent responses, unsupported command results, unexpected content, and integration failures.

Therefore, the challenge is to integrate language-model-generated responses without allowing model output to execute directly on the underlying Ubuntu host.

The security problem is:
Cowrie SSH Honeypot
→
Incoming SSH Connection
→
Controlled Login Attempt
→
User Interaction and Command Input
→
Session Context Collection
→
Limited or Predefined Interaction Responses
→
Insufficient Context-Aware Interaction
→
Requirement for Adaptive Response Generation
→
LLM Integration and Response Validation
→
Safe Honeypot Interaction
→
Session Logging and Security Evaluation

The proposed solution introduces a Python-based integration between Cowrie and Llama 3.1, using Ollama as the local model runtime. Publicly available SSH honeypot data supports the study of interaction patterns, while newly collected laboratory logs are used to evaluate the implemented workflow. Generated responses are validated before being returned, and model-generated content is never executed directly as host commands.

Attack

Specific Attack: Unauthorized SSH Login and Simulated Command-Execution Attempts Against a Cowrie SSH Honeypot

The controlled attack scenario evaluates how the adaptive SSH honeypot responds to unauthorized login attempts and subsequent command interactions.

Kali Linux is used to generate authorized test traffic against the Cowrie SSH honeypot deployed inside the isolated laboratory.

The testing includes controlled login attempts using designated test credentials and harmless command interactions intended to resemble common SSH reconnaissance behavior.

The objective is to evaluate whether Cowrie captures the interactions correctly and whether the Python-integrated Llama 3.1 workflow generates context-aware responses that remain consistent with the honeypot's intended environment.

The activity is restricted to the laboratory. No production SSH service or unauthorized external system is targeted. No generated command is executed on the underlying host.

Attack Behavior :
Kali Linux Security-Testing Environment
→
Controlled SSH Connection Attempt
→
Cowrie SSH Honeypot
→
Test Login Interaction
→
Simulated Command Input
→
Cowrie Session Logging
→
Session Context Extraction
→
Python Integration Workflow
→
Llama 3.1 Response Generation
→
Generated Response Validation
→
Response Returned Through the Honeypot
→
Session Evidence Collection
→
Response Consistency Evaluation
→
Security Finding and Validation

Security Concept

LLM-Based Adaptive Honeypot Interaction and Context-Aware Response Generation

The primary security concept is LLM-based adaptive honeypot interaction.

The concept uses a language model to generate candidate responses based on the relevant context of a controlled SSH session. Instead of relying exclusively on fixed responses, the integration can use earlier interactions to provide context for subsequent responses.

Cowrie remains responsible for handling the honeypot interaction and collecting session evidence. Python acts as the integration layer between Cowrie and the local language model. Ollama provides the model runtime, while Llama 3.1 generates candidate responses.

The integration must validate generated output before returning it to the interacting client. Generated text must not be treated as executable instructions for the underlying Ubuntu host.

A publicly available SSH honeypot dataset provides existing interaction records for studying common patterns and preparing representative evaluation cases. The dataset does not automatically train or fine-tune Llama 3.1. Unless a separate training or fine-tuning stage is implemented, the model is used for response generation rather than being trained on the dataset.

The assessment follows:
Publicly Available SSH Honeypot Dataset
→
Dataset Inspection and Preparation
→
SSH Interaction Pattern Analysis
→
Representative Test-Case Preparation
→
Cowrie SSH Honeypot Deployment
→
Controlled SSH Interaction
→
Session Context Collection
→
Python Integration
→
Ollama Model Runtime
→
Llama 3.1 Context-Aware Response Generation
→
Response Validation
→
Adaptive Honeypot Interaction
→
Cowrie Session Logging
→
Wireshark / Suricata Supporting Monitoring
→
Response Evaluation
→
Security Validation

Defensive Mechanism

The security concept defines the overall adaptive honeypot interaction strategy. The following are the specific defensive mechanisms implemented.

Controlled SSH Honeypot Deployment :

Cowrie is deployed inside an isolated laboratory to receive controlled SSH interactions without exposing the host's actual administrative shell.

Purpose: Capture unauthorized-looking SSH interactions in a controlled environment without providing real host access.

Public Dataset-Based Interaction Analysis

A publicly available SSH honeypot dataset is reviewed to understand existing login-attempt patterns and command-interaction examples. Relevant records are used to prepare representative test cases and support response evaluation.

Purpose
  • Use existing SSH interaction evidence to inform test-case preparation and evaluation.

Session Context Management

The Python integration extracts relevant information from the current Cowrie session, such as the interaction sequence and previous simulated commands. Only the necessary context is supplied to the language model.

Purpose
  • Provide relevant session information so that generated responses can reflect the current interaction.

LLM-Based Contextual Response Generation

Llama 3.1 generates candidate responses based on the session context supplied by the Python integration through Ollama.

Purpose
  • Generate context-aware honeypot responses instead of relying exclusively on predefined response text.

Generated Response Validation

The Python integration checks generated output against defined validation rules, including response format, permitted content, and unexpected output handling. Invalid or unusable responses are rejected.

Purpose
  • Prevent invalid or unsafe model output from being returned through the honeypot interaction.

Host Command-Execution Prevention

Generated model output is handled as text. It is not passed to a shell, subprocess, or host command executor. Simulated command behavior remains within the honeypot's controlled interaction environment.

Purpose
  • Prevent language-model output from executing commands on the underlying Ubuntu host.

Honeypot Isolation

Cowrie and the associated testing components operate within an isolated VirtualBox laboratory. Network connectivity is restricted to the systems required for the authorized experiment.

Purpose
  • Limit the risk of unintended interaction with production systems or external networks.

SSH Session Logging

Cowrie logs relevant session events and interactions. The Python integration records the corresponding response-generation outcomes and errors, with appropriate timestamps or session identifiers where available.

Purpose
  • Maintain evidence for reviewing SSH activity, generated responses, and integration behavior.

Network-Level Security Monitoring

Wireshark is used to inspect observable network communication, while Suricata can monitor the test network and generate alerts for traffic matching its configured detection rules.

Purpose
  • Provide supporting network evidence and identify observable suspicious SSH-related traffic patterns.

Post-Integration Validation

The integrated workflow is tested using repeated controlled interactions. Generated responses, validation failures, logs, and integration errors are reviewed against the initial baseline.

Purpose
  • Confirm that the adaptive interaction workflow operates consistently and safely under the tested conditions.

Security Tools

SSH Honeypot Tool: Cowrie SSH Honeypot

Cowrie is the primary target application in this use case. It emulates SSH interactions and records relevant session activity.

Purpose
  • Receive controlled SSH connection attempts.
  • Capture login and session interactions.
  • Record simulated command inputs.
  • Provide the honeypot interaction environment.
  • Supply session evidence for response evaluation.

AI Model: Llama 3.1

Llama 3.1 is the language model used to generate candidate responses based on the context supplied by the integration.

Purpose
  • Generate context-aware response text.
  • Use relevant previous interactions as prompt context.
  • Produce candidate responses for validation.
  • Support adaptive honeypot interaction.

Local Model Runtime: Ollama

Ollama runs the selected Llama 3.1 model locally and provides the interface used by the Python integration to submit prompts and receive generated responses.

Purpose
  • Load and run the Llama 3.1 model.
  • Receive prompts from the Python integration.
  • Return generated response text.
  • Support local model execution without requiring a hosted LLM API.

Integration and Data-Processing Tool: Python

Python implements the integration logic connecting Cowrie's interaction workflow to Ollama. It also supports dataset inspection, log processing, response validation, and evaluation.

Purpose
  • Extract relevant session context.
  • Prepare prompts for Llama 3.1.
  • Send requests to Ollama and receive responses.
  • Validate generated output.
  • Process public dataset records and laboratory logs.
  • Record integration errors and response-evaluation results.

Security Testing Platform: Kali Linux

Kali Linux provides the controlled security-testing environment for initiating authorized SSH interactions against Cowrie.

Purpose
  • Generate controlled SSH connection attempts.
  • Perform authorized login testing.
  • Submit harmless simulated command interactions.
  • Verify the observable behavior of the honeypot.
  • Support repeat testing after integration changes.

Target Platform: Ubuntu Linux

Ubuntu Linux hosts the Cowrie SSH honeypot and the associated integration components according to the selected laboratory architecture.

Purpose
  • Host the honeypot environment.
  • Run the required integration components.
  • Store session logs and experiment evidence.
  • Support configuration and validation activities.

Network Analysis Tool: Wireshark

Wireshark is used to capture and inspect network packets exchanged during the controlled testing.SSH application data is encrypted during normal SSH communication, so Wireshark cannot be relied upon to reveal the plaintext commands exchanged inside an encrypted session. Cowrie logs provide the primary command-interaction evidence.

Purpose
  • Observe SSH connection establishment and termination.
  • Inspect network-level communication patterns.
  • Identify connection timing and packet-level behavior.
  • Correlate network evidence with the laboratory test timeline.

Network Intrusion Detection Tool: Suricata

Suricata is a network intrusion detection tool that can monitor the laboratory network and generate alerts when observed traffic matches configured detection rules.Its effectiveness depends on the available traffic visibility and the rules enabled. Encrypted SSH traffic limits direct inspection of the commands carried within the connection.

Purpose
  • Monitor observable laboratory network traffic.
  • Generate alerts for matching SSH-related traffic patterns.
  • Support network-level security monitoring.
  • Provide supplementary evidence for the assessment.

Dataset Processing Libraries: pandas and NumPy

pandas and NumPy support the inspection and processing of publicly available SSH honeypot records and the laboratory's collected evaluation data.

Purpose
  • Read and organize compatible dataset records.
  • Inspect relevant fields and missing values.
  • Summarize SSH interaction patterns.
  • Prepare structured evaluation records.
  • Compare response-evaluation measurements.

Virtualization Platform: Oracle VirtualBox

VirtualBox provides the isolated virtual machines required for the laboratory.

Purpose
  • Host Ubuntu Linux and Kali Linux.
  • Configure the laboratory network.
  • Separate testing from the host environment.
  • Support repeatable experiments.
  • Reduce the risk of unintended interaction with production systems.

Process

STEP 01

Prepare the Isolated SSH Honeypot Laboratory

  • Create an isolated cybersecurity laboratory using Oracle VirtualBox.
  • Deploy Ubuntu Linux as the honeypot and integration environment and Kali Linux as the security-testing system.
  • Configure the virtual network so that the testing system can communicate with the honeypot without exposing the experiment to unintended external systems.
  • Verify network connectivity between the required laboratory components.
  • Confirm that the environment is authorized and isolated before proceeding.
Tools: Oracle VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Deploy Cowrie SSH Honeypot

  • Install and configure Cowrie on the designated Ubuntu environment using its supported installation procedure.
  • Configure the required SSH listening interface and port for the laboratory.
  • Verify that Cowrie starts successfully and accepts connections through its configured interface.
  • Confirm that Cowrie records the expected connection and session events.
  • Record the initial configuration and ensure that the honeypot does not provide access to the underlying host shell.
Tools: Cowrie + Ubuntu Linux
STEP 03

Establish the Initial Honeypot Baseline

  • Connect from the authorized Kali Linux testing environment to the Cowrie SSH service.
  • Perform controlled login attempts using designated laboratory test credentials.
  • Submit harmless simulated commands and observe the resulting interaction.
  • Review Cowrie's session logs and confirm that the expected events are recorded.
  • Record the baseline behavior before connecting the language model.
Tools: Kali Linux + Cowrie + Ubuntu Linux
STEP 04

Obtain and Inspect a Publicly Available SSH Honeypot Dataset

  • Select a publicly available SSH honeypot dataset suitable for studying SSH login activity and session interactions.
  • Review its documentation, licensing conditions, available fields, and data format.
  • Inspect the records for login attempts, session details, or command-interaction information where these fields are available.
  • Remove or exclude irrelevant, malformed, or sensitive records as appropriate.
  • Keep the public dataset separate from the data generated by the laboratory experiment.
Tools: Public SSH Honeypot Dataset + Python + pandas + NumPy
STEP 05

Prepare Dataset-Based Interaction Test Cases

  • Use the inspected dataset to study representative SSH interaction patterns.
  • Identify suitable examples of repeated login attempts, session sequences, and command-interaction patterns, depending on the available records.
  • Convert the relevant patterns into safe, controlled test cases for the isolated honeypot.
  • Do not replay untrusted dataset content as executable commands.
  • Record which test cases were derived from public data and which were created independently for laboratory validation.
  • The dataset supports testing and analysis; it does not automatically train or fine-tune Llama 3.1.
Tools: Python + pandas + NumPy + Public SSH Honeypot Dataset
STEP 06

Deploy the Ollama Model Runtime

  • Install Ollama on the designated laboratory system according to the supported installation procedure.
  • Verify that the Ollama service starts correctly.
  • Configure the runtime so that the Python integration can access it through the intended local interface.
  • Avoid exposing the model service to untrusted network interfaces.
  • Confirm that the runtime is available before attempting model integration.
Tools: Ollama + Ubuntu Linux
STEP 07

Obtain and Verify Llama 3.1

  • Obtain the intended Llama 3.1 model variant through Ollama.
  • Verify that the model has been downloaded and can generate a basic response.
  • Record the model variant and runtime configuration used for the experiment.
  • Check the available system resources and model response latency.
  • Confirm that the model responds successfully before integrating it with Cowrie.
Tools: Llama 3.1 + Ollama + Ubuntu Linux
STEP 08

Prepare the Python Integration Environment

  • Create a dedicated Python environment for the integration components.
  • Install the required Python dependencies for communicating with Ollama, processing structured records, and validating generated responses.
  • Prepare separate components for session-context preparation, model communication, response validation, and experiment logging.
  • Keep the integration code separate from the underlying host's command-execution mechanisms.
  • Verify that Python can communicate with the local Ollama runtime.
Tools: Python + Ollama + pandas + NumPy + Ubuntu Linux
STEP 09

Define the Honeypot Interaction Context

  • Identify the session information required for generating relevant responses.
  • Depending on the available Cowrie events, this may include the current session identifier, authentication outcome, earlier simulated commands, and the sequence of interactions.
  • Define a controlled representation of the apparent honeypot environment so that generated responses do not claim unsupported system behavior.
  • Limit the information supplied to the language model to what is necessary for the experiment.
Tools: Cowrie + Python + Public SSH Honeypot Dataset
STEP 10

Develop the LLM Response-Generation Workflow

  • Implement the Python workflow that receives the relevant interaction context and prepares a prompt for Llama 3.1.
  • Send the prompt to the local Ollama runtime and retrieve the generated response.
  • Maintain the distinction between the incoming simulated command and the model's candidate response.
  • Ensure that the model response is treated as text and is never passed to a host shell or command executor.
  • Record the request, response, and associated session reference for evaluation.
Tools: Python + Ollama + Llama 3.1
STEP 11

Implement Generated Response Validation

  • Develop validation checks for the responses received from Llama 3.1.
  • Check whether the response is present, follows the expected format, and complies with the rules defined for the simulated honeypot environment.
  • Reject malformed, empty, unsupported, or otherwise disallowed responses.
  • Implement a safe fallback behavior for cases where the model times out, becomes unavailable, or produces an invalid response.
  • Verify that invalid output cannot trigger command execution on the underlying host.
Tools: Python + Ollama + Llama 3.1 + Cowrie
STEP 12

Integrate the Model with Cowrie's Interaction Workflow

  • Connect the Python response-generation component to Cowrie's supported interaction-handling workflow.
  • Implement the required integration code to pass relevant session context to the model and return validated response text through the appropriate honeypot interaction mechanism.
  • Confirm that the integration does not bypass Cowrie's intended session handling or introduce direct host command execution.
  • Test the workflow with a harmless controlled interaction before expanding the test cases.
  • If the selected Cowrie interaction mode does not support the intended behavior directly, implement the required supported extension or integration layer rather than assuming that the model is automatically connected.
Tools: Cowrie + Python + Ollama + Llama 3.1 + Ubuntu Linux
STEP 13

Perform Controlled SSH Login Testing

  • Use Kali Linux to initiate authorized SSH connections to the laboratory honeypot.
  • Perform the predefined login test cases and observe how Cowrie records each interaction.
  • Verify that the Python integration receives the required context when the workflow is triggered.
  • Record whether the response-generation process succeeds, fails, or uses its fallback behavior.
  • Compare the results with the baseline established before model integration.
Tools: Kali Linux + Cowrie + Python + Ollama
STEP 14

Perform Simulated Command-Interaction Testing

  • Submit harmless command inputs that represent typical SSH interaction patterns within the isolated laboratory.
  • Test sequences containing multiple related interactions to assess whether the integration uses relevant session context.
  • Observe the generated responses and verify that they are returned through the intended honeypot workflow.
  • Confirm that the generated content remains simulated and does not execute on the underlying Ubuntu host.
  • Record inconsistent responses, unsupported claims, and validation failures.
Tools: Kali Linux + Cowrie + Python + Llama 3.1 + Ollama
STEP 15

Collect Session Logs and Supporting Security Evidence

  • Collect the Cowrie session logs produced during the controlled login and command-interaction tests.
  • Collect the Python integration records, including generated responses, validation results, error records, and response timings.
  • Use Wireshark to inspect observable network-level communication and correlate connection events with the testing timeline.
  • Configure Suricata to monitor the laboratory network and review any alerts generated by its enabled rules.
  • Keep network evidence separate from application-level command evidence, because encrypted SSH traffic does not ordinarily expose command contents to passive packet inspection.
Tools: Cowrie + Python + Wireshark + Suricata + Ubuntu Linux
STEP 16

Evaluate Response Relevance and Consistency

  • Review the public dataset-based test cases and the newly collected laboratory records separately.
  • Evaluate whether generated responses are relevant to the current interaction and whether they remain consistent with the intended simulated environment.
  • Measure response latency and the frequency of invalid or rejected responses.
  • Review whether the model successfully uses relevant session context across multiple interactions.
  • Document any limitations, including hallucinated responses, inconsistent simulated behavior, or incomplete session-context handling.
Tools: Python + pandas + NumPy + Cowrie + Llama 3.1
STEP 17

Evaluate Error Handling and Repeat Testing

  • Test the integration's behavior when Ollama is unavailable, a request times out, or the model returns an invalid response.
  • Verify that the integration uses its defined fallback behavior and that failures are recorded.
  • Repeat selected SSH interaction scenarios to check whether the responses and logging behavior remain consistent.
  • Review the network configuration and verify that the model runtime is not unnecessarily exposed.
  • Compare the repeat-test results with the original baseline and record any remaining weaknesses.
Tools: Python + Ollama + Cowrie + Kali Linux + Wireshark + Suricata
STEP 18

Perform Final Security Validation and Review

  • Review the Cowrie configuration, Python integration, model runtime, response-validation rules, and host-isolation controls.
  • Verify that the Llama 3.1 integration generates candidate responses and that only validated responses are returned through the intended honeypot interaction workflow.
  • Confirm that model-generated content cannot execute directly on the underlying Ubuntu host.
  • Review the public dataset-based analysis separately from the laboratory-generated session records.
  • Compare baseline and integrated test results, document limitations, and preserve the supporting evidence.
  • Finalize the assessment with the observed results, unresolved issues, and recommendations for further improvement.
Tools: Cowrie + Python + Ollama + Llama 3.1 + Kali Linux + Ubuntu Linux + Wireshark + Suricata

Outcome

Cowrie SSH Honeypot is deployed on Ubuntu Linux within an isolated VirtualBox laboratory to capture controlled SSH interactions.

A publicly available SSH honeypot dataset is analyzed to understand existing login-attempt patterns and prepare representative interaction test cases.

Kali Linux is used to perform controlled SSH login attempts and simulated command-interaction testing against the Cowrie honeypot

Llama 3.1 is integrated through Ollama and Python to generate context-aware candidate responses based on the current SSH session.

Python-based response validation checks generated outputs before they are returned through the honeypot interaction workflow.

Host command-execution safeguards prevent model-generated text from being executed directly on the underlying Ubuntu system.

Cowrie session logs and Python integration records provide evidence of login activity, simulated commands, generated responses, and integration errors.

Wireshark and Suricata provide supporting network-level observations and alerts for traffic matching the configured monitoring rules.

Response relevance, consistency, latency, invalid-response frequency, and error-handling behavior are evaluated using the collected laboratory records.

The complete adaptive SSH honeypot workflow is assessed through dataset analysis, controlled attack testing, LLM integration, response validation, security monitoring, and final security validation.