mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Compare commits
4 Commits
5daccaed1d
...
46fe5228f4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46fe5228f4 | ||
|
|
6dc02c9bcd | ||
|
|
3d205335b9 | ||
|
|
138c7b7467 |
@@ -100,18 +100,17 @@ IPP = {
|
||||
until( name_len ~= 0 )
|
||||
|
||||
-- do minimal decoding
|
||||
for i=1, #attrib.value do
|
||||
if ( attrib.value[i].tag == IPP.Attribute.IPP_TAG_INTEGER ) then
|
||||
attrib.value[i].val = string.unpack(">I4", attrib.value[i].val)
|
||||
elseif ( attrib.value[i].tag == IPP.Attribute.IPP_TAG_ENUM ) then
|
||||
attrib.value[i].val = string.unpack(">I4", attrib.value[i].val)
|
||||
for _, av in ipairs(attrib.value) do
|
||||
if av.tag == IPP.Attribute.IPP_TAG_INTEGER then
|
||||
av.val = string.unpack(">I4", av.val)
|
||||
elseif av.tag == IPP.Attribute.IPP_TAG_ENUM then
|
||||
av.val = string.unpack(">I4", av.val)
|
||||
end
|
||||
end
|
||||
|
||||
if ( 1 == #attrib.value ) then
|
||||
attrib.value = attrib.value[1].val
|
||||
end
|
||||
--print(attrib.name, attrib.value, stdnse.tohex(val))
|
||||
|
||||
return pos, attrib
|
||||
end,
|
||||
@@ -152,26 +151,14 @@ IPP = {
|
||||
-- @param tag number containing the attribute tag
|
||||
getAttribute = function(self, name, tag)
|
||||
for _, attrib in ipairs(self.attribs) do
|
||||
if ( attrib.name == name ) then
|
||||
if ( not(tag) ) then
|
||||
return attrib
|
||||
elseif ( tag and attrib.tag == tag ) then
|
||||
return attrib
|
||||
end
|
||||
if attrib.name == name and (not tag or attrib.tag == tag) then
|
||||
return attrib
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
getAttributeValue = function(self, name, tag)
|
||||
for _, attrib in ipairs(self.attribs) do
|
||||
if ( attrib.name == name ) then
|
||||
if ( not(tag) ) then
|
||||
return attrib.value
|
||||
elseif ( tag and attrib.tag == tag ) then
|
||||
return attrib.value
|
||||
end
|
||||
end
|
||||
end
|
||||
return (self:getAttribute(name, tag) or {}).value
|
||||
end,
|
||||
|
||||
__tostring = function(self)
|
||||
@@ -375,7 +362,7 @@ Helper = {
|
||||
{ tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "job-name" },
|
||||
{ tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "job-state" },
|
||||
{ tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "printer-uri" },
|
||||
-- { tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "job-originating-user-name" },
|
||||
{ tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "job-originating-user-name" },
|
||||
-- { tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "job-printer-state-message" },
|
||||
-- { tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "job-printer-uri" },
|
||||
{ tag = IPP.Attribute.IPP_TAG_KEYWORD, val = "time-at-creation" } } ),
|
||||
@@ -393,16 +380,19 @@ Helper = {
|
||||
|
||||
local results = {}
|
||||
for _, ag in ipairs(response:getAttributeGroups(IPP.Attribute.IPP_TAG_JOB)) do
|
||||
local uri = ag:getAttributeValue("printer-uri")
|
||||
local printer = uri:match(".*/(.*)$") or "Unknown"
|
||||
local printer = ag:getAttributeValue("printer-uri"):match(".*/(.*)$") or "Unknown"
|
||||
-- some jobs have multiple state attributes, so far the ENUM ones have been correct
|
||||
local state = ag:getAttributeValue("job-state", IPP.Attribute.IPP_TAG_ENUM) or ag:getAttributeValue("job-state")
|
||||
-- some jobs have multiple id tag, so far the INTEGER type have shown the correct ID
|
||||
local id = ag:getAttributeValue("job-id", IPP.Attribute.IPP_TAG_INTEGER) or ag:getAttributeValue("job-id")
|
||||
local tm = ag:getAttributeValue("time-at-creation")
|
||||
local size = ag:getAttributeValue("job-k-octets") .. "k"
|
||||
local jobname = ag:getAttributeValue("com.apple.print.JobInfo.PMJobName") or "Unknown"
|
||||
local owner = ag:getAttributeValue("com.apple.print.JobInfo.PMJobOwner") or "Unknown"
|
||||
local jobname = ag:getAttributeValue("com.apple.print.JobInfo.PMJobName")
|
||||
or ag:getAttributeValue("job-name")
|
||||
or "Unknown"
|
||||
local owner = ag:getAttributeValue("com.apple.print.JobInfo.PMJobOwner")
|
||||
or ag:getAttributeValue("job-originating-user-name")
|
||||
or "Unknown"
|
||||
|
||||
results[printer] = results[printer] or {}
|
||||
table.insert(results[printer], {
|
||||
|
||||
Reference in New Issue
Block a user