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/tools/modules/module_rank.rb
Views: 11766
#!/usr/bin/env ruby12##3# This module requires Metasploit: https://metasploit.com/download4# Current source: https://github.com/rapid7/metasploit-framework5##67#8# This script lists each module with its rank9#1011msfbase = __FILE__12while File.symlink?(msfbase)13msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))14end1516$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))17require 'msfenv'1819$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']2021require 'rex'2223ranks= Hash.new2425ranks['Manual'] = 026ranks['Low'] = 10027ranks['Average'] = 20028ranks['Normal'] = 30029ranks['Good'] = 40030ranks['Great'] = 50031ranks['Excellent'] = 6003233minrank= 034maxrank= 60035sort = 036filter= 'All'37filters = ['all','exploit','payload','post','nop','encoder','auxiliary']3839opts = Rex::Parser::Arguments.new(40"-h" => [ false, "Help menu." ],41"-M" => [ true, "Set Maximum Rank [Manual,Low,Average,Normal,Good,Great,Excellent] (Default = Excellent)." ],42"-m" => [ true, "Set Minimum Rank [Manual,Low,Average,Normal,Good,Great,Excellent] (Default = Manual)."],43"-s" => [ false, "Sort by Rank instead of Module Type."],44"-r" => [ false, "Reverse Sort by Rank"],45"-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],46)4748opts.parse(ARGV) { |opt, idx, val|49case opt50when "-h"51puts "\nMetasploit Script for Displaying Module Rank information."52puts "=========================================================="53puts opts.usage54exit55when "-M"56unless ranks.include?(val)57puts "Invalid Rank Supplied: #{val}"58puts "Please use one of these: [Manual,Low,Average,Normal,Good,Great,Excellent]"59exit60end61puts "Maximum Rank: #{val}"62maxrank = ranks[val]63when "-m"64unless ranks.include?(val)65puts "Invalid Rank Supplied: #{val}"66puts "Please use one of these: [Manual,Low,Average,Normal,Good,Great,Excellent]"67exit68end69puts "Minimum Rank: #{val}"70minrank = ranks[val]71when "-s"72puts "Sorting by Rank"73sort = 174when "-r"75puts "Reverse Sorting by Rank"76sort = 277when "-f"78unless filters.include?(val.downcase)79puts "Invalid Filter Supplied: #{val}"80puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}"81exit82end83puts "Module Filter: #{val}"84filter = val8586end8788}899091Indent = ' '9293# Always disable the database (we never need it just to list module94# information).95framework_opts = { 'DisableDatabase' => true }9697# If the user only wants a particular module type, no need to load the others98if filter.downcase != 'all'99framework_opts[:module_types] = [ filter.downcase ]100end101102# Initialize the simplified framework instance.103$framework = Msf::Simple::Framework.create(framework_opts)104105106tbl = Rex::Text::Table.new(107'Header' => 'Module Ranks',108'Indent' => Indent.length,109'Columns' => [ 'Module', 'Rank' ]110)111112$framework.modules.each { |name, mod|113x = mod.new114modrank = x.rank115if modrank >= minrank and modrank<= maxrank116tbl << [ x.fullname, modrank ]117end118119}120121if sort == 1122tbl.sort_rows(1)123end124125if sort == 2126tbl.sort_rows(1)127tbl.rows.reverse128end129130puts tbl.to_s131132133