Forum Discussion
Extracting specific information from an HTTP POST and logging it.
I am trying to log the IP address and usernames that are attempting to login to our web portal. I have the iRule mostly working, but I am having difficulty finding out how to extract certain pieces of the HTTP form rather than the whole thing. The fields in the form are UserID, EnteredUserId,and Password. Currently with the script below I get the following message in my LTM log file ": domain=&UserID=Nate10&EnteredUserID=Nate10&Password=PasswordRemoved has attempted to login from 172.xxx.xxx.xxx:61562." For security reasons I would like to just log the UserID and EnteredUserID as well as have a variable that can be toggled on/off to log the password for debugging and troubleshooting. I have tried adding a couple of different scripts to mine that I have seen in other posts, but nothing seems to work. Any ideas?
when HTTP_REQUEST { if { [HTTP::method] equals "POST" } { if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576} { set content_length [HTTP::header "Content-Length"] } else { set content_length 1048576 } HTTP::collect $content_length } } when HTTP_REQUEST_DATA { set client [IP::client_addr]:[TCP::client_port] set url [HTTP::header Host][HTTP::uri] set HTTP_METHOD [HTTP::method] set HTTP_PAYLOAD [HTTP::payload] log local0. "This is a test message $url $client" if {($url contains "/servlet/Login")} { log local0. "$HTTP_PAYLOAD has attempted to login from $client" } }
- Stanislas_Piro2
Cumulonimbus
You can try this:
set user [ URI::query ?[HTTP::payload] user ]
URI::query search the query string in a URI (starting with ?), then search the parameter user and return the value.
As standard POST content format is the same as a query string, add a ? before payload to use URI::query command...
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