Hello everyone, I’m having issue extracting values from CEF log using lua parser. I’m trying to extract the user-agent string in full_request. For example:
\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36\r\nAccept
I’ve been trying to use a variation of sample parser in William Motley book but the parser doesn’t work. Here is the sample parser:
local uaextracting = nw.createParser("CEF_extracting_pos1", "Extracting the user agent from cef full request")
uaextracting:setKeys({
nwlanguagekey.create("user.agent")
})
function uaextracting:extractInfo(token, first, last)
local payload = nw.getPayload()
local endOfLine = payload:find("Accept", last + 1, last + 190)
if endOfLine then
local uastring = payload:tostring(last + 1, endOfLine - 4 )
if uastring then
nw.createMeta(self.keys["user.agent"], uastring)
end
end
end
uaextracting:setCallbacks({
["Agent: "] = uaextracting.extractInfo
})
I'm new to lua parser and i've been stuck with this for days. Any help would be appreciated. Thank you