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

Half-Space Trees-Based Real-Time Network Traffic Anomaly Detection for Identifying Port-Scanning Activity Against an Ubuntu Linux Server Using Zeek

Description

Organizations use Ubuntu Linux servers to host applications, internal services, databases, and network-accessible resources. These servers communicate with other systems through network protocols and service ports.

Port scanning is a reconnaissance technique in which a source system probes multiple ports on a target server to discover accessible services. An attacker may use this information to identify exposed services and determine potential targets for further investigation or attacks.

Traditional network monitoring tools record connection activity and provide visibility into network communications. However, reviewing large volumes of connection records manually can make it difficult to identify unusual connection patterns as they occur.

In this use case, an Ubuntu Linux server is deployed as the target system within an isolated Oracle VirtualBox laboratory. Kali Linux is used to generate controlled port-scanning traffic against the authorized Ubuntu target.

Zeek monitors the laboratory network and records connection information, including source and destination addresses, ports, protocols, connection states, and timestamps. These records provide the network telemetry required for subsequent analysis. Zeek's connection logs support both live traffic monitoring and analysis of stored traffic.

Python processes the Zeek connection logs and extracts relevant network-behavior features. River provides the Half-Space Trees algorithm to analyse incoming feature records and identify observations that differ from the learned baseline.

A publicly available network traffic dataset is used for model development and evaluation. The dataset is preprocessed to ensure that its available features are compatible with the features extracted from Zeek logs.

The model's anomaly scores are then evaluated against controlled port-scanning activity generated in the isolated laboratory. Anomalous events are recorded and displayed for security investigation.

Network access controls and monitoring configurations are reviewed to reduce unnecessary exposure. The assessment is repeated after applying appropriate defensive measures to evaluate changes in detection results.

The complete security-validation workflow is:
Ubuntu Linux Server
→
Network Traffic Monitoring
→
Zeek Connection Logs
→
Network Feature Extraction
→
Half-Space Trees Analysis
→
Anomaly Scoring
→
Port-Scanning Activity Investigation
→
Security Alert Generation
→
Network Access-Control Review
→
Post-Remediation Validation

Existing Security Problem

Application/Service: Ubuntu Linux Server

Ubuntu Linux Server is the target system in this use case. It provides the operating-system environment for running network-accessible services and receiving connections from other systems.

Existing Problem :

An Ubuntu server may expose multiple network services through listening ports. If an external or internal system repeatedly probes different ports, the activity may indicate reconnaissance intended to identify accessible services.

Although Zeek records network connections, collecting connection logs alone does not automatically determine whether the observed activity represents suspicious port scanning. The connection records must be analysed to identify patterns such as repeated connection attempts, numerous destination ports, and unusual connection frequencies within a defined time window.

The security problem is:
Ubuntu Linux Server
→
Network-Accessible Services
→
Incoming Connection Attempts
→
Repeated Port Probing
→
Large Volume of Connection Events
→
Difficulty Identifying Unusual Patterns
→
Potential Port-Scanning Activity
→
Need for Continuous Anomaly Detection

The proposed solution introduces Zeek-based network monitoring, network-feature extraction, Half-Space Trees anomaly detection, public-dataset evaluation, controlled port-scanning assessment, alert generation, network access-control review, and post-remediation validation.

Attack

Specific Attack: Port-Scanning Attack Against an Ubuntu Linux Server

The controlled attack scenario evaluates whether repeated connections to different destination ports on the Ubuntu Linux server can be identified as unusual network behaviour.

Kali Linux is used to perform authorized port scanning against the designated Ubuntu target within the isolated VirtualBox laboratory.

The assessment focuses on identifying network patterns associated with port scanning, including repeated connection attempts, the number of distinct destination ports contacted by a source, connection frequency, and relevant connection states.

Half-Space Trees analyses the extracted network features to identify anomalous observations. The resulting anomaly scores are compared with the controlled test activity to evaluate whether the scanning behaviour differs from the established baseline.

Attack Behavior :
Kali Linux Testing System
→
Port-Scanning Activity
→
Multiple Connection Attempts
→
Ubuntu Linux Server
→
Zeek Connection Logging
→
Network Feature Extraction
→
Half-Space Trees Anomaly Detection
→
Anomalous Activity Review
→
Network Access-Control Assessment
→
Post-Remediation Validation

Security Concept

Continuous Network Anomaly Detection and Security Monitoring

The primary security concept is continuous network monitoring combined with streaming machine-learning-based anomaly detection.

Zeek provides network visibility by recording connection events. Python converts the recorded events into numerical features suitable for analysis, including connection frequency and distinct destination-port counts aggregated over defined time windows.

Half-Space Trees analyses these feature records incrementally and calculates anomaly scores. The scores are evaluated using a threshold established during model development and validation. Observations exceeding the configured threshold are flagged for investigation rather than automatically classified as confirmed attacks.

Publicly available network traffic data supports model development and evaluation, while controlled Kali Linux port-scanning activity provides a separate practical test of the complete monitoring workflow.

The assessment follows:
Network Architecture Review
→
Ubuntu Server Deployment
→
Zeek Network Traffic Monitoring
→
Connection Log Collection
→
Network Feature Extraction
→
Public Dataset Preparation
→
Half-Space Trees Model Development
→
Streaming Anomaly Scoring
→
Controlled Port-Scanning Assessment
→
Detection Result Validation
→
Security Alert Generation
→
Network Access-Control Review
→
Post-Remediation Validation

Defensive Mechanism

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

Continuous Network Traffic Monitoring :

Zeek continuously monitors the designated laboratory network and records relevant connection events.

Purpose: Maintain visibility into network connections involving the Ubuntu Linux server.

Network Feature Extraction

Python extracts connection-related features and aggregates relevant events within defined time windows.

Purpose
  • Convert network activity into consistent input features for machine-learning analysis.

Streaming Anomaly Detection

Half-Space Trees analyses incoming feature records and identifies observations that differ from the learned baseline.

Purpose
  • Detect unusual network behaviour for further investigation.

Anomaly Threshold Calibration

The detection threshold is selected using development and validation data rather than assumed in advance.

Purpose
  • Balance the identification of unusual activity against excessive false alerts.

Public Dataset Validation

Publicly available network traffic data is checked for feature compatibility, data quality, and suitability for the detection objective.

Purpose
  • Support systematic model development and evaluation.

Controlled Port-Scanning Assessment

Authorized scanning activity is generated from Kali Linux against the isolated Ubuntu target.

Purpose
  • Evaluate whether the monitoring pipeline identifies the intended suspicious network behaviour.

Network Access Control

Firewall rules and network restrictions are reviewed to limit unnecessary access to the Ubuntu server's services.

Purpose
  • Reduce unnecessary network exposure and restrict access to authorized systems.

Security Alert Generation

Events with qualifying anomaly scores are recorded with timestamps and supporting network details.

Purpose
  • Provide actionable evidence for security investigation.

Detection Result Validation

Anomaly results are compared against known controlled test activity and the available evaluation labels.

Purpose
  • Determine whether the detected anomalies correspond to the intended test scenarios.

Post-Remediation Validation

The network monitoring and detection workflow is repeated after applying appropriate access-control changes.

Purpose
  • Evaluate whether the defensive changes reduce unnecessary exposure while preserving required connectivity.

Security Tools

Primary Network Monitoring Tool: Zeek

Zeek monitors network traffic and generates structured connection logs. The connection records contain fields such as source and destination addresses, destination ports, protocols, timestamps, and connection states.

Purpose
  • Collect network connection events.
  • Record connection timestamps and destination ports.
  • Provide data for network-feature extraction.
  • Support identification of repeated connection patterns.
  • Preserve evidence for security investigation.

Streaming Machine-Learning Tool: River

River provides the Half-Space Trees algorithm for streaming anomaly detection. The model processes feature records incrementally and produces anomaly scores for analysis.

Purpose
  • Implement Half-Space Trees anomaly detection.
  • Analyse incoming network-feature records.
  • Identify observations that differ from the learned baseline.
  • Generate anomaly scores for configured detection thresholds.
  • Support continuous network-behaviour analysis.

Programming and Integration Tool: Python

Python connects Zeek log processing, feature extraction, machine-learning analysis, and alert generation.

Purpose
  • Read and process Zeek connection logs.
  • Extract and aggregate network features.
  • Integrate the River anomaly-detection model.
  • Record anomaly scores and detection timestamps.
  • Connect the analysis pipeline to the dashboard.

Data Processing Tool: pandas

pandas is used to organise, clean, transform, and inspect network records before they are supplied to the model.

Purpose
  • Load available dataset records.
  • Handle missing or inconsistent feature values.
  • Prepare compatible network-feature tables.
  • Aggregate connection events into time windows.
  • Support dataset and model evaluation.

Network Testing Tool: Nmap

Nmap is used from Kali Linux to conduct authorized port-scanning tests against the Ubuntu Linux server.

Purpose
  • Generate controlled port-scanning activity.
  • Identify reachable ports on the authorized target.
  • Provide reference observations for the scanning assessment.
  • Support pre-remediation and post-remediation testing.

Security Testing Platform: Kali Linux

Kali Linux provides the controlled testing environment for generating network-scanning activity.

Purpose
  • Perform authorized port-scanning tests.
  • Generate network traffic for the target server.
  • Support detection validation.
  • Provide evidence of the controlled test activity.

Target Platform: Ubuntu Linux

Ubuntu Linux provides the target server and the environment in which required network services operate.

Purpose
  • Host the target network services.
  • Receive controlled connection attempts.
  • Provide the server-side testing environment.
  • Support firewall and network-access-control configuration.

Virtualization Platform: Oracle VirtualBox

VirtualBox provides the isolated laboratory infrastructure for Ubuntu and Kali Linux virtual machines.

Purpose
  • Host the Ubuntu target server.
  • Host the Kali Linux testing system.
  • Configure isolated laboratory networking.
  • Separate controlled testing from production infrastructure.

Dashboard and Visualization Tool: Streamlit

Streamlit provides a local dashboard for presenting the monitoring results generated by the Python pipeline.

Purpose
  • Display network anomaly scores.
  • Present suspicious connection patterns.
  • Show event timestamps and relevant network details.
  • Provide a view of detection results for investigation.

Dataset and Evaluation Environment: Python-Based Analysis

Python and pandas are used to prepare publicly available network traffic data and evaluate the model using suitable reference labels where available.

Purpose
  • Prepare compatible dataset features.
  • Evaluate model behaviour against available reference information.
  • Compare results from dataset analysis and laboratory testing.
  • Record false positives and missed detections where reference labels permit.

Process

STEP 01

Prepare the Isolated Network Security Environment

  • Create an isolated cybersecurity laboratory using Oracle VirtualBox.
  • Configure Ubuntu Linux as the target server.
  • Configure Kali Linux as the authorized testing system.
  • Establish the appropriate virtual network connection between the virtual machines.
  • Assign and record the laboratory IP addresses.
  • Verify connectivity between the designated systems.
  • Confirm that all testing is restricted to the authorized laboratory.
Tools: VirtualBox + Ubuntu Linux + Kali Linux
STEP 02

Configure the Ubuntu Linux Target Server

  • Start the Ubuntu Linux virtual machine.
  • Review the server's network interfaces and IP address.
  • Identify the network services required for the assessment.
  • Confirm that the target is reachable from the designated laboratory network.
  • Review the initial firewall configuration.
  • Record the initial server and network configuration.
Tools: Ubuntu Linux + VirtualBox
STEP 03

Install and Configure Zeek

  • Install Zeek in the designated monitoring environment.
  • Identify the network interface that will observe traffic between Kali Linux and Ubuntu.
  • Configure Zeek to monitor the appropriate laboratory traffic.
  • Verify that Zeek is receiving network packets.
  • Confirm that the connection log is generated.
  • Record the initial monitoring configuration.
Tools: Zeek + Ubuntu Linux + VirtualBox
STEP 04

Establish the Normal Network-Traffic Baseline

  • Generate ordinary, authorized connections between the laboratory systems.
  • Allow Zeek to record the resulting connection events.
  • Review the generated connection logs.
  • Identify relevant fields, including timestamps, source and destination addresses, destination ports, protocols, connection states, and available packet information.
  • Collect representative normal-traffic records for baseline development.
  • Verify that the logs contain the fields required for the proposed analysis.
Tools: Zeek + Python + Ubuntu Linux
STEP 05

Obtain and Prepare the Public Network Dataset

  • Obtain a publicly available network traffic dataset appropriate for anomaly-detection research.
  • Inspect its file format and available network features.
  • Determine whether the data contains packet captures, connection records, or precomputed flow features.
  • If packet captures are supplied, process compatible captures through Zeek where feasible.
  • If flow records are supplied, map the available fields to the feature definitions used by the monitoring pipeline.
  • Clean missing or inconsistent values and document any necessary transformations.
  • Keep the dataset preparation separate from the live laboratory traffic collection.
Tools: Python + pandas + Zeek
STEP 06

Define the Network Features for Port-Scanning Analysis

  • Select features that can be extracted consistently from the available dataset and Zeek records.
  • Calculate the number of connection attempts within defined time windows.
  • Calculate the number of distinct destination ports contacted by each source within those windows.
  • Include relevant connection states and connection-frequency measurements where the required fields are available.
  • Apply consistent aggregation rules to the dataset and laboratory records.
  • Verify that the resulting feature values are suitable for model input.
Tools: Python + pandas + Zeek
STEP 07

Develop the Half-Space Trees Anomaly-Detection Pipeline

  • Install and configure the River library in the Python environment.
  • Prepare the selected network features in the format required by Half-Space Trees.
  • Configure the model parameters and the initial training or warm-up procedure.
  • Define how incoming feature records will be processed.
  • Establish how anomaly scores will be stored and associated with the original connection time windows.
  • Verify that the model processes records without feature-format errors.
Tools: Python + River + pandas
STEP 08

Evaluate the Model Using Public Dataset Records

  • Prepare the compatible dataset features for evaluation.
  • Process the records through the configured Half-Space Trees model.
  • Record the anomaly scores produced for the observations.
  • Use available reference labels, where applicable, to compare the results against known traffic categories.
  • Evaluate detection behaviour using suitable metrics where reference labels permit.
  • Document the dataset preparation, model configuration, and evaluation limitations.
Tools: Python + River + pandas
STEP 09

Generate Controlled Port-Scanning Activity

  • Use Kali Linux to conduct an authorized port scan against the Ubuntu Linux target.
  • Restrict the scan to the designated laboratory IP address.
  • Use a controlled scan configuration appropriate for the assessment.
  • Allow Zeek to monitor and record the resulting connection activity.
  • Record the scan timing and configuration so that the generated activity can be distinguished from normal traffic.
  • Avoid scanning external or unauthorized systems.
Tools: Nmap + Kali Linux + Ubuntu Linux + Zeek
STEP 10

Collect and Validate the Port-Scanning Connection Logs

  • Review the Zeek connection logs generated during the controlled scan.
  • Verify that the records correspond to the expected laboratory source and target.
  • Check destination-port information and connection timestamps.
  • Inspect connection states and the available traffic fields.
  • Compare the observed records with the scan timing and configuration.
  • Preserve the logs as evidence for the model evaluation.
Tools: Zeek + Python + Ubuntu Linux
STEP 11

Perform Real-Time Network Feature Processing

  • Configure Python to read newly available Zeek connection records continuously or at a defined short interval.
  • Parse the records into the selected feature format.
  • Aggregate the connection events into the configured time windows.
  • Calculate distinct destination-port counts and other selected network-behaviour features.
  • Check the records for missing values and incompatible data types.
  • Pass valid feature records to the anomaly-detection pipeline.
Tools: Python + pandas + Zeek
STEP 12

Detect and Record Network Anomalies

  • Process the incoming network-feature records through Half-Space Trees.
  • Calculate the anomaly score for each processed observation.
  • Apply the threshold established during model validation.
  • Flag qualifying observations for further investigation.
  • Associate each flagged observation with its time window and relevant source, destination, and port information where available.
  • Record the results without automatically treating every anomaly as a confirmed attack.
Tools: Python + River + Zeek
STEP 13

Validate Detection Results Against the Controlled Test

  • Compare the flagged observations with the recorded port-scanning activity.
  • Check whether the detected time windows overlap with the controlled scan.
  • Review the relevant source address, target address, destination-port diversity, and connection frequency.
  • Inspect any anomalous observations generated during normal traffic.
  • Record potential false positives and missed detections where the available test evidence permits.
  • Document the limitations of interpreting anomaly scores as attack classifications.
Tools: Python + pandas + River + Zeek
STEP 14

Configure the Network Anomaly Dashboard

  • Create a local dashboard using Streamlit.
  • Connect the dashboard to the Python pipeline's recorded detection results.
  • Display event timestamps and anomaly scores.
  • Present relevant source and destination information and the associated destination-port patterns.
  • Provide a view of normal and flagged observations for comparison.
  • Verify that the dashboard presents the available results accurately without inventing unobserved attack details.
Tools: Streamlit + Python + pandas
STEP 15

Review and Apply Defensive Network Controls

  • Review the ports and services exposed by the Ubuntu server.
  • Determine which services are required for the laboratory scenario.
  • Review firewall rules and restrict unnecessary network access.
  • Apply appropriate access restrictions without blocking the monitoring system or required legitimate connections.
  • Document the changes made to the target's network-access configuration.
  • Verify that the intended laboratory services remain reachable.
Tools: Ubuntu Linux + Firewall Configuration + Zeek
STEP 16

Perform Post-Remediation Port-Scanning Assessment

  • Repeat the authorized port scan against the same Ubuntu laboratory target.
  • Confirm that the scan remains restricted to the designated system.
  • Allow Zeek to record the post-remediation connection activity.
  • Review the destination ports and service accessibility observed during the reassessment.
  • Compare the results with the initial port-scanning assessment.
  • Preserve the new connection logs and record any remaining exposure.
Tools: Nmap + Kali Linux + Ubuntu Linux + Zeek
STEP 17

Validate Post-Remediation Monitoring and Detection

  • Process the new Zeek records through the established feature-extraction pipeline.
  • Apply the same feature definitions and documented model configuration used in the assessment.
  • Review the anomaly scores produced for the post-remediation activity.
  • Compare the observed network behaviour with the initial assessment.
  • Verify that the monitoring pipeline continues to process incoming records.
  • Document any changes in detection results without assuming that remediation must eliminate every anomaly.
Tools: Zeek + Python + River + pandas
STEP 18

Perform Final Security Validation and Documentation

  • Review the original port-scanning assessment and the post-remediation results.
  • Compare the initial and final network-access observations.
  • Review the dataset preparation and model evaluation results.
  • Document the anomaly-detection configuration, threshold, and evaluation limitations.
  • Record the relevant Zeek logs and dashboard evidence.
  • Summarize detected anomalies and any identified false positives or missed detections.
  • Document the network controls applied and any remaining security concerns.
  • Finalize the assessment with evidence-based findings and recommendations.
Tools: Zeek + Python + River + Streamlit + Nmap

Outcome

An isolated Ubuntu Linux server and Kali Linux testing environment are established in VirtualBox for controlled network-security assessment.

Zeek monitors the laboratory network and records connection events that provide visibility into communication involving the Ubuntu target.

Publicly available network traffic data is prepared and evaluated using features compatible with the selected anomaly-detection pipeline.

Python extracts and aggregates network-behaviour features, including connection frequency and distinct destination-port counts within defined time windows.

Half-Space Trees analyses the prepared network features and generates anomaly scores for observations that differ from the learned baseline.

Controlled port-scanning activity generated from Kali Linux provides practical test evidence for evaluating the detection pipeline.

Detected anomalies are compared with the controlled test activity to assess whether the model identifies unusual network patterns associated with port scanning.

The Streamlit dashboard presents anomaly scores, event timestamps, and relevant connection details to support security investigation.

Network-access controls are reviewed and reassessed to evaluate changes in exposed services while preserving required legitimate connectivity.

The complete workflow demonstrates continuous Zeek-based network monitoring, streaming anomaly detection with Half-Space Trees, dataset evaluation, controlled port-scanning assessment, anomaly investigation, and post-remediation validation.