LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-18-2012, 05:52 AM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309

why did you wrote {9} instead of {3} as it was in the original post?
a hexadecimal value can be: [0-9a-fA-F], so an ip can be:
Code:
[0-9a-fA-F][0-9a-fA-F](\.[0-9a-fA-F][0-9a-fA-F]){3}
  ^ one digit ^ second( ^ dot ^ digit  ^ digit ) repeat three times




_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
 
Old 06-18-2012, 05:58 AM   #17
papampi
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
with this failregex :
failregex = WARNING: ClusteredCache - Internal error receiving remote cache packet [(<HOST> ) -\ (\.[0-9a-fA-F][0-9a-fA-F]){9})]: java.io.EOFException
it gives me this error :
2012-06-18 15:30:17,615 fail2ban.filter : ERROR Unable to compile regular expression 'WARNING: ClusteredCache - Internal error receiving remote cache packet [((?:::f{4,6}?(?P<host>[\w\-.^_]+) ) -\ (\.[0-9a-fA-F][0-9a-fA-F]){9})]: java.io.EOFException'

and with this one :
failregex = WARNING: ClusteredCache - Internal error receiving remote cache packet [<HOST> - (\.[0-9a-fA-F][0-9a-fA-F]){9})]: java.io.EOFException
gives me this:
2012-06-18 15:32:43,808 fail2ban.filter : ERROR Unable to compile regular expression 'WARNING: ClusteredCache - Internal error receiving remote cache packet [(?:::f{4,6}?(?P<host>[\w\-.^_]+) - (\.[0-9a-fA-F][0-9a-fA-F]){9})]: java.io.EOFException'

Last edited by papampi; 06-18-2012 at 06:00 AM.
 
Old 06-18-2012, 05:58 AM   #18
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by papampi View Post
fail2 ban does not need regex for ip
the <HOST> part do the work
I only need regex for the hex part
Your question keeps changing!!!

To match a string of hex:

[0-9a-fA-F]*

but you have spaces before each pair, so:
Code:
( +[0-9a-fA-F]{2})*
or maybe:
Code:
( +[0-9a-fA-F]{2})* ?
the second one allows for an optional space at the end
 
Old 06-18-2012, 06:02 AM   #19
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by pan64 View Post
why did you wrote {9} instead of {3} as it was in the original post?
a hexadecimal value can be: [0-9a-fA-F], so an ip can be:
Code:
[0-9a-fA-F][0-9a-fA-F](\.[0-9a-fA-F][0-9a-fA-F]){3}
  ^ one digit ^ second( ^ dot ^ digit  ^ digit ) repeat three times




_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
He does not want to match the IP---only the hex string AFTER the IP
 
Old 06-18-2012, 06:04 AM   #20
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
that is not an IP, that is probably a mac address. you can use probably the following regex:
Code:
failregex = WARNING: ClusteredCache - Internal error receiving remote cache packet [<HOST> - ([ 0-9a-fA-F]+)]: java.io.EOFException

_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
 
Old 06-18-2012, 06:11 AM   #21
papampi
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
failregex = WARNING: ClusteredCache - Internal error receiving remote cache packet [<HOST> - ([ 0-9a-fA-F]+)]: java.io.EOFException

gives this error :
2012-06-18 15:43:16,810 fail2ban.filter : ERROR Unable to compile regular expression 'WARNING: ClusteredCache - Internal error receiving remote cache packet [(?:::f{4,6}?(?P<host>[\w\-.^_]+) - ([ 0-9a-fA-F]+)]: java.io.EOFException'
 
Old 06-18-2012, 06:15 AM   #22
papampi
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
so I will block the ip's manually for now !
and will change things, until I get some thing !

thank you all for all the helps !

will post my results later !!!!
 
Old 06-18-2012, 06:19 AM   #23
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
papampi;

first, go back to a question I asked earlier: Does this program accept extended regex syntax?

second, the regex your just tried will match at least one instance of a space followed by ONE hex character. You have a sequence of space followed by TWO hex characters. See the code that I suggested.

But first, we have to know what kind of regex your program will accept......
 
Old 06-18-2012, 06:47 AM   #24
papampi
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany View Post
papampi;
first, go back to a question I asked earlier: Does this program accept extended regex syntax?
But first, we have to know what kind of regex your program will accept......
dont know what do you mean by extended regex
here is the fail2ban manual : http://www.fail2ban.org/wiki/index.php/MANUAL_0_8
 
Old 06-18-2012, 06:51 AM   #25
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
yes, and it told: python style regexp: http://docs.python.org/library/re.html
 
Old 06-18-2012, 06:59 AM   #26
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
OK---forget "extended" regexes---use the Python rules. (I tried to see if they look like extended regex rules, but my brain has exceeded its daily quota..... )
 
Old 06-18-2012, 07:14 AM   #27
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
what I found: you can use this page to test python regexps. You have [ and ] in the original text, you need to escape them in a regexp, so you need to use: \[ and \]. The regexp generated from <HOST> does not match ip addresses like 1.2.3.4 (but hostnames, like a.b.c.d).
this looks now ok, but I'm not really sure:
Code:
WARNING: ClusteredCache - Internal error receiving remote cache packet .(<HOST>) -\s?([ 0-9a-fA-F]+).: java.io.EOFException

_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
 
Old 06-18-2012, 06:05 PM   #28
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by pan64 View Post
The regexp generated from <HOST> does not match ip addresses like 1.2.3.4
Yes it does, it handles both IP addresses and FQDNs and you can verify that by running fail2ban-regex on some log lines.


Quote:
Originally Posted by papampi View Post
I need a regex to ban ip's from this log
Either
Code:
error receiving remote cache packet \[<HOST> -
or the shorter
Code:
error .* packet \[<HOST> -
will do.
 
1 members found this post helpful.
Old 06-19-2012, 12:07 AM   #29
papampi
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Yes it does, it handles both IP addresses and FQDNs and you can verify that by running fail2ban-regex on some log lines.
Either
Code:
error receiving remote cache packet \[<HOST> -
or the shorter
Code:
error .* packet \[<HOST> -
will do.
Thanks man !
It works !!!!
 
Old 06-19-2012, 12:29 AM   #30
papampi
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
so it means we dont need to insert the full line from log file in failregex ?
and some small part of log where the ip is located will do the job ?

Last edited by papampi; 06-19-2012 at 04:27 AM.
 
  


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
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
[SOLVED] fail2ban does not ban, maybe my regex is wrong? JeanC Linux - Server 2 03-17-2011 10:01 AM
Fail2ban regex help please wvroger Linux - Security 1 05-23-2010 07:30 PM
Fail2ban and Dovecot Regex kevinslair Linux - Software 3 05-31-2009 08:19 PM
Need help with fail2ban regex jakev383 Linux - Security 6 12-07-2008 09:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:27 PM.

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