| Tool | Tipo | Punti di forza |
| Log Parser 2.2 (Microsoft, gratis) | CLI / COM | SQL-like query su file log, export CSV/SQL/XML, veloce, scriptabile |
| Log Parser Studio (GUI per Log Parser) | GUI | Query predefinite (Top 404, Slow requests, IP analysis), grafici |
| GoAccess (open source, CLI/HTML) | CLI/Web | Report interattivo HTML real-time, geoip, molto veloce |
| AWStats (Perl, legacy) | CLI/CGI | Report statici, datato |
| ELK Stack (Elasticsearch, Logstash, Kibana) | Platform | Centralizzato, scaling, dashboard, alerting, ML — enterprise |
| Graylog / Loki + Grafana | Platform | Alternative open source a ELK, più leggere |
| PowerShell / Python (pandas) | Script | Flessibilità totale, automazione, ML custom |
Query Log Parser esempi (salvate come .sql, eseguite: logparser file:query.sql -i:W3C)
-- Top 20 errori 404
SELECT TOP 20 cs-uri-stem, COUNT(*) AS Hits
FROM 'C:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log'
WHERE sc-status = 404
GROUP BY cs-uri-stem
ORDER BY Hits DESC;
-- Richieste più lente (top 50)
SELECT TOP 50 date, time, c-ip, cs-method, cs-uri-stem, time-taken, sc-status
FROM 'C:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log'
WHERE time-taken > 5000
ORDER BY time-taken DESC;
-- IP con più errori 5xx
SELECT c-ip, COUNT(*) AS Errors
FROM 'C:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log'
WHERE sc-status >= 500
GROUP BY c-ip
ORDER BY Errors DESC;
-- User Agent sospetti (scanner, bot)
SELECT cs(User-Agent), COUNT(*) AS Hits
FROM 'C:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log'
WHERE cs(User-Agent) LIKE '%sqlmap%' OR cs(User-Agent) LIKE '%nikto%' OR cs(User-Agent) LIKE '%nmap%' OR cs(User-Agent) LIKE '%bot%' OR cs(User-Agent) LIKE '%crawler%' OR cs(User-Agent) LIKE '%scanner%'
GROUP BY cs(User-Agent)
ORDER BY Hits DESC;
Indicatori di compromissione (IOC) da cercare
- Richieste con
UNION SELECT, ' OR 1=1, , ../, etc/passwd, cmd.exe, powershell in query string o path.
- Moltissimi 404 da stesso IP in breve tempo (directory enumeration).
- POST su pagine di login ripetuti (brute force / credential stuffing).
- User Agent vuoti, "Mozilla/4.0", tool noti (sqlmap, havij, acunetix, burp).
- Richieste a ore insolite da IP esteri (se business locale).
sc-win32-status = 64 (ERROR_NETNAME_DELETED) → client disconnesso bruscamente (possibile timeout attack).
Best practice gestione log
- Ritenzione: Minimo 90 giorni (compliance), 1-3 anni se possibile. Archiviate su storage economico (S3 Glacier, Azure Cool Blob).
- Rotazione: Giornaliera (default IIS) — non disabilitate.
- Compressione: Attivate compressione NTFS su cartella log o script PowerShell per .zip giornalieri.
- Centralizzazione: Filebeat / NXLog / Fluent Bit → Logstash / Vector → Elasticsearch / Loki.
- Campi custom: Aggiungete
X-Request-ID, X-User-ID via modulo IIS (Advanced Logging / Custom Logging) per tracciamento end-to-end.