From 8341de219a63e27ab83973dc0a0513a50bd5974b Mon Sep 17 00:00:00 2001 From: jah Date: Sat, 8 Aug 2009 01:51:32 +0000 Subject: [PATCH] Exit the script cleanly rather than throwing an error when attempting to receive_bytes() from a portmapper service which fails to respond with data. --- scripts/rpcinfo.nse | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/rpcinfo.nse b/scripts/rpcinfo.nse index 0aebb8abe..75c88e0ea 100644 --- a/scripts/rpcinfo.nse +++ b/scripts/rpcinfo.nse @@ -52,7 +52,15 @@ action = function(host, port) local request = bin.pack('>IIIIIIILL',0x80000028,transaction_id,0,2,100000,2,4,0,0) try(socket:send(request)) - local answer = try(socket:receive_bytes(1)) + local status, answer = socket:receive_bytes(1) + if not status then + stdnse.print_debug(1, "%s failed to receive a response from %s:%d with error: %s", + filename:match( "[\\/]([^\\/]+)\.nse$" ) or filename, + host.ip, port.number, + answer or "unknown") + socket:close() + return nil + end local _,offset,header,length,tx_id,msg_type,reply_state,accept_state,value,payload,last_fragment last_fragment = false; offset = 1; payload = ''