Forum Discussion
Blocking URLs with certain characters
I'm trying to use an iRule to drop any connections to a web server that include the less-than or greater-than characters in the URL. This is what I have so far. "illegal_url_chars" is a data group list containing two strings for the < and > characters.
It's not currently working and nothing is getting logged. This is my first iRule so any help is appreciated.
We're on v11.6.0 and upgrading to 13 soon.
when HTTP_REQUEST {
if { [class match [HTTP::uri] contains illegal_url_chars] } {
log local0. "Detected illegal URL characters from [IP::client_addr]"
log local0. "[HTTP::request]"
TCP::close
drop
}
}
4 Replies
- youssef1
Cumulonimbus
Can you show us what is your illegal URL Chars?
- Stanislas_Piro2
Cumulonimbus
Hi,
you can try this code:
when HTTP_REQUEST { if { [string match {*[<>]*} [HTTP::uri]} { log local0. "Detected illegal URL characters from [IP::client_addr]" log local0. "[HTTP::request]" TCP::close drop } }If the URI is encoded, you have to convert it before check
when HTTP_REQUEST { set uri [URI::decode [HTTP::uri]] if { [string match {*[<>]*} $uri} { log local0. "Detected illegal URL characters from [IP::client_addr]" log local0. "[HTTP::request]" TCP::close drop } } - Bobby_Hood_3633
Nimbostratus
- youssef1
Cumulonimbus
If you have ASM, you can do It easly... Otherwise you can use Stanislas Irule wich responds perfectly to your needs...
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
