Skip to content

Leegreen305/SOC-Analyst-AI-Agent-

Repository files navigation

SOC Analyst AI Agent

AI-powered Security Operations Center analyst that automates threat detection, incident response, and security reporting. This system analyzes security logs from multiple sources, detects threats using both rule-based and AI-powered analysis, generates structured incident reports, and provides actionable remediation recommendations.

Overview

This project demonstrates a production-ready SOC automation platform that combines traditional security analysis techniques with AI-powered threat detection. The agent ingests logs from Windows, Linux, firewalls, and web servers, applies threat detection rules, leverages OpenAI for contextual analysis, and automatically generates incident tickets with detailed response guidance.

Key Features

  • Multi-source log analysis (Windows Event Logs, Linux auth logs, firewall logs, web access logs)
  • AI-powered threat analysis using OpenAI GPT-4
  • Real-time threat detection with MITRE ATT&CK framework mapping
  • Automated incident ticket generation with response playbooks
  • Comprehensive reporting (real-time alerts, technical reports, executive summaries)
  • Integration templates for Splunk, ticketing systems, and notification platforms
  • Production-ready Python codebase with modular architecture

Architecture

The system follows a modular pipeline architecture:

  1. Log Ingestion - Parse and normalize logs from multiple sources
  2. Threat Detection - Apply detection rules and identify suspicious patterns
  3. AI Analysis - Leverage OpenAI for contextual threat assessment
  4. Incident Response - Generate tickets and select appropriate playbooks
  5. Reporting - Create alerts, technical reports, and executive summaries
  6. Integration - Send alerts to SIEM, ticketing, and notification systems

Folder Structure

SOC-Analyst-AI-Agent/
├── agent-core/          # Core AI agent and configuration
│   ├── soc_agent.py     # Main AI agent implementation
│   ├── config.py        # Configuration and environment management
│   └── requirements.txt # Python dependencies
├── log-analysis/        # Log parsing modules
│   ├── windows_parser.py  # Windows Event Log parser
│   ├── linux_parser.py    # Linux auth.log parser
│   ├── firewall_parser.py # Firewall log parser
│   └── web_parser.py      # Web server access log parser
├── threat-detection/    # Threat detection engine
│   └── detection_engine.py # Rule-based threat detection
├── incident-response/   # Automated incident response
│   └── incident_manager.py # Incident ticket and playbook management
├── reporting/           # Report generation
│   └── report_generator.py # Alert, incident, and executive reports
├── integrations/        # External system integrations
│   ├── splunk_integration.py      # Splunk SIEM integration
│   └── notification_integration.py # Ticketing and alerting
├── sample-data/         # Sample security logs
│   ├── windows_security.log
│   ├── linux_auth.log
│   ├── firewall.log
│   └── web_access.log
├── scripts/             # Utility scripts
│   └── run_demo.py      # Complete demonstration script
└── README.md            # This file

Setup and Installation

Prerequisites

  • Python 3.8 or higher
  • OpenAI API key (for AI-powered analysis)
  • pip package manager

Installation Steps

  1. Clone the repository:
git clone https://github.com/Leegreen305/SOC-Analyst-AI-Agent.git
cd SOC-Analyst-AI-Agent
  1. Install dependencies:
pip install -r agent-core/requirements.txt
  1. Set up environment variables:
# Required
export OPENAI_API_KEY='your-openai-api-key'

# Optional integrations
export SPLUNK_ENABLED='false'
export SPLUNK_HOST='splunk.company.com'
export SPLUNK_TOKEN='your-splunk-token'

export TICKETING_ENABLED='false'
export TICKETING_API_URL='https://ticketing.company.com/api'
export TICKETING_API_KEY='your-api-key'

export SLACK_ENABLED='false'
export SLACK_WEBHOOK_URL='https://hooks.slack.com/your-webhook'

Usage

Quick Demo

Run the demonstration script to analyze sample security logs:

python scripts/run_demo.py

This will:

  1. Parse all sample log files
  2. Detect threats using rule-based detection
  3. Generate threat alerts with severity classification
  4. Create incident tickets with response playbooks
  5. Generate executive and technical reports

Analyzing Custom Logs

Windows Event Logs

from log_analysis.windows_parser import WindowsEventLogParser

parser = WindowsEventLogParser()

with open('your_windows_logs.log', 'r') as f:
    log_content = f.read()

result = parser.parse_log_file(log_content)

print(f"Total events: {result['total_events']}")
print(f"Suspicious events: {result['suspicious_events']}")
print(f"Brute force attempts: {len(result['brute_force_attempts'])}")

Using the AI Agent

from agent_core.soc_agent import SOCAnalystAgent

# Initialize agent
agent = SOCAnalystAgent()

# Analyze logs with AI
analysis = agent.analyze_logs(log_content, log_type='windows_event')

if analysis.get('threat_detected'):
    print(f"Threat: {analysis['threat_type']}")
    print(f"Severity: {analysis['severity']}")
    print(f"Recommended actions: {analysis['recommended_actions']}")
    
    # Generate incident report
    report = agent.generate_incident_report(analysis)
    print(f"Incident ID: {report.incident_id}")

Complete Pipeline

from agent_core.soc_agent import SOCAnalystAgent
from log_analysis.windows_parser import WindowsEventLogParser
from threat_detection.detection_engine import ThreatDetectionEngine
from incident_response.incident_manager import IncidentResponseManager
from reporting.report_generator import ReportGenerator

# 1. Parse logs
parser = WindowsEventLogParser()
parsed_logs = parser.parse_log_file(log_content)

# 2. Detect threats
detector = ThreatDetectionEngine()
alerts = detector.analyze(parsed_logs, 'windows_event')

# 3. Generate incidents
incident_manager = IncidentResponseManager()
incidents = [incident_manager.create_incident(alert.to_dict()) 
             for alert in alerts]

# 4. Generate reports
reporter = ReportGenerator()
for incident in incidents:
    if incident.severity in ['critical', 'high']:
        report = reporter.generate_incident_report(incident.to_dict())
        print(report)
        
# Executive summary
summary = reporter.generate_executive_summary([i.to_dict() for i in incidents])
print(summary)

Threat Detection Capabilities

The agent detects the following threat types:

Authentication-Based Threats

  • Brute Force Attacks - Multiple failed authentication attempts followed by success
  • Credential Stuffing - Attempts using common username/password combinations
  • Invalid User Enumeration - Probing for valid user accounts

Privilege Escalation

  • Account Creation - New user accounts created with administrative privileges
  • Group Modifications - Users added to privileged security groups
  • Sudo Abuse - Suspicious use of sudo or administrative commands

Lateral Movement

  • Internal SSH Connections - Unusual patterns of internal SSH access
  • SMB Share Access - Access to administrative shares or sensitive file systems
  • Remote Service Use - Use of RDP, WinRM, or other remote administration tools

Web Application Attacks

  • SQL Injection - Attempts to inject SQL queries into application inputs
  • Cross-Site Scripting (XSS) - JavaScript injection attempts
  • Path Traversal - Attempts to access files outside web root
  • Command Injection - Attempts to execute system commands via web parameters

Network-Based Threats

  • Port Scanning - Systematic probing of multiple ports
  • Reconnaissance - Information gathering activities
  • Data Exfiltration - Large outbound data transfers to external IPs

Malware Indicators

  • Suspicious Process Execution - PowerShell with encoded commands, suspicious scripts
  • Scheduled Task Creation - New scheduled tasks for persistence
  • Service Installation - New services installed on systems
  • Registry Modification - Changes to autorun keys or security settings

AI Analysis Features

The OpenAI-powered agent provides:

  • Contextual Threat Assessment - Understanding of attack patterns and threat actor TTPs
  • Severity Classification - Accurate risk rating based on business impact
  • False Positive Reduction - Distinguishes legitimate admin activity from threats
  • Natural Language Explanations - Clear, actionable descriptions for analysts
  • Remediation Recommendations - Specific steps tailored to each threat type
  • MITRE ATT&CK Mapping - Automatic classification using industry framework

Incident Response Playbooks

The system includes automated response playbooks for:

  • Brute Force Attacks
  • Privilege Escalation
  • Lateral Movement
  • Web Application Attacks
  • Port Scanning
  • Malware Infections
  • Data Exfiltration

Each playbook provides:

  • Immediate containment steps
  • Investigation procedures
  • Eradication actions
  • Recovery guidance

Integrations

Splunk SIEM

from integrations.splunk_integration import SplunkIntegration

splunk = SplunkIntegration(
    host='splunk.company.com',
    token=os.getenv('SPLUNK_TOKEN')
)

# Send alert to Splunk
splunk.send_event(alert_data)

Ticketing System

from integrations.notification_integration import TicketingIntegration

ticketing = TicketingIntegration(
    api_url=os.getenv('TICKETING_API_URL'),
    api_key=os.getenv('TICKETING_API_KEY')
)

# Create incident ticket
ticket_id = ticketing.create_ticket(incident.to_dict())

Slack Notifications

from integrations.notification_integration import SlackNotification

slack = SlackNotification(webhook_url=os.getenv('SLACK_WEBHOOK_URL'))

# Send real-time alert
slack.send_alert(alert.to_dict())

Configuration

Configuration is managed through environment variables and the config.py module:

Core Settings

  • OPENAI_API_KEY - Required for AI analysis
  • OPENAI_MODEL - Model to use (default: gpt-4)
  • MIN_CONFIDENCE_THRESHOLD - Minimum confidence for alerts (default: 0.6)

Detection Thresholds

  • BRUTE_FORCE_THRESHOLD - Failed attempts to trigger alert (default: 5)
  • LATERAL_MOVEMENT_TIME_WINDOW - Seconds for lateral movement detection (default: 3600)
  • DATA_EXFIL_SIZE_THRESHOLD_MB - MB for data exfiltration alert (default: 100)

Integration Settings

  • See environment variable section above

Sample Data

The repository includes realistic sample data demonstrating:

  • Windows domain compromise with brute force, privilege escalation, and persistence
  • Linux server compromise with SSH brute force and backdoor installation
  • Network reconnaissance with port scanning
  • Web application attacks including SQL injection, XSS, and command injection

What This Project Demonstrates

Technical Skills

  • Python development with object-oriented architecture
  • Security log analysis and parsing (multiple formats)
  • Threat detection algorithm implementation
  • API integration (OpenAI, REST APIs)
  • SIEM integration concepts
  • Incident response automation

Security Knowledge

  • Understanding of common attack patterns and TTPs
  • MITRE ATT&CK framework application
  • Incident response lifecycle and playbooks
  • SOC operations and workflows
  • Threat intelligence and IOC analysis
  • Security monitoring and alerting

AI/ML Application

  • Prompt engineering for security analysis
  • LLM integration in security workflows
  • AI-powered threat assessment
  • Natural language generation for reports
  • Context-aware security recommendations

Future Enhancements

Potential additions for production deployment:

  • Machine learning models for anomaly detection
  • Historical threat intelligence database
  • Automated response actions (auto-blocking IPs, account lockouts)
  • Real-time log streaming integration
  • Advanced correlation across multiple data sources
  • Threat hunting capabilities
  • Custom detection rule builder
  • Dashboard and visualization interface
  • Multi-tenant support for MSSPs

Security Considerations

In production deployment:

  • Store API keys securely (AWS Secrets Manager, Azure Key Vault, etc.)
  • Implement role-based access control
  • Encrypt sensitive data at rest and in transit
  • Audit all automated actions
  • Implement rate limiting for API calls
  • Validate and sanitize all log inputs
  • Use secure communication channels for integrations
  • Maintain detailed audit logs of agent actions

License

This project is created for portfolio and demonstration purposes.

Author

Security Operations Automation Project GitHub: Leegreen305

Acknowledgments

  • OpenAI for GPT-4 API enabling AI-powered analysis
  • MITRE ATT&CK framework for threat classification
  • Security community for threat intelligence and best practices

This project demonstrates real-world SOC automation capabilities and AI integration in security operations. It showcases the ability to build production-ready security tools that enhance analyst efficiency and improve threat detection accuracy.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages