Ever wonder what's actually happening in your SSH logs? This tool digs through auth.log files and finds the real problems—brute force attacks, password spraying, and when someone finally cracks an account.
# Clone and run
git clone https://github.com/znrac137/log-signal-extractor.git
cd log-signal-extractor
python main.py logs/sample_auth.log --verbose
# Save alerts to JSON
python main.py logs/sample_auth.log --output alerts.jsonThat's it. No dependencies to install.
It parses your auth.log and hunts for suspicious patterns. When it finds something sketchy, it spits out detailed JSON alerts so you know exactly what happened and when.
- Brute Force: Someone's trying password after password on the same account. Classic attacker move.
- Password Spray: They found a common password and are throwing it at every username they can find.
- Account Takeover: After a bunch of failures, they got in. That's... not good.
- Python 3.8 or later
- Nothing else. Seriously.
git clone https://github.com/znrac137/log-signal-extractor.git
cd log-signal-extractorWant to just run it? Easy:
python main.py logs/sample_auth.logWant to save the alerts to a file?
python main.py logs/sample_auth.log --output alerts.jsonWant to see what's happening behind the scenes?
python main.py logs/sample_auth.log --verboseHere's what all the options do:
usage: main.py [-h] [-o OUTPUT] [-v] logfile
Extract security signals from SSH authentication logs
positional arguments:
logfile Path to auth.log file to analyze
optional arguments:
-h, --help show this help message and exit
-o, --output OUTPUT Output file for JSON alerts (default: stdout)
-v, --verbose Enable verbose output
[*] Parsing log file: logs/sample_auth.log
[+] Extracted 30 authentication events
[*] Running security detection algorithms...
============================================================
ALERT: BRUTE_FORCE_ATTACK (HIGH)
Source IP: 192.168.1.100
Failed attempts: 8
Usernames targeted: admin, root, postgres, test
Time window: 10 minutes
============================================================
ALERT: PASSWORD_SPRAY_ATTACK (HIGH)
Source IP: 192.168.1.101
Unique usernames: 6
Common password detected
============================================================
ALERT: SUCCESS_AFTER_FAILURES (CRITICAL)
Source IP: 192.168.1.100
Username: root
Failed attempts before success: 7
⚠️ Potential account compromise
============================================================
Analysis Complete
Events analyzed: 30
Alerts detected: 3
CRITICAL: 1
HIGH: 2
When it runs, you'll get JSON output with all the alerts. Each one includes the timestamp, usernames involved, the IP address causing trouble, and the actual log lines that triggered the alert:
{
"metadata": {
"scan_timestamp": "2026-02-10T12:00:00.000000",
"log_file": "logs/sample_auth.log",
"events_analyzed": 30,
"alerts_detected": 3
},
"alerts": [
{
"alert_type": "BRUTE_FORCE_ATTACK",
"severity": "HIGH",
"source_ip": "192.168.1.100",
"affected_usernames": ["admin", "root", "postgres", "test"],
"event_count": 8,
"timestamp": "2026-02-10T12:00:00.000000",
"description": "Detected 8 failed login attempts from 192.168.1.100 in 10min window. Possible brute force attack.",
"events": [
{
"timestamp": "2026-01-01T10:15:22",
"username": "admin",
"ip_address": "192.168.1.100",
"event_type": "Invalid user",
"raw_line": "Jan 1 10:15:22 server sshd[1234]: Invalid user admin from 192.168.1.100 port 54321"
},
...
]
}
]
}The project includes a realistic sample auth.log file with actual attack patterns already in it:
python main.py logs/sample_auth.log --verboseSample Output:
[*] Parsing log file: logs/sample_auth.log
[+] Extracted 30 authentication events
[*] Running security detection algorithms...
============================================================
Analysis Complete
============================================================
Events analyzed: 30
Alerts detected: 3
CRITICAL: 1
HIGH: 2
log-signal-extractor/
├── logs/
│ └── sample_auth.log # Sample auth.log with attack patterns
├── extractor/
│ ├── __init__.py # Package initialization
│ ├── models.py # Data models (LogEvent, Alert)
│ ├── parser.py # Auth.log parser
│ ├── detectors.py # Detection algorithms
│ └── utils.py # Utility functions
├── main.py # CLI entry point
├── requirements.txt # Python dependencies (none required)
└── README.md # This file
Here's how it all fits together:
-
models.py - The data structures:
LogEvent: A single authentication log entryAlert: A detected security alertEventType: What types of events we trackAlertSeverity: How bad is this alert?
-
parser.py - Reads auth.log files:
AuthLogParser.parse_file(): Process the whole fileAuthLogParser.parse_line(): Handle one line at a time- Pulls out: timestamp, username, IP, event type
-
detectors.py - The detection algorithms:
detect_bruteforce(): Spots repeated failed attemptsdetect_password_spray(): Finds multi-user targetingdetect_success_after_fail(): Catches account compromise- You can tweak thresholds to make it more or less sensitive
-
utils.py - Helper stuff:
- Parse timestamps
- Extract and validate IPs
- Pull out usernames
- What it is: Multiple failed login attempts from the same IP
- When it triggers: 5 or more failed attempts in a 10-minute window
- How serious: HIGH
- What it means: Someone's systematically guessing passwords
- What it is: Someone trying to log in as multiple different users from one IP
- When it triggers: 3 or more different usernames attempted in a 10-minute window
- How serious: HIGH
- What it means: They've probably got a common password and are throwing it everywhere
- What it is: A successful login that comes after a bunch of failures
- When it triggers: Login succeeds after 5+ failed attempts from the same IP and username combo
- How serious: CRITICAL
- What it means: They guessed it. Account's probably compromised.
Want to make it stricter or looser? Modify these thresholds in main.py:
detector = SuspiciousActivityDetector(config={
"failed_login_threshold": 5, # How many failed attempts before alert
"password_spray_threshold": 3, # How many different users before alert
"time_window_minutes": 10, # Window to group attempts together
})detector = SuspiciousActivityDetector(config={
"failed_login_threshold": 3, # Alert after just 3 failures
"password_spray_threshold": 2, # Alert on 2+ users targeted
"time_window_minutes": 5, # Tighter 5-minute window
})detector = SuspiciousActivityDetector(config={
"failed_login_threshold": 10, # Only alert after 10 failures
"password_spray_threshold": 5, # Need 5+ users targeted
"time_window_minutes": 15, # Wider 15-minute window
})Then just run it normally:
python main.py logs/sample_auth.log --output alerts.json- False Positives: Sometimes legitimate users trigger alerts if their VPN drops or they forget their password
- Tuning: Adjust the thresholds based on what's normal in your environment
- Log Rotation: Make sure your auth.log is being kept around long enough to analyze
- Scale It Up: If you're running this in production, consider using a log aggregation tool like ELK or Splunk
- Timestamp Format: The parser expects standard syslog format. Some systems may have different formats
- Year Information: Standard auth.log doesn't include year in timestamps, so alerts use the current year (can cause issues with logs spanning calendar years)
- Log Rotation: If logs are rotated/compressed, you'll need to decompress and pass individual files
- Real-time Analysis: Current version processes static files. For real-time streaming, needs integration with log ingestion tools
- Geographic Anomalies: Doesn't detect impossible travel or unusual access patterns (yet)
- Account Context: Doesn't know which accounts are service accounts vs. human users
To add a new detection algorithm:
- Create a method in
SuspiciousActivityDetector:
def detect_custom_pattern(self, events: List[LogEvent]) -> List[Alert]:
"""Your detection logic here"""
alerts = []
# ... implementation ...
return alerts- Call it from
detect_all():
all_alerts.extend(self.detect_custom_pattern(events))Just run it on the sample logs:
python main.py logs/sample_auth.log --output test_alerts.json --verbose- Parses typical auth.log file (~1000s of events) in <100ms
- Memory efficient: processes logs line-by-line
- Suitable for real-time log processing pipelines
- Real-time log streaming support
- Additional detection patterns (geographic anomalies, timing patterns)
- Integration with threat intelligence feeds
- Elasticsearch/Splunk exporters
- Web dashboard for alert visualization
- Machine learning models for behavioral analysis
MIT License - See LICENSE file for details
Version: 1.0.0
Last Updated: February 2026