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_author.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 each module by its author(s) and9# the number of modules per author10#1112msfbase = __FILE__13while File.symlink?(msfbase)14msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))15end1617$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))1819require 'msfenv'20require 'rex'21require 'json'2223FILENAME = 'db/modules_metadata_base.json'2425sort = 026filter = 'All'27filters = ['all','exploit','payload','post','nop','encoder','auxiliary', 'evasion']28reg = 029regex = nil3031opts = Rex::Parser::Arguments.new(32"-h" => [ false, "Help menu." ],33"-s" => [ false, "Sort by Author instead of Module Type."],34"-r" => [ false, "Reverse Sort"],35"-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],36"-x" => [ true, "String or RegEx to try and match against the Author Field"]37)3839opts.parse(ARGV) { |opt, idx, val|40case opt41when "-h"42puts "\nMetasploit Script for Displaying Module Author information."43puts "=========================================================="44puts opts.usage45exit46when "-s"47puts "Sorting by Author"48sort = 149when "-r"50puts "Reverse Sorting"51sort = 252when "-f"53unless filters.include?(val.downcase)54puts "Invalid Filter Supplied: #{val}"55puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}"56exit57end58puts "Module Filter: #{val}"59filter = val60when "-x"61puts "Regex: #{val}"62regex = Regexp.new(val)63end6465}666768Indent = ' '6970tbl = Rex::Text::Table.new(71'Header' => 'Module References',72'Indent' => Indent.length,73'Columns' => [ 'Module', 'Reference' ]74)7576names = {}7778local_modules = JSON.parse(File.read(FILENAME)) # get cache file location from framework?7980local_modules.each do |_module_key, local_module|81local_module['author'].each do |r|82next if filter.downcase != 'all' && local_module['type'] != filter.downcase83if regex.nil? or r =~ regex84tbl << [ local_module['fullname'], r ]85names[r] ||= 086names[r] += 187end88end89end9091if sort == 192tbl.sort_rows(1)93end949596if sort == 297tbl.sort_rows(1)98tbl.rows.reverse99end100101puts tbl.to_s102103tbl = Rex::Text::Table.new(104'Header' => 'Module Count by Author',105'Indent' => Indent.length,106'Columns' => [ 'Count', 'Name' ]107)108names.keys.sort {|a,b| names[b] <=> names[a] }.each do |name|109tbl << [ names[name].to_s, name ]110end111112puts113puts tbl.to_s114115116