XML Payload =========== ROOT#0;APS#0;BSMIS_APS_PER_AC#4;BSMIS_AP_INFO#230241 2015-05-06T18:17:27.152-05:00 ATTRIBUTE VALUE CHANGE REGISTERED LUA Code ======== -- Execution -- -- "c:\Program Files\Wireshark\tshark.exe" -q -X lua_script:"c:\External_Copies\Tools\Lua\xml_dissect.lua" -r "c:\users\cw1\Desktop\SOAPXML_Notifications.pcap" f_xml_cdata = Field.new("xml.cdata") xml_tag_f = Field.new("xml.tag") xml_field = Field.new("xml") local tap = Listener.new(nil, "tcp && xml && !tcp.analysis.retransmission") local HTML_REQ = { ["HTTP"] = 1, ["GET "] = 1, ["PUT "] = 1, ["POST"] = 1, } function BreakUpLongLines (str, sep) --Array to return each of the elements vals = {}; valindex = 1; word = "" local strSize = #str local offset =0 while strSize > offset do svar, evar=string.find(str, sep, offset) if evar == nil then return vals end if evar > strSize then return vals end vals[valindex] = string.sub(str, offset,evar) --print("Index [" .. valindex .. "] " .. vals[valindex]) valindex = valindex+1 offset=evar+1 end return vals end local function handle_xml(pinfo, tvb) local fieldinfo = xml_field() local xmldata = tvb(fieldinfo.offset):string() -- some of these packets start w/HTTP header...skip to XML local starts = xmldata:sub(1,4) if HTML_REQ[starts] ~= nil then local pos = string.find(xmldata, "<") local objInst = "" local ntfType = "" local attrType = "" local attrValue = "" for i,v in pairs(la_cdata), la_cdata do if string.find(v,"objectInstance") then local s = string.find(v,">") local e = string.find(v,"<") local objStr = string.gsub(string.sub(v, s+1, e-1), ";AP#0", "") --print("Start index = " .. s .. " and End index = " .. e) -- Extract out instance for Attr Val Change objInst = string.sub(objStr, string.find(objStr, "%d+$")) --print("Object Instance: " .. objInst) end if string.find(v,"notificationType") then local s = string.find(v,">") local e = string.find(v,"<") ntfType = string.sub(v, s+1, e-1) --print("Notification Type: " .. ntfType) end if ntfType == "ATTRIBUTE VALUE CHANGE" then if string.find(v,"registeredAs") then attrType = string.sub(v, string.find(v, "%d+")) --print("Attribute Type: " .. attrType) -- TODO --> Need decoder for type values local s = string.find(v,">") local e = string.find(v,"<") attrValue = string.sub(v, s+1, e-1) --print("Attribute Value: " .. attrValue) end elseif ntfType == "STATE CHANGE" then if string.find(v,"attribute name") then attrType = string.gsub(string.sub(v, string.find(v, "\"%a+\"")), "\"", "") --print("Attribute Type: " .. attrType) local s = string.find(v,">") local e = string.find(v,"<") attrValue = string.sub(v, s+1, e-1) --print("Attribute Value: " .. attrValue) end end --print(v) end -- Print summary of event if ntfType == "ATTRIBUTE VALUE CHANGE" or ntfType == "STATE CHANGE" then if ntfType == "ATTRIBUTE VALUE CHANGE" then print("Attribute Value Change detected") elseif ntfType == "STATE CHANGE" then print("State Change detected") end print("Object Instance = " .. objInst) print("Attribute Value Change Type = " .. attrType) print("Attribute Value Change Value = " .. attrValue) end end function tap.draw() end function tap.reset() end