Created
October 1, 2014 17:53
-
-
Save bonsaiviking/2ab2483fab65a552eb8f to your computer and use it in GitHub Desktop.
turn a service_fp blob into binary blob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment