module_description.rb 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env ruby
  2. ##
  3. # This module requires Metasploit: https://metasploit.com/download
  4. # Current source: https://github.com/rapid7/metasploit-framework
  5. ##
  6. #
  7. # This script lists each module with its description
  8. #
  9. msfbase = __FILE__
  10. while File.symlink?(msfbase)
  11. msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
  12. end
  13. $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
  14. require 'msfenv'
  15. $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
  16. require 'rex'
  17. sort = 0
  18. filter= 'All'
  19. filters = ['all','exploit','payload','post','nop','encoder','auxiliary']
  20. opts = Rex::Parser::Arguments.new(
  21. "-h" => [ false, "Help menu." ],
  22. "-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],
  23. )
  24. opts.parse(ARGV) { |opt, idx, val|
  25. case opt
  26. when "-h"
  27. puts "\nMetasploit Script for Displaying Module Descriptions."
  28. puts "=========================================================="
  29. puts opts.usage
  30. exit
  31. when "-f"
  32. unless filters.include?(val.downcase)
  33. puts "Invalid Filter Supplied: #{val}"
  34. puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}"
  35. exit
  36. end
  37. puts "Module Filter: #{val}"
  38. filter = val
  39. end
  40. }
  41. Indent = ' '
  42. # Always disable the database (we never need it just to list module
  43. # information).
  44. framework_opts = { 'DisableDatabase' => true }
  45. # If the user only wants a particular module type, no need to load the others
  46. if filter.downcase != 'all'
  47. framework_opts[:module_types] = [ filter.downcase ]
  48. end
  49. # Initialize the simplified framework instance.
  50. $framework = Msf::Simple::Framework.create(framework_opts)
  51. tbl = Rex::Text::Table.new(
  52. 'Header' => 'Module Descriptions',
  53. 'Indent' => Indent.length,
  54. 'Columns' => [ 'Module', 'Description' ]
  55. )
  56. $framework.modules.each { |name, mod|
  57. x = mod.new
  58. tbl << [ x.fullname, x.description ]
  59. }
  60. if sort == 1
  61. tbl.sort_rows(1)
  62. end
  63. puts tbl.to_s