Aiwg log-analysis
Multi-source log correlation across auth.log, syslog, journald, application logs, and web access logs with pattern detection for brute force, privilege escalation, and lateral movement
git clone https://github.com/jmagly/aiwg
T=$(mktemp -d) && git clone --depth=1 https://github.com/jmagly/aiwg "$T" && mkdir -p ~/.claude/skills && cp -r "$T/agentic/code/frameworks/forensics-complete/skills/log-analysis" ~/.claude/skills/jmagly-aiwg-log-analysis-e7c1fb && rm -rf "$T"
agentic/code/frameworks/forensics-complete/skills/log-analysis/SKILL.mdlog-analysis
Correlates log data from multiple sources to identify attacker activity patterns including brute force login attempts, credential stuffing, privilege escalation, lateral movement, and data exfiltration. Adapts to log availability on the target system and produces a structured timeline of suspicious events.
Triggers
Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
- "auth.log" / "syslog" → specific log file analysis
- "lateral movement" → log-based lateral movement detection
- "brute force" → authentication attack detection in logs
Purpose
Individual log sources tell fragments of a story. Correlating authentication logs, process accounting, web access logs, and application logs reveals the full attack chain: initial access method, persistence establishment, privilege escalation path, and lateral movement targets. This skill assembles those fragments into a coherent timeline.
Behavior
When triggered, this skill:
-
Discover available log sources:
- Check for journald:
journalctl --disk-usage 2>/dev/null - Check for traditional syslog files:
,/var/log/syslog/var/log/messages - Check for auth logs:
(Debian) or/var/log/auth.log
(RHEL)/var/log/secure - Check for web server logs:
,/var/log/nginx/
,/var/log/apache2//var/log/httpd/ - Check for application-specific logs:
subdirectories/var/log/ - Record which sources are available and which are absent (absence is itself evidence)
- Check for journald:
-
Authentication log analysis:
- Extract all SSH authentication events:
grep -E 'sshd.*(Failed|Accepted|Invalid|Disconnected)' /var/log/auth.log - Count failed logins per source IP to detect brute force:
grep 'Failed password' /var/log/auth.log | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn | head -20 - Extract successful logins after prior failures (credential stuffing success indicator)
- Parse sudo and su events: privilege escalation timing, escalating users, target users
- Extract all SSH authentication events:
-
Brute force pattern detection:
- Identify source IPs with > threshold failed attempts within a rolling time window
- Flag distributed brute force: multiple IPs, same username targets, compressed time window
- Check for password spraying: many usernames, few attempts each, from one or few IPs
- Flag successful login from an IP that previously generated failures (compromise indicator)
-
Privilege escalation analysis:
- Sudo usage:
grep sudo /var/log/auth.log | grep -v 'pam_unix\|session' - PAM events for su, sudo, and other elevation mechanisms
- setuid binary execution via process accounting if available:
lastcomm 2>/dev/null - Journal entries for systemd service unit changes by non-root users
- Sudo usage:
-
Lateral movement indicators:
- Internal SSH connections (source IP is RFC1918): logins from one internal host to another
- Service accounts authenticating interactively
- Accounts logging in from multiple source IPs within a short window
- Use of credential forwarding (SSH agent forwarding):
grep 'agent' /var/log/auth.log
-
Web access log analysis:
- Parse combined log format for common web attack patterns:
grep -E '\.(php|asp|aspx|jsp|cgi).*\?(.*=.*)(union|select|exec|eval|base64)' access.log - Detect directory traversal:
grep '\.\.\/' access.log - Detect webshell access patterns: repeated POST requests to static file paths
- Identify scanning activity: high request rate from single IP, 404 storms, UA strings matching known scanners
- Flag HTTP 200 responses to paths that should not exist
- Parse combined log format for common web attack patterns:
-
Syslog and journal correlation:
- Extract cron job execution events around suspicious times
- Find process start events correlating with authentication events
- Kernel OOM kills, segfaults, or coredumps near the incident window
- Network interface up/down events (potential persistence via network scripts)
-
Application log review:
- Database logs: failed authentication, unusual query patterns, bulk SELECT/export activity
- Mail server logs: outbound relay abuse, unusual recipient domains
- VPN/remote access logs: off-hours connections, unusual source geographies
- Custom application logs: error bursts, API authentication failures
-
SSH key fingerprint and session duration analysis:
- Extract accepted public key fingerprints:
grep "Accepted publickey" /var/log/auth.log | awk '{print $NF}' - Correlate session open/close events to compute session durations; flag sessions that never close (potential persistent shell)
- Distinguish opportunistic scanning (broad invalid-user lists) from targeted attacks (specific, plausible usernames) using invalid user enumeration counts
- Extract accepted public key fingerprints:
-
PAM tampering detection:
- Compare installed
files against package manager originals using/etc/pam.d/
(Debian) ordebsums
(RHEL); modifications are a persistence indicatorrpm -V pam - Identify
entries or module paths outsidepam_exec
or/lib/security//lib64/security/ - List PAM
files not owned by any package to surface injected modules.so
- Compare installed
-
Btmp and lastb failed login analysis:
- Parse the binary failed-login log with
to enumerate IPs and accounts targetedlastb - Cross-reference failed-login IPs against successful-login IPs using
to identify IPs that eventually succeeded — the strongest brute force confirmation patterncomm -12
- Parse the binary failed-login log with
-
Windows Event Log correlation:
- Parse Event ID 4624 (successful logon)
values: Type 3 (network) and Type 10 (RDP) from unexpected sources indicate lateral movementLogonType - Aggregate Event ID 4625 (failed logon) by
andTargetUserName
; distinguishIpAddress
(wrong password) fromSubStatus 0xC000006A
(non-existent account)0xC0000064 - Flag Event ID 4648 (explicit credentials) chains across multiple hosts as pass-the-hash or credential relay indicators
- Extract and base64-decode PowerShell Event ID 4103 (module logging) and 4104 (script block logging) entries; flag encoded blocks that spawn network connections or write to temp paths
- Parse Event ID 4624 (successful logon)
-
Cloud log parsing:
- AWS CloudTrail: extract
,eventName
, andsourceIPAddress
; flaguserIdentity
,DeleteTrail
, andStopLogging
with unusual session namesAssumeRole - Azure Activity Log: extract
,operationName
, andcaller
; flagcorrelationId
and bulk permission changesMicrosoft.Authorization/roleAssignments/write - GCP Audit Log: extract
,methodName
, andprincipalEmail
; flagresourceName
,SetIamPolicy
, andCreateServiceAccount
eventsCreateServiceAccountKey
- AWS CloudTrail: extract
-
Timeline construction:
- Merge events from all sources into a unified chronological timeline
- Normalize timestamps to UTC
- Annotate events with severity: INFO, SUSPICIOUS, MALICIOUS
- Group events into phases: Reconnaissance, Initial Access, Execution, Persistence, Privilege Escalation, Lateral Movement, Exfiltration
- Write findings document:
- Save to
.aiwg/forensics/findings/<hostname>-log-analysis.md - Include: source inventory, attack timeline, IOCs extracted (IPs, usernames, paths), pattern summary
- Save to
Usage Examples
Example 1 — Full log analysis on local system
analyze logs
Example 2 — Auth log focus
auth log analysis /var/log/auth.log
Example 3 — Specify time window
log forensics --from "2026-02-01 00:00:00" --to "2026-02-15 23:59:59"
Output Locations
- Findings:
.aiwg/forensics/findings/<hostname>-log-analysis.md - Unified timeline:
.aiwg/forensics/timelines/<hostname>-log-timeline.md - IOC list:
.aiwg/forensics/iocs/<hostname>-log-iocs.txt
Configuration
log_analysis: brute_force_threshold: 10 brute_force_window_minutes: 5 spray_threshold_users: 5 web_log_paths: - /var/log/nginx/access.log - /var/log/apache2/access.log - /var/log/httpd/access_log timeline_timezone: UTC severity_levels: - INFO - SUSPICIOUS - MALICIOUS
References
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/research-before-decision.md — Discover available log sources before analysis; absence of logs is itself evidence to document
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/evidence-integrity.md — Analyze log copies only; do not modify original log files
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/red-flag-escalation.md — Escalate immediately when log analysis reveals active attacker presence or data exfiltration
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/skills/evidence-preservation/SKILL.md — Logs must be preserved and hashed before analysis begins
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/skills/sigma-hunting/SKILL.md — Sigma hunting applies detection rules on top of the log sources analyzed here