logs-syslog-analyze
Linux log forensics and event correlation. Authentication events, auditd analysis, journald forensics, web server logs, cron/systemd-timer abuse, sudo trail, timeline reconstruction, and log tampering detection.
- License 许可
- MIT
- 最近更新
- 2026-09-01
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- logs-syslog-analyze
- tags
- [ "forensics", "log", "linux", "logfile-recon" ]
- capec
- []
- model
- sonnet
- tools
- [ "Read", "Bash", "Glob", "Grep", "WebSearch" ]
- skills
- [ "shared-memory", "threats/mitre-attack-mapper" ]
- maxTurns
- 30
- nist_csf
- []
- description
- Linux log forensics and event correlation. Authentication events, auditd analysis, journald forensics, web server logs, cron/systemd-timer abuse, sudo trail, timeline reconstruction, and log tampering detection.
- mitre_attack
- [ "T1053.003", "T1059", "T1110", "T1548.003", "T1595" ]
02 资源文件 1
- 参考文档index.json668 B
03 SKILL.md 正文
Logfile Recon
Purpose: Log forensics, timeline reconstruction, and tampering detection. Builds a structured attacker timeline from all available log sources.
Core Focus Areas
- Authentication events: SSH logins, sudo usage, su, PAM failures, brute-force patterns
- Kernel/system events: dmesg anomalies, OOM events, kernel module loads
- Auditd events: EXECVE, SYSCALL, USER_AUTH, USER_CMD, FILE_ACCESS rules
- Web server logs: nginx/apache/caddy access logs, path traversal, shell upload patterns
- Cron/systemd timers: Unexpected timer activations, new service starts
- Log tampering: mtime anomalies, internal timestamp gaps, truncation, log rotation manipulation
- Lateral movement traces: SSH pivots, sudo to different users, unusual tty allocations
- Fail2ban / IDS logs: Banned IPs, signature matches, alert correlation
Key Techniques & Tools
Authentication Analysis
# SSH authentication events — last 14 days
journalctl -u sshd --since "14 days ago" 2>/dev/null | \
grep -E "(Accepted|Failed|Invalid|Disconnected|session opened|session closed)" | \
awk '{print $1,$2,$3,$11,$13}' | head -50
# Authentication failures by IP (brute-force detection)
journalctl -u sshd --since "7 days ago" 2>/dev/null | \
grep "Failed password" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | \
sort | uniq -c | sort -rn | head -20
# Successful logins from unusual IPs
last -a 2>/dev/null | grep -v "reboot\|wtmp\|^$" | head -30
lastb 2>/dev/null | head -20
# PAM authentication events
grep -iE "(authentication failure|session opened for user|sudo:)" \
/var/log/auth.log 2>/dev/null | tail -30 || \
journalctl --since "7 days ago" 2>/dev/null | \
grep -iE "(pam_unix|authentication failure|sudo)" | head -30
Sudo & Privilege Escalation Trail
# All sudo events
journalctl --since "30 days ago" 2>/dev/null | \
grep "sudo:" | grep -v "^--\|session" | head -40
# Sudo command history with timestamps
grep -h "sudo:" /var/log/auth.log* 2>/dev/null | \
grep -v "session opened\|session closed\|pam_unix" | tail -30
# su (switch user) events
journalctl --since "14 days ago" 2>/dev/null | \
grep -E "(pam_su|su\[|su:)" | head -20
# Root shell obtained via sudo
journalctl --since "14 days ago" 2>/dev/null | \
grep "sudo:" | grep -E "COMMAND=/bin/bash|COMMAND=/bin/sh|COMMAND=bash|COMMAND=sh" | head -10
Auditd / Audit Log Analysis
# Audit log location
[ -f /var/log/audit/audit.log ] && echo "auditd: active" || echo "auditd: NOT running"
# EXECVE events (command execution)
ausearch -m EXECVE --start "14 days ago" 2>/dev/null | \
aureport -x --summary 2>/dev/null | head -20
# Failed syscalls (potential exploit attempts)
ausearch -m SYSCALL --success=no --start "7 days ago" 2>/dev/null | \
awk '/syscall/{print $0}' | head -20
# User authentication events
ausearch -m USER_AUTH,USER_LOGIN,USER_CMD --start "14 days ago" 2>/dev/null | \
aureport --summary 2>/dev/null | head -20
# File access events (sensitive file reads)
ausearch -m OPEN,READ,WRITE -f /etc/shadow -f /etc/passwd \
--start "7 days ago" 2>/dev/null | head -20
# Auditd rules (coverage check)
sudo auditctl -l 2>/dev/null | head -20
Kernel & System Events
# Recent kernel messages (errors, module loads, crashes)
dmesg --time-format iso 2>/dev/null | grep -iE \
"(error|warning|fail|oops|bug|rootkit|hide|hook|blocked|forbidden)" | tail -30
# Module load/unload events
dmesg 2>/dev/null | grep -iE "(loaded|unloaded|insmod|rmmod)" | head -20
journalctl -k --since "7 days ago" 2>/dev/null | \
grep -iE "(module|kmod|insmod)" | head -20
# OOM killer events (potential DoS or memory exhaustion attack)
dmesg 2>/dev/null | grep -i "oom\|out of memory" | head -10
journalctl -k --since "7 days ago" 2>/dev/null | grep -i "OOM" | head -10
# Kernel panics / crashes
dmesg 2>/dev/null | grep -i "panic\|oops\|BUG:" | head -10
ls -la /var/crash/ 2>/dev/null | head -5
Web Server Log Analysis
# Nginx access log — top IPs, methods, status codes
for log in /var/log/nginx/access.log /var/log/nginx/access.log.1; do
[ -f "$log" ] || continue
echo "=== $log ==="
awk '{print $1}' "$log" | sort | uniq -c | sort -rn | head -10 # Top IPs
awk '{print $6}' "$log" | sort | uniq -c | sort -rn | head -5 # Methods
awk '{print $9}' "$log" | sort | uniq -c | sort -rn | head -5 # Status codes
done
# Path traversal / LFI / RFI attempts
grep -iE "(\.\./|%2e%2e|%252e|etc/passwd|/proc/self|cmd=|exec=|system=)" \
/var/log/nginx/access.log 2>/dev/null | head -20
# Shell upload indicators
grep -iE "(\.php\?cmd=|\.asp\?cmd=|webshell|eval\(|base64_decode)" \
/var/log/nginx/access.log 2>/dev/null | head -10
# 4xx/5xx error spike (potential scanning/exploitation)
awk '$9 ~ /^4[0-9][0-9]|^5[0-9][0-9]/ {print $1}' \
/var/log/nginx/access.log 2>/dev/null | sort | uniq -c | sort -rn | head -10
Cron & Systemd Timer Abuse
# cron job execution history
grep "CRON\|crontab" /var/log/syslog 2>/dev/null | tail -20 || \
journalctl -u cron --since "7 days ago" 2>/dev/null | tail -20
# Unusual systemd timer activations
systemctl list-timers --all 2>/dev/null | head -20
journalctl --since "7 days ago" 2>/dev/null | \
grep -E "\.timer.*Triggered|timer.*activated" | head -20
# systemd service starts (new or unexpected)
journalctl --since "7 days ago" 2>/dev/null | \
grep "systemd.*Started\|systemd.*Stopping\|service.*failed" | \
grep -v "user@\|session-\|dbus\|NetworkManager\|bluetooth" | head -20
Log Tampering Detection
# Check log file mtime vs last internal timestamp
for logfile in /var/log/auth.log /var/log/syslog /var/log/kern.log; do
[ -f "$logfile" ] || continue
file_mtime=$(stat -c "%Y" "$logfile" 2>/dev/null)
last_ts=$(tail -1 "$logfile" 2>/dev/null | head -c 20)
file_mtime_h=$(date -d @$file_mtime '+%Y-%m-%d %H:%M:%S' 2>/dev/null)
echo "$logfile: mtime=$file_mtime_h last_entry='$last_ts'"
done
# Journald verification
journalctl --verify 2>/dev/null | tail -10
# Log file size anomalies (truncation indicator)
ls -la /var/log/*.log* 2>/dev/null | awk '{print $5, $9}' | sort -rn | head -20
# Check for gaps in journal timeline
journalctl --list-boots 2>/dev/null | head -10
journalctl --since "7 days ago" 2>/dev/null | \
awk '{ts=$1" "$2" "$3; print ts}' | head -5
journalctl --since "7 days ago" 2>/dev/null | \
awk '{ts=$1" "$2" "$3; print ts}' | tail -5
# auditd log gaps
if [ -f /var/log/audit/audit.log ]; then
awk 'NR==1 || NR==FNR{ts=$0; next} END{print "First:", first_ts, "Last:", ts}' \
/var/log/audit/audit.log | head -3
fi
Timeline Reconstruction
# Unified timeline from all sources (last 24 hours)
journalctl --since "24 hours ago" --output=short-iso 2>/dev/null | \
awk '{print $1, $2, $3, $4, substr($0, index($0,$5))}' | head -100
# Combine auth + audit + system events
paste \
<(grep "$(date -d '1 day ago' '+%b %e')" /var/log/auth.log 2>/dev/null | \
awk '{print $1,$2,$3,"AUTH",$5,$0}' | head -30) \
2>/dev/null | sort | head -30
MITRE ATT&CK Mapping
| Finding | Technique |
|---|---|
| SSH brute-force logins | T1110.001 – Password Guessing |
| sudo abuse for root access | T1548.003 – Sudo and Sudo Caching |
| Log file mtime tampering | T1070.002 – Clear Linux Logs |
| Journal entries deleted | T1070.002 – Clear Linux Logs |
| Web shell access via web log | T1505.003 – Web Shell |
| Cron job added | T1053.003 – Cron |
| Unexpected service started | T1543.002 – Systemd Service |
| Auditd disabled | T1562.012 – Disable or Modify Linux Audit System |
Rules for Agents
- Always report log tampering (mtime mismatch) as HIGH — preserve original
- SSH brute-force from single IP (>10 failures) = MEDIUM minimum
- Successful login following brute-force = CRITICAL
- New cron jobs or systemd timers not in PersistenceBaseline = HIGH
- Web server path traversal attempts = MEDIUM — correlate with process tree
- Output timeline format:
ISO_TIMESTAMP | SOURCE | EVENT_TYPE | DETAILS | SEVERITY - Sync reconstructed attacker timeline to shared memory at session end
04 同仓库更多 Skills
devel-jb-algorithmic-art
- Embed algorithms inline in the HTML artifact (don't create separate .
services-wmi-persistence-detect
Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.
services-wmi-exec-exploit
Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.
registry-artifact-extract
Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.
processes-token-impersonate-detect
Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.
processes-thread-injection-detect
Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.