pam_abl funktioniert nicht

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
Benutzeravatar
striker2150
Beiträge: 158
Registriert: 23.07.2004 20:46:22

pam_abl funktioniert nicht

Beitrag von striker2150 » 29.06.2007 10:43:49

Hi @ll,

pam_abl ist ein pam-Modul, welches bei mehrfachen falschen Logins den Zugang fuer eine bestimmte Zeit sperren soll. Das ist gedacht um BruteForce Angriffe abzuwehren.

Da pam_abl nicht im Debian Repository ist habe ich mir die Sourcen geladen und das ganze von Hand kompiliert und installiert. Dafuer war es notwendig die Berkely DB und die entsprechenden -dev Packages zu installieren. Das habe ich auch gemacht. Das kompilieren und installieren ist ohne Fehler durchgelaufen. Anschliessend die Konfiguration in /etc/pam.d/sshd angepasst, wie im Handbuch beschrieben.

Ich habe mich dann mal absichtlich versucht mit falschem Passwort ein zu loggen. Aber der Zugang wurde nach dem Ueberschreiten des Schwellwertes nicht gesperrt. Also die Debug Option in der pam_abl.conf gesetzt.

Nun bekomme ich bei jedem Loginversuch folgende Meldung in der /var/log/auth.log:

Code: Alles auswählen

 In cleanup, err is 20000000
Mit der Fehlermeldung habe ich nur einen Fred im Gentoo Forum gefunden. Allerdings hat der mich auch nicht weiter gebracht. Eine EMail-Anfrage an den Programmauthor ist bis jetzt unbeantwortet.

Hat jemand von euch das Programm zum laufen bekommen? Es gibt zwar noch andere Moeglichkeiten sowas abzuwehren, die dann von iptables gebrauch machen. Aber dafuer muesste ich die komplette Firewallkonfiguration (die nicht von mir stammt) komplett zerlegen und neu machen. Da springt mir unser anderer Admin an die Kehle ;-)

Gruss
Sascha

P.S. Es handelt sich um ein Debian Etch System mit allen Debian Updates

Benutzeravatar
striker2150
Beiträge: 158
Registriert: 23.07.2004 20:46:22

Beitrag von striker2150 » 29.06.2007 11:25:26

Update:

Ich habe das pam_abl Modul nun mal testweise in der /etc/pam.d/su eingetragen. Zusammen mit su funktioniert das Modul einwandfrei.

Sascha

Benutzeravatar
striker2150
Beiträge: 158
Registriert: 23.07.2004 20:46:22

Beitrag von striker2150 » 29.06.2007 14:03:00

Ok, habe folgendes herausgefunden:

Hier wird die Fehlermeldung an den Syslog gegeben:

Code: Alles auswählen

static void cleanup(pam_handle_t *pamh, void *data, int err) {
    if (NULL != data) {
        abl_args *args = data;
        log_debug(args, "In cleanup, err is %08x", err);

        if (err && (err & PAM_DATA_REPLACE) == 0) {
            record_attempt(args);
        }
        config_free(args);
        free(args);
    }
}

Die Funktion cleanup() wird in der PAM-Docu wie folgt beschrieben:
...
PAM modules may be dynamically loadable objects. In general such files should not contain static variables. This function and its counterpart pam_get_data(3), provide a mechanism for a module to associate some data with the handle pamh. Typically a module will call the pam_set_data function to register some data under a (hopefully) unique module_data_name. The data is available for use by other modules too but not by an application. Since this functions stores only a pointer to the data, the module should not modify or free the content of it.
...
The function cleanup() is associated with the data and, if non-NULL, it is called when this data is over-written or following a call to pam_end(3).
...
Quelle: PAM Doku


In der security/pammodules.h finde ich folgendes:

Code: Alles auswählen

/*
 * here are some proposed error status definitions for the
 * 'error_status' argument used by the cleanup function associated
 * with data items they should be logically OR'd with the error_status
 * of the latest return from libpam -- new with .52 and positive
 * impression from Sun although not official as of 1996/9/4 there are
 * others in _pam_types.h -- they are for common module/app use.
 */

#define PAM_DATA_REPLACE   0x20000000     /* used when replacing a data item */

Im Logfile erscheint folgendes:

Code: Alles auswählen

Jun 29 13:43:03 hostB pam_abl[5808]: pam_sm_authenticate(), flags=00000001
Jun 29 13:43:03 hostB pam_abl[5808]: /etc/security/pam_abl.conf: user_db=/var/lib/abl/users.db
Jun 29 13:43:03 hostB pam_abl[5808]: /etc/security/pam_abl.conf: user_purge=2d
Jun 29 13:43:03 hostB pam_abl[5808]: /etc/security/pam_abl.conf: user_rule=!root:3/1h,30/1d
Jun 29 13:43:03 hostB pam_abl[5808]: Checking user userA
Jun 29 13:43:03 hostB pam_abl[5808]: /var/lib/abl/users.db opened
Jun 29 13:43:03 hostB sshd[5808]: (pam_unix) authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=hostname.de  user=userA
Jun 29 13:43:05 hostB sshd[5808]: Failed password for userA from 123.123.123.123 port 40236 ssh2
Jun 29 13:43:14 hostB pam_abl[5808]: pam_sm_authenticate(), flags=00000001
Jun 29 13:43:14 hostB pam_abl[5808]: /etc/security/pam_abl.conf: user_db=/var/lib/abl/users.db
Jun 29 13:43:14 hostB pam_abl[5808]: /etc/security/pam_abl.conf: user_purge=2d
Jun 29 13:43:14 hostB pam_abl[5808]: /etc/security/pam_abl.conf: user_rule=!root:3/1h,30/1d
Jun 29 13:43:14 hostB pam_abl[5808]: In cleanup, err is 20000000
Jun 29 13:43:14 hostB pam_abl[5808]: Checking user userA
Jun 29 13:43:14 hostB pam_abl[5808]: /var/lib/abl/users.db opened
Jun 29 13:43:16 hostB sshd[5808]: Failed password for userA from 123.123.123.123 port 40236 ssh2
Beachtet, dass der Cleanup Error erst auftritt, wenn man das Passwort das zweite mal falsch eingibt (mit ssh kann man 3 mal pro session einen login probieren). Dabei wird die Funktion pam_sm_authenticate() aufgerufen, die wiederum irgendwo pam_set_data() aufruft. Und genau an der stelle Entsteht die Fehlermeldung.

Bin mir noch nicht ganz sicher was das bedeutet, aber ich suche mal weiter.

Sascha

Benutzeravatar
striker2150
Beiträge: 158
Registriert: 23.07.2004 20:46:22

Beitrag von striker2150 » 02.07.2007 12:58:55

Scheint nicht an libpam_abl zu liegen, sondern ein Bug im OpenSSL Package zu sein:

Bug#405041

Antworten