Forum Discussion
matt_wheeler_11
Jul 18, 2007Historic F5 Account
Binary Scan help with an iRule
I am working with a customer where we are trying to grab specific content from a SQL response to create persistence. However, when the rule get to the line where I log line "0004 clientdata: $clientd...
matt_wheeler_11
Jul 20, 2007Historic F5 Account
Here is the irule that I got to work...However, does anyone know how to convert the ASCII into text so that I can just grab the InsertService from the packets?
when RULE_INIT {
log local0. "0001 iRule RealEC-iRule initialized"
}
when CLIENT_ACCEPTED {
log local0. "0002 New client connection from [IP::client_addr]:[TCP::client_port]"
TCP::collect
log local0. "0003 Collecting"
}
when CLIENT_DATA {
binary scan [TCP::payload] H* clientdata
Convert Text to HEX before Client_Accepted so we only do this task once.
set ::InsertServiceEvent "1201003400000000000015000601001b000102001c000c0300280004ff080001550000004d5353514c53657276657200140b0000"
set ::TranOrigID "005400720061006e004f00720069006700490044"
set ::TranRefNum "005400720061006e005200650066004e0075006d"
log local0. "0004 clientdata: $clientdata"
Look for InsertService 128 bites into the TCP Payload
set svc_event [findstr $clientdata $::InsertServiceEvent]
log local0. "0004a svc_event: $svc_event"
If we see Insert Service set Persist
if { [findstr $clientdata $::InsertServiceEvent] != "" } {
Look for TranOrigID, offset 40 (Hex) and stop at &
set trans_id [findstr $clientdata $::TranOrigID 40 "26"]
Look for TranRefNum, offset 40 (Hex) and stop at &
set ref_id [findstr $clientdata $::TranRefNum 40 "26"]
Concantenate the two values and persist
set db_id $trans_id:$ref_id
if { $db_id != "" } {
log local0. "0005 DB-ID=$db_id"
persist uie $db_id
log local0. "Persisting $db_id to [persist lookup uie $db_id]"
TCP::release
}
}
}
when LB_SELECTED {
After logic is run and server is selected, log which one
log local0. "Selected server [LB::server]"
}
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