Hola a todos,
Christian, sí tengo ese filtro ('apache-auth') y tengo también uno llamado 'freepbx-auth'. Aqui están:
El 'apache-auth.conf':
failregex = [[]client <HOST>[]] user .* authentication failure
[[]client <HOST>[]] user .* not found
[[]client <HOST>[]] user .* password mismatch
El 'freepbx-auth.conf':
failregex = <HOST> - .* "GET .* 401 *
Este último también está activado en el jail.conf.
Mensajes con la expresión del 'freepbx-auth' tengo en el archivo 'ssl_access_log'.
En este archivo se almacenan todos los intentos de conexión, o sea los exitosos y los fallidos. El problema está en que los mensajes de los intentos fallidos no son parecidos a los regex del 'apache-auth'. Mensajes con sus expresiones exactas no las he visto (aun) en ningún archivo.
Ejemplos del 'ssl_access_log' con "ataques" al freePBX (o sea, con https://192.168.1.5/admin o clicando en 'Unembedded freePBX' ya en el Elastix):
192.168.1.6 - - [02/Dec/2012:14:56:14 -0200] "GET /admin/images/tab-first-current.png HTTP/1.1" 200 2639
192.168.1.6 - - [02/Dec/2012:14:56:15 -0200] "GET /admin/images/tab-hover.png HTTP/1.1" 200 2557
192.168.1.6 - - [02/Dec/2012:14:56:16 -0200] "GET /admin/config.php HTTP/1.1" 401 2277
192.168.1.6 - admin3 [02/Dec/2012:14:56:16 -0200] "GET /admin/config.php HTTP/1.1" 401 2277
192.168.1.6 - admin3 [02/Dec/2012:14:56:19 -0200] "GET /admin/config.php HTTP/1.1" 401 2277
192.168.1.6 - admin3 [02/Dec/2012:14:56:22 -0200] "GET /admin/config.php HTTP/1.1" 401 2277
192.168.1.6 - admin3 [02/Dec/2012:14:56:24 -0200] "GET /admin/config.php HTTP/1.1" 401 2277
192.168.1.6 - - [02/Dec/2012:14:56:50 -0200] "GET /index.php?logout=yes HTTP/1.1" 302 -
192.168.1.6 - - [02/Dec/2012:14:56:50 -0200] "GET /index.php HTTP/1.1" 200 3040
192.168.1.6 - - [02/Dec/2012:14:56:50 -0200] "GET /themes/elastixneo/login_styles.css HTTP/1.1" 200 2012
192.168.1.6 - - [02/Dec/2012:14:56:50 -0200] "GET /themes/elastixneo/login_styles.css HTTP/1.1" 200 2012
192.168.1.6 - - [02/Dec/2012:14:56:50 -0200] "GET /themes/elastixneo/images/elastix_logo_mini.png HTTP/1.1" 200 5109
Estos pertenecen al mismo 'ssl_access_log' pero para "ataques" a https://192.168.1.5 (o sea, a la WEB de Elastix):
192.168.1.2 - - [02/Dec/2012:18:41:52 -0200] "POST / HTTP/1.1" 200 3040
192.168.1.2 - - [02/Dec/2012:18:41:58 -0200] "POST / HTTP/1.1" 200 3040
192.168.1.2 - - [02/Dec/2012:18:42:04 -0200] "POST / HTTP/1.1" 200 3040
Fíjate que en ese archivo tengo aquellos mensajes del GET/401, pero los mensajes del POST/200 no los tengo en las regex.
Ahora siguen ejemplos del 'ssl_error_log'. Aquí solo se almacenan los intentos de conexión fallidos al 'Unembedded freePBX', o sea, clicando en ese link después de entrar con éxito a la consola WEB del Elastix:
Ejemplos del 'ssl_error_log' con intentos de conexión comenzando a las 01:06:21, 22:22:37 y 22:43:13:
[28 23:56:30] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[28 23:56:30] RSA server certificate CommonName (CN) localhost.localdomain' does NOT match server name!?
[28 23:56:31] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[28 23:56:31] RSA server certificate CommonName (CN)localhost.localdomain' does NOT match server name!?
[29 01:06:21] [client 192.168.1.2] Thu, 29 Nov 2012 01:06:21 -0200 - Got event.. fullybooted, referer: https://192.168.1.5/index.php
[29 01:06:21] [client 192.168.1.2] Thu, 29 Nov 2012 01:06:21 -0200 - No event handler for event 'fullybooted', referer: https://192.168.1.5/index.php
[29 01:06:21] [client 192.168.1.2] File does not exist: /var/www/html/modules/pbxadmin/js/script.legacy.js, referer: https://192.168.1.5/index.php?menu=pbxconfig
[29 01:11:54] [client 192.168.1.2] PHP Notice: Undefined variable: skip_astman in /var/www/html/admin/header.php on line 117, referer: https://192.168.1.5/admin/config.php
[29 01:11:54] [client 192.168.1.2] PHP Notice: Undefined variable: skip_astman in /var/www/html/admin/header.php on line 117, referer: https://192.168.1.5/admin/config.php
[29 01:11:56] [client 192.168.1.2] PHP Notice: Undefined variable: skip_astman in /var/www/html/admin/header.php on line 117, referer: https://192.168.1.5/admin/config.php
[29 01:12:00] [client 192.168.1.2] PHP Notice: Undefined variable: skip_astman in /var/www/html/admin/header.php on line 117, referer: https://192.168.1.5/admin/config.php
[29 01:12:02] [client 192.168.1.2] PHP Notice: Undefined variable: skip_astman in /var/www/html/admin/header.php on line 117, referer: https://192.168.1.5/admin/config.php
[29 15:41:38] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[29 15:41:38] RSA server certificate CommonName (CN) localhost.localdomain' does NOT match server name!?
[29 15:41:39] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[29 15:41:39] RSA server certificate CommonName (CN)localhost.localdomain' does NOT match server name!?
[29 22:22:37] [client 192.168.1.6] Sat, 01 Dec 2012 22:22:37 -0200 - Got event.. fullybooted, referer: https://192.168.1.5/index.php
[29 22:22:37] [client 192.168.1.6] Sat, 01 Dec 2012 22:22:37 -0200 - No event handler for event 'fullybooted', referer: https://192.168.1.5/index.php
[29 22:22:39] [client 192.168.1.6] File does not exist: /var/www/html/modules/pbxadmin/js/script.legacy.js, referer: https://192.168.1.5/index.php?menu=pbxconfig
[29 22:43:13] [client 192.168.1.6] Sat, 01 Dec 2012 22:43:13 -0200 - Got event.. fullybooted, referer: https://192.168.1.5/index.php
[29 22:43:13] [client 192.168.1.6] Sat, 01 Dec 2012 22:43:13 -0200 - No event handler for event 'fullybooted', referer: https://192.168.1.5/index.php
[29 22:43:13] [client 192.168.1.6] Sat, 01 Dec 2012 22:43:13 -0200 - Got event.. fullybooted, referer: https://192.168.1.5/index.php
[29 22:43:13] [client 192.168.1.6] Sat, 01 Dec 2012 22:43:13 -0200 - No event handler for event 'fullybooted', referer: https://192.168.1.5/index.php
[29 22:43:14] [client 192.168.1.6] File does not exist: /var/www/html/modules/pbxadmin/js/script.legacy.js, referer: https://192.168.1.5/index.php?menu=pbxconfig
Fíjate que estos mensajes no se corresponden con los regex del 'apache-auth'.
Ahora, en el archivo '/elastix/audit.log' encuentro estos mensajes para las conexiones a la consola WEB:
[Dec 02 18:41:58] LOGIN admin1: Authentication Failure to Web Interface login. Invalid user 1admin from 192.168.1.2.
[Dec 02 18:42:04] LOGIN admin1: Authentication Failure to Web Interface login. Invalid user 1admin from 192.168.1.2.
[Dec 02 19:47:24] LOGIN admin: Web Interface login successful. Accepted password for admin from 192.168.1.2.
[Dec 02 19:53:08] NAVIGATION admin: User admin visited "PBX >> PBX Configuration" from 192.168.1.2.
Ahí aparece la frase "Authentication Failure", pero la expresión no se corresponden con la del regex.
Y como decía, yo puedo adaptar las regex y direccionar los logpath para estos archivos que menciono, pero ellos son grandes (fíjate que aparecen mensajes que no son solo de los ataques), y son varios archivos para el mismo tipo de ataque (apache).
Por ejemplo, en mi archivo 'full' (que tiene varios Megas) se almacenan todos los eventos del asterisk, pero en el archivo 'fail2ban' se almacenan solo los ataques:
[03:23:54] NOTICE chan_sip.c: Registration from '"LIX"<sip:1002@192.168.1.5;transport=UDP>' failed for '192.168.1.4:5060' - Wrong password
[03:23:54] NOTICE chan_sip.c: Failed to authenticate device "LIX"<sip:1002@192.168.1.5;transport=UDP>;tag=4a6c4a1f for SUBSCRIBE
[03:24:21] NOTICE chan_sip.c: Sending fake auth rejection for device "LIX"<sip:1003@192.168.1.5;transport=UDP>;tag=1104f666
[03:24:21] NOTICE chan_sip.c: Registration from '"LIX"<sip:1003@192.168.1.5;transport=UDP>' failed for '192.168.1.4:5060' - No matching peer found
Ese archivo "fail2ban" (de menor tamaño) es el que tiene la regla del asteris en el jail.conf (o sea, en su logpath).
De ahí la pregunta: qué tengo que hacer para que en un único archivo (o en varios) se almacenes apenas los mensajes de los ataques al apache ? (para colocarlo(s) en el logpath del Fail2ban).
Buenos, gracias por la ayuda.