rapid7/metasploit-framework — pull request #2060 by ringt (2013-07-03 14:39:14+00:00)
Title: lib/rex/proto/smb/client.rb find_next throws exception

While testing my smb_enumshares_rw.rb module, kept getting an exception and traced it back to the smb client library.

Line 1918 references last_name and will throw an exception when last_name is nil (from what I can tell, the first time through find_next).

Stack trace (from debugging):
[-] Error: '192.168.9.3' 'TypeError' 'can't convert nil into String' '["/opt/framework/lib/rex/proto/smb/client.rb:1919:in `+'", "/opt/framework/lib/rex/proto/smb/client.rb:1919:in `find_next'", "/opt/framework/lib/rex/proto/smb/client.rb:1899:in `find_first'", "/opt/framework/modules/auxiliary/scanner/smb/smb_enumshares_rw.rb:117:in `eval_host'"

Changing	].pack('vvvVv') + last_filename + "\x00" # Last filename returned from find_first or find_next
to:	].pack('vvvVv') + "#{last_filename}" + "\x00" # Last filename returned from find_first or find_next

Stops the exception from happening and allows the assessment to continue.

Note the exception being thrown did not stop execution of the module, so its mostly cosmetic in not having to see the caught exception in the module.