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_mixins.rb
Views: 11619
#!/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 mixins. Handy for finding different "kinds" of modules.9#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'2223def do_want(klass)24return false if klass.class != Module25return false if [ Kernel, ERB::Util, SNMP::BER].include?(klass)26return false if klass.to_s.match(/^Rex::Ui::Subscriber/)2728return true29end3031# Initialize the simplified framework instance.32$framework = Msf::Simple::Framework.create('DisableDatabase' => true)3334all_modules = $framework.exploits3536# If you give an argument (any argument will do), you really want a sorted37# list of mixins, regardless of the module they're in.38if ARGV[0]39mod_hash = {}40longest_name = 041all_modules.each_module do |name, mod|42x = mod.new43mixins = x.class.ancestors.select {|y| do_want(y) }44mixins.each do |m|45mod_hash[m] ||= 046mod_hash[m] += 147longest_name = m.to_s.size unless m.to_s.size < longest_name48end49end50mod_hash.sort_by {|a| a[1]}.reverse.each do |arr|51puts "%-#{longest_name}s | %d" % arr52end53else54# Tables kind of suck for this.55results = []56longest_name = 057all_modules.each_module do |name, mod|58x = mod.new59mixins = x.class.ancestors.select {|y| do_want(y) }60results << [x.fullname, mixins.sort {|a,b| a.to_s <=> b.to_s}.join(", ")]61longest_name = x.fullname.size if longest_name < x.fullname.size62end63# name | module1, module1, etc.64results.each do |r|65puts "%-#{longest_name}s | %s" % r66end67end686970