diff --git a/nselib/srvloc.lua b/nselib/srvloc.lua index fd45e190d..246d23a0f 100644 --- a/nselib/srvloc.lua +++ b/nselib/srvloc.lua @@ -324,15 +324,19 @@ Helper = { self.socket:set_timeout(5000) self.socket:sendto( self.host, self.port, tostring(sr) ) - local r = Reply.Service.fromSocket(self.socket) - self.socket:close() + local result = {} + repeat + local r = Reply.Service.fromSocket(self.socket) + if ( r ) then + table.insert(result, r:getUrl()) + end + self.xid = self.xid + 1 + until(not(r)) - self.xid = self.xid + 1 - - if ( not(r) ) then + if ( #result == 0 ) then return false, "ERROR: Helper.Locate no response received" end - return true, r:getUrl() + return true, result end, --- Requests an attribute from the server @@ -355,7 +359,6 @@ Helper = { self.socket:sendto( self.host, self.port, tostring(ar) ) local r = Reply.Attribute.fromSocket(self.socket) - self.socket:close() self.xid = self.xid + 1 if ( not(r) ) then @@ -364,4 +367,8 @@ Helper = { return true, r:getAttribList() end, + close = function(self) + return self.socket:close() + end, + } \ No newline at end of file diff --git a/scripts/broadcast-novell-locate.nse b/scripts/broadcast-novell-locate.nse index 281272365..980ffc617 100644 --- a/scripts/broadcast-novell-locate.nse +++ b/scripts/broadcast-novell-locate.nse @@ -31,10 +31,15 @@ function action() local helper = srvloc.Helper:new() local status, bindery = helper:ServiceRequest("bindery.novell", "DEFAULT") - if ( not(status) or not(bindery) ) then return end + if ( not(status) or not(bindery) ) then + helper:close() + return + end + bindery = bindery[1] local srvname = bindery:match("%/%/%/(.*)$") local status, attrib = helper:AttributeRequest(bindery, "DEFAULT", "svcaddr-ws") + helper:close() attrib = attrib:match("^%(svcaddr%-ws=(.*)%)$") if ( not(attrib) ) then return end @@ -59,6 +64,7 @@ function action() local output = {} local status, treename = helper:ServiceRequest("ndap.novell", "DEFAULT") if ( status ) then + treename = treename[1] treename = treename:match("%/%/%/(.*)%.$") table.insert(output, ("Tree name: %s"):format(treename)) end