Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] syslog_ng - run script on passwordfailure
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
petterg
Guru
Guru


Joined: 25 Mar 2004
Posts: 500
Location: Oslo, Norway

PostPosted: Sat Dec 25, 2004 1:53 am    Post subject: [SOLVED] syslog_ng - run script on passwordfailure Reply with quote

On http://www.gentoo.org/doc/en/gentoo-security.xml I read, for metalog:
Quote:

If you want to be notified by email whenever a password failure occurs use one of the following scripts.
[...]
Then uncomment the command line under "Password failures" in /etc/metalog/metalog.conf like:
Code:

command  = "/usr/local/sbin/mail_pwd_failures.sh"



I would like to do the same using syslog_ng. At the same site I read:
Quote:
Syslog-ng provides some of the same features as syslog and metalog with a small difference. It can filter messages based on level and content (like metalog), provide remote logging like syslog, handle logs from syslogd (even streams from Solaris), write to a TTY, execute programs, and it can act as a logging server. Basically it is the best of both loggers combined with advanced configuration.


So I'm wondering how to do this using syslog_ng. Does anyone know?


Last edited by petterg on Thu Dec 30, 2004 2:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
mbjr
Guru
Guru


Joined: 17 Jan 2004
Posts: 531
Location: Budapest/Hungary

PostPosted: Sat Dec 25, 2004 8:34 pm    Post subject: Reply with quote

Hi,

Did you try this: https://lists.balabit.hu/pipermail/syslog-ng/ ? :-)
_________________
mb
Back to top
View user's profile Send private message
petterg
Guru
Guru


Joined: 25 Mar 2004
Posts: 500
Location: Oslo, Norway

PostPosted: Sun Dec 26, 2004 5:17 pm    Post subject: Reply with quote

Are you sure you posted the link you were planing to post?
Back to top
View user's profile Send private message
mbjr
Guru
Guru


Joined: 17 Jan 2004
Posts: 531
Location: Budapest/Hungary

PostPosted: Tue Dec 28, 2004 10:42 am    Post subject: Reply with quote

I am :-) I just didn't have the time to search over the full mailing list, but I'm sure you're not alone with the problem.

Syslog-ng is highly configurable as well as Matalog :-)
_________________
mb
Back to top
View user's profile Send private message
petterg
Guru
Guru


Joined: 25 Mar 2004
Posts: 500
Location: Oslo, Norway

PostPosted: Tue Dec 28, 2004 2:06 pm    Post subject: Reply with quote

I might be blind and/or dumb, but I can't see any search functionality there
Back to top
View user's profile Send private message
hensan
l33t
l33t


Joined: 26 Jun 2003
Posts: 868
Location: Sweden

PostPosted: Tue Dec 28, 2004 2:37 pm    Post subject: Reply with quote

In syslog-ng, sending stuff to a program is done with the 'program' destination:

Code:
destination d_auth { program("/path/to/script"); };


Combine that with a filter:

Code:
filter f_auth { facility(auth,authpriv) and level(notice); };


and a log statement:

Code:
log { source(src); filter(f_auth); destination(d_auth); };


I haven't done any advanced syslogging in a while, but when I last looked into this, syslog-ng worked by launching the script/program when syslog-ng was started and then sent the logs to its stdin. So you'll have to make the script a loop that sends what it gets on stdin.
Back to top
View user's profile Send private message
mbjr
Guru
Guru


Joined: 17 Jan 2004
Posts: 531
Location: Budapest/Hungary

PostPosted: Tue Dec 28, 2004 6:23 pm    Post subject: Reply with quote

Well, this ment to be a full archive download, so basically:
Quote:

foobar ~ # wget https://lists.balabit.hu/pipermail/syslog-ng.mbox/syslog-ng.mbox
foobar ~ # cat syslog-ng.mbox |grep $my_searchstring


:-)[/quote]
_________________
mb
Back to top
View user's profile Send private message
mbjr
Guru
Guru


Joined: 17 Jan 2004
Posts: 531
Location: Budapest/Hungary

PostPosted: Tue Dec 28, 2004 6:23 pm    Post subject: Reply with quote

Well, this ment to be a full archive download, so basically:
Quote:

foobar ~ # wget https://lists.balabit.hu/pipermail/syslog-ng.mbox/syslog-ng.mbox
foobar ~ # cat syslog-ng.mbox |grep $my_searchstring


:-)
_________________
mb
Back to top
View user's profile Send private message
petterg
Guru
Guru


Joined: 25 Mar 2004
Posts: 500
Location: Oslo, Norway

PostPosted: Wed Dec 29, 2004 2:09 pm    Post subject: Reply with quote

I'm able to filter out everything from facilities / programs, and trigger scripts, but I can't figure out how to filter out what has to do with failed logins. Like imap logins and smtp-auth does not show up in the auth or authpriv facility. Everything from sshd comes in the auth facility at info level, no matter if it's a failed login or debug information.

Seems like I have to pass all logs from all services that deals with logins to a script, and do some reg-expr in the script to figure out if it should handle or ignore.
Back to top
View user's profile Send private message
hensan
l33t
l33t


Joined: 26 Jun 2003
Posts: 868
Location: Sweden

PostPosted: Wed Dec 29, 2004 2:32 pm    Post subject: Reply with quote

Use the program filter to catch the messages that don't use the auth facility, and the match filter to catch only messages that contain the word failed.
Back to top
View user's profile Send private message
petterg
Guru
Guru


Joined: 25 Mar 2004
Posts: 500
Location: Oslo, Norway

PostPosted: Thu Dec 30, 2004 12:52 am    Post subject: Reply with quote

In fact that is the problem - match() apares to not make any difference on the filter.
How would the config of a filter for this look?
filters out the facilities auth and authpriv,
the programs imap and imap-ssl,
and matches the strings "Failed password" or "illegal user"
Back to top
View user's profile Send private message
hensan
l33t
l33t


Joined: 26 Jun 2003
Posts: 868
Location: Sweden

PostPosted: Thu Dec 30, 2004 12:15 pm    Post subject: Reply with quote

Something like:

Code:
filter f_auth {
        facility(auth, authpriv) or
        program("imap") or
        program("imap-ssl") and
        match("(Failed password|illegal user)");
};
Back to top
View user's profile Send private message
petterg
Guru
Guru


Joined: 25 Mar 2004
Posts: 500
Location: Oslo, Norway

PostPosted: Thu Dec 30, 2004 2:07 pm    Post subject: Reply with quote

FUNKAR! :)

Thanx a lot.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum