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_ports.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 by the default ports it uses9#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'2223# Initialize the simplified framework instance.24$framework = Msf::Simple::Framework.create('DisableDatabase' => true)25# XXX: this is weird, merging module sets together for different module types could lead to unforseen issues26all_modules = $framework.exploits.merge($framework.auxiliary)27all_ports = {}2829all_modules.each_module { |name, mod|30x = mod.new31ports = []3233if x.datastore['RPORT']34ports << x.datastore['RPORT']35end3637if(x.respond_to?('autofilter_ports'))38x.autofilter_ports.each do |rport|39ports << rport40end41end42ports = ports.map{|p| p.to_i}43ports.uniq!44ports.sort{|a,b| a <=> b}.each do |rport|45# Just record the first occurrence.46all_ports[rport] = x.fullname unless all_ports[rport]47end48}4950all_ports.sort.each { |k,v|51puts "%5s # %s" % [k,v]52}535455