msfconsole 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env ruby
  2. # -*- coding: binary -*-
  3. #
  4. # This user interface provides users with a command console interface to the
  5. # framework.
  6. #
  7. #
  8. # Standard Library
  9. #
  10. require 'pathname'
  11. if ENV['METASPLOIT_FRAMEWORK_PROFILE'] == 'true'
  12. gem 'perftools.rb'
  13. require 'perftools'
  14. formatted_time = Time.now.strftime('%Y%m%d%H%M%S')
  15. root = Pathname.new(__FILE__).parent
  16. profile_pathname = root.join('tmp', 'profiles', 'msfconsole', formatted_time)
  17. profile_pathname.parent.mkpath
  18. PerfTools::CpuProfiler.start(profile_pathname.to_path)
  19. at_exit {
  20. PerfTools::CpuProfiler.stop
  21. puts "Generating pdf"
  22. pdf_path = "#{profile_pathname}.pdf"
  23. if Bundler.clean_system("pprof.rb --pdf #{profile_pathname} > #{pdf_path}")
  24. puts "PDF saved to #{pdf_path}"
  25. Rex::Compat.open_file(pdf_path)
  26. end
  27. }
  28. end
  29. #
  30. # Project
  31. #
  32. # @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/generators/rails/app/templates/script/rails#L3-L5
  33. require Pathname.new(__FILE__).realpath.expand_path.parent.join('config', 'boot')
  34. require 'metasploit/framework/command/console'
  35. Metasploit::Framework::Command::Console.start