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_disclodate.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 its disclosure date9#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'2223nilc = false24sort = 025filter = 'All'26filters = ['all','exploit','payload','post','nop','encoder','auxiliary']27startdate = Date.new28enddate = Date.new(2525,01,01)29match = nil3031opts = Rex::Parser::Arguments.new(32"-h" => [ false, "Help menu." ],33"-s" => [ false, "Sort by Disclosure Date 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"-n" => [ false, "Filter out modules that have no Disclosure Date listed."],37"-d" => [ true, "Start of Date Range YYYY-MM-DD."],38"-D" => [ true, "End of Date Range YYYY-MM-DD."]39)4041opts.parse(ARGV) { |opt, idx, val|42case opt43when "-h"44puts "\nMetasploit Script for Displaying Module Disclosure Date Information."45puts "=========================================================="46puts opts.usage47exit48when "-s"49puts "Sorting by Disclosure Date"50sort = 151when "-r"52puts "Reverse Sorting"53sort = 254when "-f"55unless filters.include?(val.downcase)56puts "Invalid Filter Supplied: #{val}"57puts "Please use one of these: #{filters.map{|f|f.capitalize}.join(", ")}"58exit59end60puts "Module Filter: #{val}"61filter = val62when "-n"63puts "Excluding Null dates"64nilc=165when "-d"66(year,month,day) = val.split('-')67if Date.valid_civil?(year.to_i,month.to_i,day.to_i)68startdate= Date.new(year.to_i,month.to_i,day.to_i)69puts "Start Date: #{startdate}"70else71puts "Invalid Start Date: #{val}"72exit73end74when "-D"75(year,month,day) = val.split('-')76if Date.valid_civil?(year.to_i,month.to_i,day.to_i)77enddate= Date.new(year.to_i,month.to_i,day.to_i)78puts "End Date: #{enddate}"79else80puts "Invalid Start Date: #{val}"81exit82end83else84if opt85puts "Unknown option"86exit87end88match = Regexp.new(val)89end9091}9293Indent = ' '9495# Always disable the database (we never need it just to list module96# information).97framework_opts = { 'DisableDatabase' => true }9899# If the user only wants a particular module type, no need to load the others100if filter.downcase != 'all'101framework_opts[:module_types] = [ filter.downcase ]102end103104# Initialize the simplified framework instance.105$framework = Msf::Simple::Framework.create(framework_opts)106107108tbl = Rex::Text::Table.new(109'Header' => 'Module References',110'Indent' => Indent.length,111'Columns' => [ 'Module', 'Disclosure Date' ]112)113114$framework.modules.each { |name, mod|115next if match and not name =~ match116x = mod.new117if x.disclosure_date.nil?118if nilc==1119tbl << [ x.fullname, '' ]120end121else122if x.disclosure_date >= startdate and x.disclosure_date <= enddate123tbl << [ x.fullname, x.disclosure_date ]124end125end126}127128129if sort == 1130tbl.sort_rows(1)131end132133134if sort == 2135tbl.sort_rows(1)136tbl.rows.reverse137end138139puts tbl.to_s140141142