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/payload_lengths.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# This script lists each payload module along with its length8# NOTE: No encoding or BadChar handling is performed9#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'2223Indent = ' '2425# Initialize the simplified framework instance.26$framework = Msf::Simple::Framework.create(27:module_types => [ Msf::MODULE_PAYLOAD ],28'DisableDatabase' => true29)3031# Process special var/val pairs...32Msf::Ui::Common.process_cli_arguments($framework, ARGV)3334options = ARGV.join(',')3536tbl = Rex::Text::Table.new(37'Header' => 'Payload Lengths',38'Indent' => Indent.length,39'Columns' => [ 'Payload', 'Length' ]40)4142enc = nil4344$framework.payloads.each_module { |payload_name, mod|4546len = 'Error: Unknown error!'4748begin49# Create the payload instance50payload = mod.new51raise "Invalid payload" if not payload5253# Set the variables from the cmd line54payload.datastore.import_options_from_s(options)5556# Skip non-specified architectures57if (ds_arch = payload.datastore['ARCH'])58next if not payload.arch?(ds_arch)59end6061# Skip non-specified platforms62if (ds_plat = payload.datastore['PLATFORM'])63ds_plat = Msf::Module::PlatformList.transform(ds_plat)64next if not payload.platform.supports?(ds_plat)65end6667len = payload.size68if len > 069len = len.to_s70else71len = "Error: Empty payload"72end73rescue74len = "Error: #{$!}"75end7677tbl << [ payload_name, len ]78}7980puts tbl.to_s818283