Cybersecurity & Artificial Intelligence

CyberGuard AI: Building an AI-Powered Security Analyst from Scratch

By Yogesh Aryalβ€’8 min readβ€’Cybersecurity

A practical journey into building a lightweight AI-powered Security Operations Center that detects threats, stores security events, visualizes attacks, and generates AI-powered security recommendations.

1. The Problem: Too Many Alerts, Too Little Context

Modern cybersecurity teams face a common challenge: they collect enormous amounts of security data but often struggle to turn it into actionable intelligence. A Security Operations Center (SOC) can generate hundreds or even thousands of alerts every day. Many of these alerts are repetitive, low-risk, or false positives. As a result, analysts spend significant time reviewing logs instead of investigating actual threats.

This challenge inspired me to build CyberGuard AI, a personal cybersecurity project that combines traditional detection techniques with artificial intelligence to help security analysts quickly understand and respond to potential attacks.

The goal was simple: Transform raw security logs into meaningful security insights through automation and local AI analysis.

Project Goal

Transform raw security logs into meaningful security insights through automation and local AI analysis.

2. Project Vision

CyberGuard AI was designed as a lightweight Security Operations Center (SOC) platform that can:

1

Detect suspicious activity from log files

2

Store security events for future investigation

3

Visualize threats through an interactive dashboard

4

Use AI to explain threats and recommend actions

5

Keep sensitive data private by running AI locally

Rather than replacing security analysts, the project focuses on augmenting them by reducing manual investigation time.

3. System Architecture

The project follows a straightforward security monitoring workflow:

CyberGuard AI System Architecture

Each stage adds additional value to the data until a simple log entry becomes a security recommendation.

3.1 Phase 1: Building the Detection Engine

Every security platform starts with visibility. To simulate real-world authentication activity, I created a log file containing login events, including successful and failed authentication attempts. The first challenge was identifying suspicious behavior.

Detecting Brute Force Attacks

One of the most common attack techniques is a brute force attack, where an attacker repeatedly attempts to guess passwords. CyberGuard AI monitors failed login attempts and tracks how many times each IP address appears in the logs. When an IP exceeds a predefined threshold of failed attempts, the system generates a security alert.

For example:

Source IPFailed AttemptsResult
192.168.1.506Alert Generated
192.168.1.752No Alert

This simple detection mechanism demonstrates how meaningful security events can be extracted from otherwise noisy log data.

3.2 Phase 2: Creating a Security Audit Trail

Initially, alerts were displayed directly in the terminal. While this approach was useful for testing, it has a major limitation. Once the program stops running, the alert history would disappear.

To solve this problem, SQLite is integrated as a lightweight security event database. Every alert generated by the detection engine is stored with; timestamp, alert type, severity level, source IP and number of attempts.

This transformation enabled the project to move from a simple script to a system capable of maintaining historical records.

This matters because persistent storage allows security teams to:

  1. 1. Identify recurring attackers
  2. 2. Analyze attack trends
  3. 3. Generate reports
  4. 4. Maintain audit records
  5. 5. Support compliance requirements

Instead of asking, "What happened today?", analysts can begin asking, "What patterns have emerged over time?"

3.3 Phase 3: Building a SOC Dashboard

Security data becomes far more valuable when it is visualized. To make the alert data easier to interpret, an interactive dashboard was built using Streamlit. The dashboard provides an immediate overview of the organization's security posture.

Instead of reviewing rows of data manually, users gain situational awareness within seconds.

Dashboard Features

1. Security Metrics

At a glance, users can view; total alerts detected, high-severity incidents and recent activity levels

2. Top Attacking IP Addresses

A dedicated section highlights the most active sources of suspicious activity. This helps prioritize investigation efforts and quickly identify recurring offenders.

3. Threat Visualization

Charts and visual summaries reveal trends that are difficult to spot in raw database tables. Analysts can immediately understand; alert frequency, severity distribution and attack concentration.

3.4 Phase 4: Introducing the AI Security Analyst

While dashboards help visualize threats, analysts still need to answer critical questions:

1

What does this alert mean?

2

How serious is it?

3

What should happen next?

This is where AI becomes valuable. CyberGuard AI integrates a locally hosted Large Language Model using Ollama and Llama 3.2:3b.

This local AI is implemented because many organizations hesitate to send security data to cloud-based AI services. Running the model locally provides several benefits:

βœ“ Improved privacy
βœ“ No external API costs
βœ“ Reduced dependency on internet connectivity
βœ“ Greater control over sensitive information

Turning Alerts into Intelligence

A raw alert may look like this:

Alert TypeSource IPAttempts
Brute Force Attack192.168.1.506

For a junior analyst, this information raises several questions. CyberGuard AI automatically converts the alert into a concise security assessment.

The AI responds using a structured format:

Threat Summary

A brief explanation of what happened.

Severity

An assessment of the risk level.

MITRE ATT&CK Mapping

Industry-standard classification of the attack technique.

Recommended Actions

Practical steps security teams should take immediately.

This transforms technical data into actionable guidance.

3.5 Challenges and Lessons Learned

Building CyberGuard AI taught me several important lessons:

1. Security Data Is Only Valuable When Context Exists

Raw logs are not intelligence. Meaningful analysis requires detection logic, historical storage, and interpretation.

2. Simplicity Often Wins

A straightforward brute-force detection rule can still uncover legitimate security concerns. Complexity is not always necessary.

3. AI Works Best as an Assistant

The most effective role for AI is helping analysts understand and prioritize information rather than replacing human decision-making.

4. Privacy Matters

Local AI deployment offers a practical balance between automation and data protection.

3.6 Future Enhancements

CyberGuard AI is an ongoing project, and several improvements are planned:

1.Real-time log monitoring
2.Additional attack detection rules
3.Threat intelligence integration
4.Automated incident reports
5.Email and Slack notifications
6.Multi-user authentication
7.Risk scoring engine
8.Machine learning anomaly detection
9.Docker deployment
10.Cloud-hosted dashboard

These enhancements would move the platform closer to a production-grade SOC solution.

3.7 Conclusion

CyberGuard AI began as an experiment to explore the intersection of cybersecurity and artificial intelligence. What emerged was a complete security workflow capable of detecting suspicious activity, preserving historical evidence, visualizing threats, and generating AI-powered security guidance.

The project reinforced an important lesson; The future of cybersecurity is not just collecting more data. It is helping people understand that data faster, more accurately, and with greater context.

By combining traditional detection techniques with local AI, CyberGuard AI demonstrates how modern security operations can become more efficient, scalable, and intelligent without sacrificing privacy.

CyberGuard AI β€’ Cybersecurity & Artificial Intelligence