Forum Discussion
laga44_77816
Nimbostratus
Aug 07, 2008blocking content with iRules
Hi, I'm looking for a sample to block a specific
parameter from a http request URL query string.
As an example is someone hits our site with
http://test.test.11/dir/1315=bad2144
I'd like to block "bad2144"
either by dropping the connection
or a redirect.
Is this possible? Has anyone done this before?
Thankyou,
R
- Sure thing. In your example "/dir/1315=bad2144" is contained in the HTTP::uri variable. If you are looking just for "bad2144" then this should work.
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "bad2144" } { drop } }
- laga44_77816
Nimbostratus
thank you very much.. If I wanted to exclude a specific http url, do I add it in front of this rule? - hoolio
Cirrostratus
Is the bad string found in a parameter value (/dir/1315?param=bad2144)? If so, you might want to verify whether the application accepts the same parameter in the payload of a POST request. A malicious user could potentially use an interception proxy to modify the request from a GET to a POST and include the parameter in the POST data. Also, for the URI check, you could be more specific using HTTP::query. - laga44_77816
Nimbostratus
Is an example of what I want to dream of doing. - laga44_77816
Nimbostratus
thank you.. when I run this script, I get - Andy_Herrman_22
Nimbostratus
The class definitions aren't part of the iRule itself. You'd need to create those separately, either through bigpipe commands or in the management interface. - laga44_77816
Nimbostratus
when I add the classes through the GUI, it doesn't seem to like - hoolio
Cirrostratus
Can you log the value of the class from the iRule to see what's been added (log local0. "class \$::badStrings: $::badStrings". Or more accurately, can you list the contents using 'b class badStrings list'? You may need to escape the ; with \. If you use log local0. "some string", the output is written by default to /var/log/ltm. TCL errors from iRules would also be written to the ltm log file. - laga44_77816
Nimbostratus
When I do a "class list all" through the console, I get - laga44_77816
Nimbostratus
The iRule I created is:
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects