Index: nselib/mongodb.lua =================================================================== --- nselib/mongodb.lua (revision 34977) +++ nselib/mongodb.lua (working copy) @@ -4,12 +4,13 @@ -- @author Martin Holst Swende -- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html -- --- Version 0.2 +-- Version 0.3 -- -- @args mongodb.db - the database to use for authentication -- Created 01/13/2010 - v0.1 - created by Martin Holst Swende -- Revised 01/03/2012 - v0.2 - added authentication support +-- Revised 07/25/2015 - v0.3 - fixed query method to return all documents instead of just 1 local bin = require "bin" local nmap = require "nmap" @@ -589,7 +590,15 @@ end -- result, data, err_msg = bson.fromBson(bsonData) - result, data, err_msg = fromBson(bsonData) + if (responseHeader["numberReturned"] > 1) then + while (#bsonData > 0 and not err_msg) do + local tmpresult + tmpresult, bsonData, err_msg = fromBson(bsonData) + table.insert(result, tmpresult) + end + else + result, data, err_msg = fromBson(bsonData) + end if err_msg then dbg("Got error converting from bson: %s" , err_msg)