Ral...@it... wrote:
>
> This was all very easy.
> However, now I even fail to get the most basic filter to work.
> Before I can establish any useful filters I need to convince
> myself
> that I understood their concept and syntax correctly.
Hi,
Two recommendations if you want to just play with it:
1. Use "SecFilter REGEX" - SecFilter is very broad (it
examines the request line and the body at the same
time) but nice to play with regular expressions.
2. Use the debug log and increase the log level (e.g.
to 9) - then you'll be able to see exactly what
ModSecurity does. This is usually not a good idea
on a production server, though, because it logs
a lot of stuff for every request.
> As a Perl fan I would assume that I have a basic knowledge of
> Perl's
> regex's, and the mod_security doc claims it to be PCRE capable.
ModSecurity uses what Apache uses and if it's Apache 2.x
then it's PCRE.
> SecFilterSelective HTTP_Header
> /agent:?\s*(?:hostA|hostB)-status/i log,pass
Some observations:
1) For the User-Agent header you want your rule to start
with:
SecFilterSelective HTTP_User-Agent ...
2) You don't need / and /
3) And you don't need i at the end, regexes are case
insensitive.
You'll find plenty of examples in the manual, BTW.
> I changed other directives such as e.g. SecServerSignature just
> to verify that
> my tinkering gets recognized at all, and the latter one works if
> the ServerToken is reset to Full.
> Btw, it would be a nice feature if one could place an exec action
> next to SecServerSignature
> to sort of get "randomized" server signatures (e.g. day of week
> or similar)
Noted.
--
Ivan Ristic, Technical Director
Thinking Stone, http://www.thinkingstone.com
ModSecurity: Open source Web Application Firewall
|