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_targets.rb
Views: 11768
#!/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 all modules with their targets9#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'2223sort=024fil = 025filter = ""2627opts = Rex::Parser::Arguments.new(28"-h" => [ false, "Help menu." ],29"-s" => [ false, "Sort by Target instead of Module Type."],30"-r" => [ false, "Reverse Sort"],31"-x" => [ true, "String or RegEx to try and match against the Targets field"]32)3334opts.parse(ARGV) { |opt, idx, val|35case opt36when "-h"37puts "\nMetasploit Script for Displaying Module Target information."38puts "=========================================================="39puts opts.usage40exit41when "-s"42puts "Sorting by Target"43sort = 144when "-r"45puts "Reverse Sorting"46sort = 247when "-x"48puts "Filter: #{val}"49filter = val50fil=151end52}5354Indent = ' '5556# Initialize the simplified framework instance.57$framework = Msf::Simple::Framework.create('DisableDatabase' => true)5859tbl = Rex::Text::Table.new(60'Header' => 'Module Targets',61'Indent' => Indent.length,62'Columns' => [ 'Module name','Target' ]63)6465all_modules = $framework.exploits6667all_modules.each_module { |name, mod|68x = mod.new69x.targets.each do |targ|70if fil==0 or targ.name=~/#{filter}/71tbl << [ x.fullname, targ.name ]72end73end74}7576if sort == 177tbl.sort_rows(1)78end798081if sort == 282tbl.sort_rows(1)83tbl.rows.reverse84end8586puts tbl.to_s878889