From 929a29d310efea90666feff62c20eb629caa5226 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 3 Jun 2024 19:00:29 +0000 Subject: [PATCH] Fix a crash in rpc-grind when scanning a non-RPC service --- scripts/rpc-grind.nse | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/rpc-grind.nse b/scripts/rpc-grind.nse index a89067b53..ce9996856 100644 --- a/scripts/rpc-grind.nse +++ b/scripts/rpc-grind.nse @@ -103,12 +103,14 @@ local isRPC = function(host, port) -- If we got response, set port to open nmap.set_port_state(host, port, "open") - rxid, msgtype = string.unpack(">I4 I4", data) - -- If response XID does match request XID - -- and message type equals 1 (REPLY) then - -- it is a RPC port. - if rxid == xid and msgtype == 1 then - return true + if #data >= 8 then + rxid, msgtype = string.unpack(">I4 I4", data) + -- If response XID does match request XID + -- and message type equals 1 (REPLY) then + -- it is a RPC port. + if rxid == xid and msgtype == 1 then + return true + end end end end