You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use Metasploit with Ruby 3.2 or later (when File.exists? was removed, spoiler alert, that's the issue)
Find a module with an OptPath datastore option
Type in a path that is partially complete, e.g. /path/to/some for a file named /path/to/something
Hit the tab key twice to get tab complete
See a stack trace that resembles the following
/home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:8490:in `append_to_match': undefined method `exists?' for File:Class (NoMethodError)
Did you mean? exist?
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:6864:in `rl_complete_internal'
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:6903:in `rl_complete'
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4374:in `_rl_dispatch_subseq'
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4363:in `_rl_dispatch'
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4779:in `readline_internal_charloop'
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4853:in `readline_internal'
from /home/smcintyre/.rvm/gems/ruby-3.2.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:4875:in `readline'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/input/readline.rb:161:in `readline_with_output'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/input/readline.rb:99:in `pgets'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/shell.rb:341:in `get_input_line'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/shell.rb:142:in `block in run'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/shell.rb:309:in `block in with_history_manager_context'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/shell/history_manager.rb:33:in `with_context'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/shell.rb:306:in `with_history_manager_context'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/rex/ui/text/shell.rb:133:in `run'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/metasploit/framework/command/console.rb:54:in `start'
from /home/smcintyre/Repositories/metasploit-framework.pr/lib/metasploit/framework/command/base.rb:82:in `start'
from ./msfconsole:23:in `<main>'
Bump the rb-readline gem to the latest version to pull in the changes
I've opened this ticket for visibility. I others start to run into this, we may want to consider a resolution that does not depend on the upstream project.
The text was updated successfully, but these errors were encountered:
I'm not against having a polyfill for File.exists?; it would allow also allow older modules that use File.exists? to continue to work with newer framework releases/ruby runtimes
I've previously updated framework plus our other gems to no longer use File.exists? - but looks like I missed rb-readline. From a quick grep of the current gemset:
➜ ruby-3.0.5@metasploit-framework rg 'File.exists\?'
gems/systemu-2.6.5/Rakefile
102: extensions << ext if File.exists?(ext)
gems/pcaprub-0.13.2/USAGE.rdoc
42: if(not File.exists?(pcapfile))
gems/Ascii85-1.1.0/bin/ascii85
59: unless File.exists?(@options[:file])
gems/eventmachine-1.2.7/docs/old/ChangeLog
176:30Sep08: Added File.exists? checks in the args for start_tls, as suggested by
gems/http_parser.rb-0.8.0/tasks/compile.rake
37: at_exit{ FileUtils.rm t.name if File.exists?(t.name) }
gems/rubocop-1.63.2/lib/rubocop/cop/lint/deprecated_class_methods.rb
11: # File.exists?(some_path)
gems/macaddr-1.7.2/Rakefile
102: extensions << ext if File.exists?(ext)
gems/builder-3.2.4/rakelib/tags.rake
17: SYSTEM_DIRS = RVM_GEMDIR && File.exists?(RVM_GEMDIR) ? RVM_GEMDIR : []
gems/rb-readline-0.5.5/lib/rbreadline.rb
6568: return nil if !File.exists?(filename)
8489: return temp_string_index unless File.exists? filename
It looks like we'll need to only update rb-readline, and maybe http_parser.rb? It looks like there was a commit for it - but it was never released as a version bump to Ruby gems: tmm1/http_parser.rb@f2b7e1a
Steps to reproduce
Tested with Metasploit v6.4.7 with Ruby 3.2.3
File.exists?
was removed, spoiler alert, that's the issue)OptPath
datastore option/path/to/some
for a file named/path/to/something
Proposed solution
I've opened this ticket for visibility. I others start to run into this, we may want to consider a resolution that does not depend on the upstream project.
The text was updated successfully, but these errors were encountered: