From 4728d7437d16381afe214864b9f4be589eadc007 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 18 Aug 2012 03:32:50 +0000 Subject: [PATCH] Fixes to rpc-grind NSE: rpc-grind Connect(): RPC library does not support: nil protocol NSE: rpc-grind Connect(): RPC library does not support: rpcbind version 81578896 These errors caused by ChkProgram and ChkVersion called from rpc.Comm.Connect. Added a dummy program in rpc-grind and a check for self.checkprogver in ChkVersion, and everything works great. Also fixed portrule to only fail if the non-rpcbind service name was not the result of table lookup. Was failing on port 2049 (in nmap-services as "nfs") without -sV. --- nselib/rpc.lua | 1 + scripts/rpc-grind.nse | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nselib/rpc.lua b/nselib/rpc.lua index c0c9014ee..03955ceaa 100644 --- a/nselib/rpc.lua +++ b/nselib/rpc.lua @@ -231,6 +231,7 @@ Comm = { -- @return status boolean true on success, false on failure -- @return string containing error message (if status is false) ChkVersion = function(self) + if not self.checkprogver then return true end if ( self.version > RPC_version[self.program].max or self.version < RPC_version[self.program].min ) then return false, string.format("RPC library does not support: %s version %d", diff --git a/scripts/rpc-grind.nse b/scripts/rpc-grind.nse index 70137041b..3c76029c5 100644 --- a/scripts/rpc-grind.nse +++ b/scripts/rpc-grind.nse @@ -41,7 +41,7 @@ categories = {"version"} portrule = function(host, port) - if port.service ~= nil and port.service ~= 'rpcbind' then + if port.service ~= nil and port.version.service_dtype ~= "table" and port.service ~= 'rpcbind' then -- Exclude services that have already been detected as something -- different than rpcbind. return false @@ -157,9 +157,8 @@ local rpcGrinder = function(host, port, iterator, result) -- We use a random, most likely unsupported version so that -- we also trigger min and max version disclosure for the target service. version = math.random(12345, 123456789) - rpcConn = rpc.Comm:new() + rpcConn = rpc.Comm:new("rpcbind", version) rpcConn:SetCheckProgVer(false) - rpcConn:SetVersion(version) status, err = rpcConn:Connect(host, port) if not status then