Files
metasploit-gs/tools/modules/payload_lengths.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
1.8 KiB
Ruby
Raw Normal View History

2010-08-20 19:39:13 +00:00
#!/usr/bin/env ruby
2018-03-20 11:33:34 +00:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2010-08-20 19:39:13 +00:00
# This script lists each payload module along with its length
# NOTE: No encoding or BadChar handling is performed
#
msfbase = __FILE__
while File.symlink?(msfbase)
2013-09-30 13:47:53 -05:00
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
2015-10-06 10:30:52 -05:00
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
2012-04-15 23:35:38 -05:00
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
2010-08-20 19:39:13 +00:00
require 'rex'
Indent = ' '
# Initialize the simplified framework instance.
$framework = Msf::Simple::Framework.create(
2013-09-30 13:47:53 -05:00
:module_types => [ Msf::MODULE_PAYLOAD ],
'DisableDatabase' => true
2010-08-20 19:39:13 +00:00
)
# Process special var/val pairs...
Msf::Ui::Common.process_cli_arguments($framework, ARGV)
2010-08-20 20:36:06 +00:00
options = ARGV.join(',')
2016-08-10 13:30:09 -05:00
tbl = Rex::Text::Table.new(
2013-09-30 13:47:53 -05:00
'Header' => 'Payload Lengths',
'Indent' => Indent.length,
'Columns' => [ 'Payload', 'Length' ]
2010-08-20 19:39:13 +00:00
)
enc = nil
$framework.payloads.each_module { |payload_name, mod|
2013-09-30 13:47:53 -05:00
len = 'Error: Unknown error!'
begin
# Create the payload instance
payload = mod.new
raise "Invalid payload" if not payload
# Set the variables from the cmd line
payload.datastore.import_options_from_s(options)
# Skip non-specified architectures
if (ds_arch = payload.datastore['ARCH'])
next if not payload.arch?(ds_arch)
end
# Skip non-specified platforms
if (ds_plat = payload.datastore['PLATFORM'])
ds_plat = Msf::Module::PlatformList.transform(ds_plat)
next if not payload.platform.supports?(ds_plat)
end
len = payload.size
if len > 0
len = len.to_s
else
len = "Error: Empty payload"
end
rescue
len = "Error: #{$!}"
end
tbl << [ payload_name, len ]
2010-08-20 19:39:13 +00:00
}
puts tbl.to_s