Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
turn a service_fp blob into binary blob
local lpeg = require "lpeg"
local U = require "lpeg-utility"
local getquote = U.escaped_quote()
local unescape = lpeg.P ( {
lpeg.Cs((lpeg.V "simple_char" + lpeg.V "unesc")^0),
esc = lpeg.P "\\",
simple_char = lpeg.P(1) - lpeg.V "esc",
unesc = (lpeg.V "esc" * lpeg.Cs( lpeg.V "esc" + lpeg.V "specials" + lpeg.V "code" + lpeg.P(1) ))/"%1",
specials = lpeg.S "trn0" / {t="\t", r="\r", n="\n", ["0"]="\0"},
code = (lpeg.P "x" * lpeg.C(lpeg.S "0123456789abcdefABCDEF"^-2))/function(c)
return string.char(tonumber(c,16)) end,
local function getrequest_response (fp)
fp = string.gsub(fp, "\nSF:", "")
stdnse.debug1("fp = >%s<", fp)
local i, e = string.find(fp, "GetRequest,%d+,")
stdnse.debug1("i=%d, e=%d", i, e)
stdnse.debug1("Matching on >%s<", string.sub(fp, e, e+10))
return unescape:match(getquote:match(fp, e+1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment