Forum Discussion
R__Winters_7757
Nimbostratus
Sep 16, 2010iRule to alert on hotlinking
Hey all,
I am looking for an irule to trigger an alert whenever hotlinking is detected. We are having issues with phishers mirroring our pages but thankfully they keep the FQDN of the images so we would like to use the ASM to detect when our images are being hotlinked.
note: we do NOT want to block the hotlinking, only trigger an alert with the referer url included
Thanks in advance.
- Something like this should work for you. Just check the Referer header and see if it's from the same domain as the request.
when HTTP_REQUEST { if { [HTTP::header exists "Referer"] } { if { ! ([HTTP::header "Referer"] starts_with "http://[HTTP::host]") } { log local0. "Someone is hotlinking this image. Uri: [HTTP::uri]; Referer: '[HTTP::header Referer]'"; } } }
- R__Winters_7757
Nimbostratus
Joe,when HTTP_REQUEST { set refer_host [string tolower [URI::host [HTTP::header Referer]]] if { ( [matchclass [HTTP::uri] ends_with $::images] ) and ( not [matchclass $refer_host starts_with $::allowed_referers] ) } { log "Warning, Hotlinking detected from: $refer_host" } }
- local 0 is the logging level for syslog.. 0 being the highest, 7 the lowest..
- DeVon_Jarvis
Altostratus
As far as the header Referer goes, this header would include the full URL, including protocol. Just like you would see it in the URL field in the browser. For example: - hoolio
Cirrostratus
I'd try to tailor the iRule (and optionally datagroup) for your exact scenario to minimize the load this would use. If you only have one or two domains that should be referring to your web app and it's only http:// for example, I'd avoid a datagroup and any parsing of the referer header. If it's more complicated than that, I'd suggest using timing to compare the efficiency of parsing the referer header and/or checking against a datagroup.
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