4

If I run

fail2ban-regex '31.22.105.115 - - [11/Apr/2014:18:09:54 +0100] "GET /admin/config.php 
HTTP/1.0" 301 573 "-" "-"' '^<HOST> - - (?:\[[^]]*\] )+\"(GET|POST)/(?i)(PMA|phptest|phpmyadmin|myadmin|mysql|mysqladmin|sqladmin|mypma|admin|xampp|mysqldb|mydb|db|pmadb|phpmyadmin1|phpmyadmin2|cgi-bin)'

Then I get Success, the total number of match is 1. Yet If I have an access.log containing

 .
 .
109.68.191.26 - - [11/Apr/2014:12:47:50 +0100] "GET / HTTP/1.0" 301 541 "-" "masscan/1.0 (https://github.com/robertdavidgraham/masscan)"
31.22.105.115 - - [11/Apr/2014:18:09:54 +0100] "GET /admin/config.php HTTP/1.0" 301 573 "-" "-"

and a filter.d .conf file containing

failregex  = '^<HOST> - - (?:\[[^]]*\] )+\"(GET|POST) /(?i)(PMA|phptest|phpmyadmin|myadmin|mysql|mysqladmin|sqladmin|mypma|admin|xampp|mysqldb|mydb|db|pmadb|phpmyadmin1|phpmyadmin2|cgi-bin)'

, and I try running fail2ban-regex path/to/access.log /etc/fail2ban/filter.d/apache-getphp.conf I get Sorry, no match, why?

3

Ah, simply that I shouldn't quote the regex in the filter.d file, i.e, should be:

failregex  = ^<HOST> - - (?:\[[^]]*\] )+\"(GET|POST) /(?i)(PMA|phptest|phpmyadmin|myadmin|mysql|mysqladmin|sqladmin|mypma|admin|xampp|mysqldb|mydb|db|pmadb|phpmyadmin1|phpmyadmin2|cgi-bin)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.