A real-time cybersecurity analytics platform for detecting lateral movement attacks from enterprise authentication and network logs using machine learning.
The project combines synthetic enterprise event generation, Apache Kafka-based event streaming, behavioural feature engineering, anomaly detection using Isolation Forest, MongoDB storage, a FastAPI backend, and a React-based monitoring dashboard to simulate an enterprise Security Operations Center (SOC) workflow.
Lateral movement is one of the most critical stages of a cyber attack, where an attacker who has gained initial access attempts to move across internal systems to escalate privileges or access high-value assets.
Network Log Analytics AI analyzes authentication and internal network events to identify abnormal behaviour patterns associated with:
- Lateral Movement
- Privilege Escalation
- Internal Reconnaissance
- Suspicious Authentication Behaviour
- Abnormal Host Traversal
- Administrative Protocol Misuse
Rather than relying solely on rule-based detection, the system engineers behavioural features from authentication logs and applies an Isolation Forest model to identify anomalous activity.
- Synthetic enterprise authentication and network event generation
- Real-time event streaming using Apache Kafka
- Behavioural feature engineering for lateral movement detection
- Isolation Forest based anomaly detection
- MongoDB event storage
- FastAPI REST API
- Interactive React monitoring dashboard
- Offline model training and evaluation pipeline
- Dockerized infrastructure
The pipeline models lateral movement as abnormal internal user-host traversal after an attacker has already entered the network.
Detection is based on behavioural indicators such as:
- One user accessing many new destination hosts within a short time window
- Unusual source-to-destination host relationships
- Administrative protocol usage (RDP, WinRM, SMB, SSH)
- Successful authentication after repeated failures
- Privileged account activity outside normal behaviour
- Rapid lateral hops across workstations, servers and domain controllers
- Rare protocol usage
- Abnormal bytes-out ratios
- Off-hours authentication activity
- Python
- FastAPI
- Apache Kafka
- MongoDB
- Docker
- Scikit-learn
- Isolation Forest
- Pandas
- NumPy
- Joblib
- React
- TypeScript
- TanStack Router
- Recharts
The model was evaluated on a held-out test dataset containing 9,885 authentication events that were never used during training or threshold calibration.
| Metric | Score |
|---|---|
| Accuracy | 98.30% |
| Precision | 89.00% |
| Recall | 97.98% |
| F1-score | 93.27% |
| ROC-AUC | 0.9967 |
| PR-AUC | 0.9876 |
Confusion Matrix
| Predicted Normal | Predicted Lateral Movement | |
|---|---|---|
| Actual Normal | 8552 | 144 |
| Actual Attack | 24 | 1165 |
Decision Threshold
0.623875
The model is trained as an unsupervised anomaly detector where Isolation Forest learns normal authentication behaviour before a calibrated threshold is selected using a labeled validation dataset.
producer.event_buildergenerates synthetic enterprise authentication and network events.scripts.generate_synthetic_datacreates labeled CSV and JSONL datasets.ml_engine.feature_buildercomputes behavioural features used for anomaly detection.ml_engine.traintrains the Isolation Forest model and saves model artifacts.ml_engine.evaluateevaluates the trained model and exports metrics tooutputs/metrics.json.producer.producercontinuously streams live authentication events into Apache Kafka.consumer.consumerperforms feature engineering, anomaly scoring and stores enriched events in MongoDB.api.mainexposes analytics through FastAPI.- The React dashboard visualizes live events, threat analytics, machine learning metrics and system health.
The feature engineering pipeline extracts behavioural indicators including:
unique_dst_hosts_5munique_src_hosts_5munique_protocols_5mauth_event_rate_5mfailed_auth_count_5msuccess_after_fail_count_10mnew_user_host_pairnew_src_dst_pairrare_protocol_flagprivileged_account_flagadmin_protocol_flaglateral_hop_count_15mfanout_score_15mbytes_out_ratiooff_hours_flag
NetworkLogAnalyticsAI/
├── api/
├── configs/
├── consumer/
├── datasets/
├── docker/
├── Frontend/
├── ml_engine/
├── producer/
├── scripts/
├── shared/
├── outputs/
├── docker-compose.yml
├── requirements.txt
└── README.md
Generate the synthetic dataset:
python -m scripts.generate_synthetic_data --events 30000 --seed 42Build behavioural features:
python -m ml_engine.feature_builderTrain the model:
python -m ml_engine.trainEvaluate the model:
python -m ml_engine.evaluateGenerated artifacts:
datasets/synthetic/network_auth_events.csvdatasets/synthetic/network_auth_events.jsonldatasets/processed/training_dataset.csvml_engine/model.pklml_engine/scaler.pklml_engine/threshold.jsonoutputs/metrics.json
Start the infrastructure:
docker compose up -dRun the producer:
python -m producer.producerRun the consumer:
python -m consumer.consumerThe consumer automatically loads:
ml_engine/model.pklml_engine/scaler.pklml_engine/threshold.json
If model artifacts are unavailable, events are still collected and stored for future model training.
Start the backend:
uvicorn api.main:app --reload --port 8000Start the frontend:
cd Frontend/Dashboard
npm install
npm run dev| Endpoint | Description |
|---|---|
GET /api/summary |
Dashboard summary statistics |
GET /api/events |
Recent network authentication events |
GET /api/ml |
Machine learning metrics |
GET /api/system |
System status and health information |
The React dashboard currently includes:
- Overview Dashboard
- Live Event Monitor
- Threat Analysis
- Machine Learning Analytics
- User Behaviour
- System Status
The dashboard communicates directly with the FastAPI backend and displays live information from MongoDB.
This project supports both labeled and unlabeled workflows.
- Synthetic labeled datasets are used for reproducible training and quantitative evaluation.
- Isolation Forest performs anomaly detection without requiring labels during inference.
- Authentication logs from enterprise environments can be adapted to the same event schema for future deployment.
- Windows Event Log integration
- Sysmon support
- SIEM integration
- Explainable AI for anomaly interpretation
- Threat intelligence enrichment
- Alerting and notification pipeline
- Real enterprise authentication datasets
- Rahul Karmakar ( Aspiring Data Analyst | Astrophysicist)
- Associated with CDAC Chennai