GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - ThejasRajamoney/Log-Analyzer: Summarizes the key features β€” SSH/web/Windows log parsing, brute force/SQLi/XSS/privilege escalation detection, colored terminal output, JSON reports, and severity levels

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
log-analyzer
log-analyzer
 
 
README.md
README.md
 
 

Repository files navigation

πŸ” Log Analyzer β€” Suspicious Activity Detection

A professional-grade CLI tool that parses SSH, web server, and Windows event logs to detect brute force attacks, injection attempts, port scans, and privilege escalation β€” all with colored terminal output and structured JSON reports.


πŸ“Έ Preview

╔══════════════════════════════════════╗
β•‘     LOG ANALYZER β€” SECURITY REPORT  β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

[CRITICAL] Successful Login After Brute Force
           IP: 192.168.1.45 | Time: 2024-01-15 03:42:11
           Details: 47 failed attempts then success at 3:42am

[HIGH]     Brute Force Detected
           IP: 10.0.0.23 | Attempts: 142 in 8 minutes
           Targeted User: admin

[MEDIUM]   SQL Injection Attempt
           IP: 203.45.67.89 | URL: /login?id=1' OR '1'='1
           User Agent: sqlmap/1.7

══════════════════════════════════════
SUMMARY
══════════════════════════════════════
Total Events Analyzed : 15,432
Suspicious Events     : 89
Unique Attacker IPs   : 12
CRITICAL              : 2  πŸ”΄
HIGH                  : 8  🟠
MEDIUM                : 23 🟑
LOW                   : 56 πŸ”΅

⚑ Quickstart

# Install the only dependency
pip install colorama

# Analyze all sample logs at once
python main.py --type all --dir sample_logs/

# Analyze a specific SSH log
python main.py --type ssh --file sample_logs/auth.log

# Filter by severity and save a JSON report
python main.py --type web --file sample_logs/access.log --severity HIGH --output report.json

🧠 What It Detects

SSH / Auth Logs (/var/log/auth.log)

Threat Condition
Brute Force 5+ failed logins from same IP within 10 minutes
Root Login Attempts Any Failed password for root entry
Invalid User Invalid user entries logged
Successful Login After Failures Possible account compromise
Off-Hours Access Successful login between 11pm – 5am

Web Server Logs (Apache / Nginx)

Threat Condition
SQL Injection Patterns like ' OR 1=1, UNION SELECT in URLs
XSS Attempts <script>, alert(), javascript: in request paths
Directory Traversal ../../../ sequences detected
Scanner Detection Tools like nikto, sqlmap, masscan in User-Agent
404 Flooding 20+ 404s from one IP within 1 minute
High Request Rate 100+ requests from one IP within 1 minute
Unusual HTTP Methods TRACE, CONNECT, DELETE from unknown IPs

Windows Event Logs (JSON format)

Event ID Meaning Detection
4625 Failed logon Multiple = brute force
4648 Logon with explicit credentials Flagged for review
4720 New user account created Flagged
4732 User added to privileged group 4720 + 4732 sequence = privilege escalation
7045 New service installed Flagged as suspicious
4698 Scheduled task created Flagged

πŸ—‚οΈ Project Structure

log-analyzer/
β”œβ”€β”€ main.py                    ← CLI entry point (argparse)
β”œβ”€β”€ analyzer/
β”‚   β”œβ”€β”€ base_analyzer.py       ← Abstract base class
β”‚   β”œβ”€β”€ ssh_analyzer.py        ← Parses auth/SSH logs
β”‚   β”œβ”€β”€ web_analyzer.py        ← Parses Apache/Nginx logs
β”‚   └── windows_analyzer.py   ← Parses Windows event logs (JSON)
β”œβ”€β”€ detectors/
β”‚   β”œβ”€β”€ brute_force.py         ← Brute force detection logic
β”‚   β”œβ”€β”€ port_scan.py           ← Port scan detection
β”‚   └── anomaly.py             ← Unusual pattern detection
β”œβ”€β”€ reporter/
β”‚   β”œβ”€β”€ terminal_report.py     ← Colored terminal output (colorama)
β”‚   └── json_report.py         ← Structured JSON report writer
β”œβ”€β”€ sample_logs/
β”‚   β”œβ”€β”€ auth.log               ← Sample SSH log with fake attacks
β”‚   β”œβ”€β”€ access.log             ← Sample Apache log with injection attempts
β”‚   └── windows.evtx.json      ← Sample Windows events (JSON)
β”œβ”€β”€ requirements.txt
└── README.md

πŸ–₯️ CLI Reference

python main.py [OPTIONS]
Argument Values Description
--type ssh, web, windows, all Log format to analyze
--file path Single log file to analyze
--dir path Directory of logs (use with --type all)
--output path Save findings to JSON file
--severity CRITICAL, HIGH, MEDIUM, LOW, INFO Filter output by minimum severity
--threshold integer Brute force attempt threshold (default: 5)

Examples:

python main.py --type ssh     --file sample_logs/auth.log
python main.py --type web     --file sample_logs/access.log
python main.py --type windows --file sample_logs/windows.evtx.json
python main.py --type all     --dir  sample_logs/
python main.py --type web     --file access.log --severity HIGH --output report.json
python main.py --type ssh     --file auth.log   --threshold 10

πŸ“Š Severity Levels

Level Color Meaning
CRITICAL πŸ”΄ Red background Active compromise indicators
HIGH 🟠 Red text Brute force, privilege escalation
MEDIUM 🟑 Yellow text Scanning, repeated failures
LOW πŸ”΅ Cyan text Off-hours access, unusual agents
INFO βšͺ White text General statistics

πŸ“„ JSON Report Format

{
  "report_generated": "2024-01-15T14:23:00",
  "log_file": "auth.log",
  "log_type": "ssh",
  "total_lines_analyzed": 15432,
  "summary": {
    "total_suspicious": 89,
    "unique_ips": 12,
    "critical": 2,
    "high": 8,
    "medium": 23,
    "low": 56
  },
  "findings": [
    {
      "severity": "HIGH",
      "type": "brute_force",
      "ip": "10.0.0.23",
      "timestamp": "2024-01-15T03:42:11",
      "details": "142 failed attempts in 8 minutes",
      "targeted_user": "admin",
      "recommendation": "Block IP immediately, check if login succeeded"
    }
  ],
  "top_attacker_ips": ["10.0.0.23", "192.168.1.45"],
  "recommendations": [
    "Block 3 IPs immediately",
    "Enable fail2ban for SSH",
    "Review admin account for compromise"
  ]
}

πŸ› οΈ Tech Stack

  • Language: Python 3.10+
  • Dependencies: colorama (terminal colors) β€” nothing else
  • Standard library: re, os, sys, json, datetime, collections, argparse
  • Design patterns: Abstract base class, dataclasses, pure functions

πŸ”§ Installation

git clone https://github.com/ThejasRajamoney/log-analyzer
cd log-analyzer
pip install colorama
python main.py --type all --dir sample_logs/

πŸ§ͺ Sample Logs

The sample_logs/ directory includes pre-built realistic log files for immediate testing:

  • auth.log β€” SSH log with a 50-attempt brute force sequence ending in a successful login, root login attempts from 3 IPs, and off-hours access
  • access.log β€” Apache log with normal traffic mixed with SQL injection, directory traversal, sqlmap requests, and a 404 flood
  • windows.evtx.json β€” Windows events with a 4625 brute force sequence, a 4720 + 4732 privilege escalation chain, and a suspicious 7045 service install

πŸ—ΊοΈ Roadmap

  • Live log tailing with --watch mode
  • IP geolocation enrichment
  • Slack / webhook alert integration
  • HTML report export
  • Docker container support

⚠️ Disclaimer

This tool is intended for authorized security analysis and defensive monitoring only. Only use it on systems and logs you own or have explicit permission to analyze.


Part of the 50 Projects Challenge β€” building one project in every language.

About

Summarizes the key features β€” SSH/web/Windows log parsing, brute force/SQLi/XSS/privilege escalation detection, colored terminal output, JSON reports, and severity levels

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.