Nmap Development mailing list archives
[NSE] rpcinfo - handling of an initial receive_bytes() causes not very graceful exit
From: jah <jah () zadkiel plus com>
Date: Thu, 06 Aug 2009 11:56:24 +0100
Hi folks,
If rpcinfo.nse sends its rpc dump packet to a portmapper which then FIN
ACKs the connection then the initial receive_bytes(), which is wrapped
in a try(), will result in an error being thrown:
NSE: rpcinfo against X.X.194.130:111 threw an error!
EOF
stack traceback:
[C]: in function 'try'
C:\Program Files\Nmap\scripts\rpcinfo.nse:55: in function
<C:\Program Files\Nmap\scripts\rpcinfo.nse:41>
(tail call): ?
Similarly, for any other error, e.g. TIMEOUT. This is OK, but do we
really need the traceback? I suggest a more graceful exit of the script:
NSE: rpcinfo failed to receive a response from X.X.194.130:111 with
error: EOF
and have attached a patch.
Regards,
jah
--- rpcinfo.nse.orig 2009-08-06 11:48:54.531250000 +0100
+++ rpcinfo.nse 2009-08-06 11:51:29.328125000 +0100
@@ -52,7 +52,15 @@
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 = ''
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [NSE] rpcinfo - handling of an initial receive_bytes() causes not very graceful exit jah (Aug 06)
- Re: [NSE] rpcinfo - handling of an initial receive_bytes() causes not very graceful exit David Fifield (Aug 07)
