LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-10-2008, 12:19 PM   #1
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Rep: Reputation: 30
Help with regex


Hello all!

I am using fail2ban to help keep the bad guys away from my mail server. Well, it's been working wonderfully, but now I'm using dovecot for my imap server, and I need a bit of help.

I am using this line so far:

failregex = dovecot.*(?:authentication failure).*rhost=(?:::f{4,6}?(?P<host>\S*)

to go through the log file entry of

12:47:58 smtp dovecot-auth: (pam_unix) authentication failure; logname= uid=0 euid=0 tty=dovecot ruser= rhost=xxx.xxx.xxx.xxx

in my auth.log file.

Where am I going wrong in my regex? I am FAR from an expert, so I imagine that my line that I have above might be full of problems. Any help is appreciated!
 
Old 07-10-2008, 06:21 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
It might be clearer if you slapped it into code-tags, I'm not 100% sure what that smiley
is meant to be; but I'd guess the problem is the
Code:
?P<host>\S*)
which won't match anything on that line.



Cheers,
Tink
 
Old 07-10-2008, 07:19 PM   #3
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Tinkster View Post
It might be clearer if you slapped it into code-tags, I'm not 100% sure what that smiley
is meant to be; but I'd guess the problem is the
Code:
?P<host>\S*)
which won't match anything on that line.



Cheers,
Tink

Sorry about that. Yeah, sometimes, they'll grab code and make it look like smiley faces.


But here's the original code:

Code:
failregex = dovecot.*(?:authentication failure).*rhost=(?:::f{4,6}:)?(?P<host>\S*)
I'll try your idea out and see how well it works. Thanks for the quick reply! I appreciate it!
 
Old 07-10-2008, 07:28 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by tbeehler View Post
Sorry about that. Yeah, sometimes, they'll grab code and make it look like smiley faces.


But here's the original code:

Code:
failregex = dovecot.*(?:authentication failure).*rhost=(?:::f{4,6}:)?(?P<host>\S*)
I'll try your idea out and see how well it works. Thanks for the quick reply! I appreciate it!
I just tested it, it works w/o the bit I pointed out.

What were you hoping to match with it?



Cheers,
Tink
 
Old 07-11-2008, 10:05 AM   #5
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Tinkster View Post
I just tested it, it works w/o the bit I pointed out.

What were you hoping to match with it?



Cheers,
Tink
The oddest thing, I went back, copied and pasted my code again, and it worked.

I was trying to match this:

smtp dovecot-auth: (pam_unix) authentication failure; logname= uid=0 euid=0 tty=dovecot ruser= rhost=61.152.169.150

in my /var/log/auth.log file

The guy keeps trying to log in from various points and I'm trying to get fail2ban to read the auth log file and ban him accordingly.

Thank's for all your help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
regex with sed to process file, need help on regex dwynter Linux - Newbie 5 08-31-2007 05:10 AM
Regex help Penguin of Wonder Programming 4 08-06-2007 07:04 AM
regex help siyisoy Programming 4 04-07-2006 05:32 AM
Regex Help cmfarley19 Programming 5 03-31-2005 10:13 PM
GNU C++ Regex lumux Programming 5 09-29-2003 10:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration