问题描述
运行 msfconsole,即报如下警告信息:
➜ recon msfconsole
/usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:84: warning: deprecated Object#=~ is called on Integer; it always returns nil
/usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:84: warning: deprecated Object#=~ is called on Integer; it always returns nil
/usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:84: warning: deprecated Object#=~ is called on Integer; it always returns nil
警告信息会在使用过程中一直出现,扰乱阅读。
解决方法
打开 /opt/metasploit/vendor/bundle/ruby/2.7.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb 文件,找到 84 行,将 if config =~ SIMPLE_INT" 改成 if config.to_i.to_s == config 即可。
测试问题已解决。
EDIT:
修改文件之后发现这一个错误警告解决了,但是还有其他,不能一个一个文件改。
最终解决方案,在 bashrc 中做一个 alias:
alias msfconsole="RUBYOPT='-W:no-deprecated -W:no-experimental' msfconsole"
所有问题解决。
EDIT2:
发现 msfvenom 还是会报警告,所以应该把 RUBYOPT='-W:no-deprecated -W:no-experimental' 放到 bashrc 里面。就不需要做 alias 了。正常使用 msf1 和 msfvenom 即可。