diff --git a/nselib/ipp.lua b/nselib/ipp.lua index 42209991d..a73b87245 100644 --- a/nselib/ipp.lua +++ b/nselib/ipp.lua @@ -290,19 +290,13 @@ HTTP = { Helper = { - new = function(self, host, port, options) - local o = { host = host, port = port, options = options or {} } + new = function(self, host, port) + local o = { host = host, port = port } setmetatable(o, self) self.__index = self return o end, - connect = function(self) - self.socket = nmap.new_socket() - self.socket:set_timeout(self.options.timeout or 10000) - return self.socket:connect(self.host, self.port) - end, - getPrinters = function(self) local attribs = { @@ -412,10 +406,6 @@ Helper = { return output end, - - close = function(self) - return self.socket:close() - end, } return _ENV; diff --git a/scripts/cups-info.nse b/scripts/cups-info.nse index 9f96c78a9..14743a824 100644 --- a/scripts/cups-info.nse +++ b/scripts/cups-info.nse @@ -1,7 +1,6 @@ local ipp = require "ipp" local shortport = require "shortport" local stdnse = require "stdnse" -local string = require "string" local table = require "table" description = [[ @@ -51,13 +50,8 @@ local verbose_states = { action = function(host, port) - local helper = ipp.Helper:new(host, port) - if ( not(helper:connect()) ) then - return stdnse.format_output(false, "Failed to connect to server") - end - - local status, printers = helper:getPrinters() - if ( not(status) ) then + local status, printers = ipp.Helper:new(host, port):getPrinters() + if not status then return end diff --git a/scripts/cups-queue-info.nse b/scripts/cups-queue-info.nse index e89b1aef7..f5c78a69e 100644 --- a/scripts/cups-queue-info.nse +++ b/scripts/cups-queue-info.nse @@ -35,13 +35,8 @@ categories = {"safe", "discovery"} portrule = shortport.port_or_service(631, "ipp", "tcp", "open") action = function(host, port) - local helper = ipp.Helper:new(host, port) - if ( not(helper:connect()) ) then - return stdnse.format_output(false, "Failed to connect to server") - end - - local output = helper:getQueueInfo() - if ( output ) then + local output = ipp.Helper:new(host, port):getQueueInfo() + if output then return stdnse.format_output(true, output) end end