Access log forensics with Claude Code

A one-page incident report, without handing your visitors' IPs to an LLM

Something is off with a site. It is slow, or it is throwing 503s, or someone in a chat says "are we under attack?". The answer is usually sitting in the access log, somewhere between a few thousand and a few million lines.

Reading it by hand means the usual dance: awk for the top IPs, sort | uniq -c for the user agents, a dozen greps for the classic attack patterns, and then squinting at all of it until a story appears. It works, but it is slow, and it is exactly the kind of work you do not want to be doing while the site is down.

So I packaged that dance into a Claude Code skill.

What it does

Point it at a log in combined format:

/access-log-forensics analyze /var/log/apache2/access.log

Or just ask "can you check access.log for signs of an attack?" and Claude picks it up on its own.

The skill then:

  1. Redacts the log. Client IPs are replaced with stable pseudonyms (ip-042) before any log content enters the conversation.
  2. Builds a baseline with a bundled script: timeframe, status codes, top IPs with error and URL counts, user agents, paths and requests-per-minute peaks.
  3. Sweeps for signatures: SQL injection, path traversal, WordPress and Drupal probing, secret hunting (.env, .git/), XSS and scanner user agents.
  4. Applies judgement. Raw counts are not findings. A distributed flood, a scraper walking every URL, a brute force on user/login, and the big one: was an attack attempted, or did it succeed? A 404 is noise, a 200 with a real response size is not.
  5. Writes forensics-report.md, capped at one page and 400 words: a verdict, key findings, notable sources and prioritized actions.

The word limit is on purpose. Nobody reads a ten-page report during an incident. If the log shows nothing, the report says so in one paragraph and does not invent findings.

Why the redaction

IP addresses in access logs are personal data under GDPR. Analyzing them for security is perfectly legitimate, Recital 49 says so explicitly, but sending raw logs to a cloud LLM turns the provider into a processor and, for US processing, a third-country transfer. That is paperwork you do not want to discover after the fact.

Pseudonymizing first sidesteps most of it. The analysis works exactly the same, ip-042 is as useful as the real address for spotting a pattern, and no real IP leaves your machine. The mapping file stays local (chmod 600), and when you actually need to block someone you resolve the pseudonym yourself:

grep -P '\tip-042$' access.log.ipmap.tsv

The README has a longer section on what is and is not fine under GDPR. It is practical guidance, not legal advice, so involve your DPO if in doubt.

No magic required

The scripts only need bash, awk, grep, sort and uniq. The baseline script also runs on its own, without Claude:

bash scripts/summarize.sh /path/to/access.log

Install it by copying the folder into .claude/skills/ for one project, or ~/.claude/skills/ for all of them.

Resources

The skill, scripts and README are on GitHub.

← All articles