Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msfenv.rb
Views: 11704
# Use bundler to load dependencies1#23# Enable legacy providers such as blowfish-cbc, cast128-cbc, arcfour, etc4$stderr.puts "Overriding user environment variable 'OPENSSL_CONF' to enable legacy functions." unless ENV['OPENSSL_CONF'].nil?5ENV['OPENSSL_CONF'] = File.expand_path(6File.join(File.dirname(__FILE__), '..', 'config', 'openssl.conf')7)89if ENV['KRB5CCNAME']10$stderr.puts 'Warning: KRB5CCNAME environment variable not supported - unsetting'11ENV['KRB5CCNAME'] = nil12end1314# Override the normal rails default, so that msfconsole will come up in production mode instead of development mode15# unless the `--environment` flag is passed.16ENV['RAILS_ENV'] ||= 'production'1718require 'pathname'19root = Pathname.new(__FILE__).expand_path.parent.parent20config = root.join('config')21require config.join('boot')2223# Requiring environment will define the Metasploit::Framework::Application as the one and only Rails::Application in24# this process and cause an error if a Rails.application is already defined, such as when loading msfenv through25# msfconsole in Metasploit Pro.26unless defined?(Rails) && !Rails.application.nil?27require config.join('environment')28end29require 'msf_autoload'3031# Disable the enhanced error messages introduced as part of Ruby 3.1, as some error messages are directly shown to users,32# and the default ErrorHighlight formatter displays unneeded Ruby code to the user33# https://github.com/ruby/error_highlight/tree/f3626b9032bd1024d058984329accb757687cee4#custom-formatter34if defined?(::ErrorHighlight)35noop_error_formatter = Object.new36def noop_error_formatter.message_for(_spot)37''38end39::ErrorHighlight.formatter = noop_error_formatter40end4142MsfAutoload.instance4344def _warn_deprecation_message(method)45stack_size = 346warning_message = "[DEPRECATION] The global method #{method.inspect} is deprecated, please raise a Github issue with this output. Called from: #{caller(1, stack_size).to_a}"47warn(warning_message)48# Additionally write to ~/.msf4/logs/framework.log - as this gets attached to Github issues etc49elog(warning_message)50end5152# @deprecated In most scenarios you should delegate to either a framework module object, or Rex::Ui::Text::DispatcherShell etc53def print_line(msg)54_warn_deprecation_message __method__55$stdout.puts(msg)56end5758# @deprecated In most scenarios you should delegate to either a framework module object, or Rex::Ui::Text::DispatcherShell etc59def print_warning(msg)60_warn_deprecation_message __method__61$stderr.puts(msg)62end6364# @deprecated In most scenarios you should delegate to either a framework module object, or Rex::Ui::Text::DispatcherShell etc65def print_good(msg)66_warn_deprecation_message __method__67$stdout.puts(msg)68end6970# @deprecated In most scenarios you should delegate to either a framework module object, or Rex::Ui::Text::DispatcherShell etc71def print_error(msg, exception = nil)72_warn_deprecation_message __method__7374unless exception.nil?75msg += "\n Call Stack:"76exception.backtrace.each {|line|77msg += "\n"78msg += "\t #{line}"79}80end8182$stderr.puts(msg)83end848586