Do not assume IPP end-of-attributes-tag is followed by another tag

This commit is contained in:
nnposter 2020-06-13 22:47:15 +00:00
parent 7ff536c8a1
commit 838ec193e3
2 changed files with 18 additions and 17 deletions

View file

@ -52,6 +52,9 @@ o [Windows] Add support for the new loopback behavior in Npcap 0.9983. This
o [NSE][GH#2063] IPP request object conversion to string was not working
correctly [nnposter]
o [NSE][GH#2063] IPP response parser was not correctly processing
end-of-attributes-tag [nnposter]
o [NSE][GH#2010] Oracle TNS parser was incorrectly unmarshalling DALC byte
arrays [nnposter]

View file

@ -80,7 +80,6 @@ IPP = {
local attrib = IPP.Attribute:new()
local val
attrib.tag, attrib.name, val, pos = string.unpack(">Bs2s2", data, pos)
-- print(attrib.name, stdnse.tohex(val))
attrib.value = {}
table.insert(attrib.value, { tag = attrib.tag, val = val })
@ -245,35 +244,34 @@ IPP = {
resp.version, resp.status, resp.reqid, pos = string.unpack(">I2I2I4", data)
resp.attrib_groups = {}
local group
local group = nil
repeat
local tag, attrib
tag, pos = string.unpack(">B", data, pos)
local tag = data:byte(pos, pos)
if ( tag == IPP.Attribute.IPP_TAG_OPERATION or
tag == IPP.Attribute.IPP_TAG_JOB or
tag == IPP.Attribute.IPP_TAG_PRINTER or
tag == IPP.Attribute.IPP_TAG_END ) then
if ( group ) then
if group then
table.insert(resp.attrib_groups, group)
end
if tag ~= IPP.Attribute.IPP_TAG_END then
group = IPP.AttributeGroup:new(tag)
else
group = IPP.AttributeGroup:new(tag)
group = nil
end
pos = pos + 1
else
pos = pos - 1
if not group then
stdnse.debug2("Unexpected tag: %d", tag)
return
end
local attrib
pos, attrib = IPP.Attribute.parse(data, pos)
group:addAttribute(attrib)
end
if ( not(group) ) then
stdnse.debug2("Unexpected tag: %d", tag)
return
end
pos, attrib = IPP.Attribute.parse(data, pos)
group:addAttribute(attrib)
until( pos == #data + 1)
until pos > #data
return resp
end,