we have received some suspicious requests with a customized User-Agent in the HTTP header. Now the idea is to temporary block those Agents with an iRule to do some further investigations.
I can see the User-Agents from the first log line, but no connections with the Agent “Mozilla/4.0” will be dropped (also the second log line does never match). Can anyone explain why this is the case? I want to block only exactly this expression, not something like User-Agent:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0 bla bla because someone uses an old browser.
Furthermore I’d like to know if the “drop” is the correct statement for this, or I should rather more use a HTTP respond code like 403 or a “sorry page”.
You convert your user agent header to lower case and match it against a string containing upper case. Change Mozilla/4.0 to mozilla/4.0 and you should be ok.
Can you try below when HTTP_REQUEST { if { [ string tolower [HTTP::header User-Agent]] contains “name_of_user_agent”} { drop log local0. “Client IP:[IP::client_addr] has been blocked with user agent :[HTTP::header User-Agent]” } }
Thanks for the help! It was the upper case letter from “Mozilla/4.0”, sorry for my noobish question
Thanks F5 Rocks, with the first log line I just wanted to get sure, that the rule hits at all (or maybe a previous match prevents this from hitting).
Pascal, I guess that would be fine too - I just don’t want to block every agent which “contains” Mozilla or Mozilla/4.0, but exactly the expression “Mozilla/4.0”