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

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

44 lines
1.3 KiB
Ruby
Raw Normal View History

#!/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
##
#
# This script updates the CachedSize constants in payload modules
#
msfbase = __FILE__
while File.symlink?(msfbase)
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')))
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
2016-07-05 02:33:45 -05:00
gem 'rex-text'
require 'rex'
# Initialize the simplified framework instance.
framework = Msf::Simple::Framework.create('DisableDatabase' => true)
exceptions = []
framework.payloads.each_module do |name, mod|
begin
next if name =~ /generic/
mod_inst = framework.payloads.create(name)
#mod_inst.datastore.merge!(framework.datastore)
2022-11-04 00:33:03 +00:00
next if mod_inst.is_a?(Msf::Payload::Adapter) || Msf::Util::PayloadCachedSize.is_cached_size_accurate?(mod_inst)
$stdout.puts "[*] Updating the CacheSize for #{mod.file_path}..."
Msf::Util::PayloadCachedSize.update_module_cached_size(mod_inst)
rescue => e
2022-11-04 00:33:03 +00:00
$stderr.puts "[!] Caught Error while updating #{name}:\n#{e}\n#{e.backtrace.map { |line| "\t#{line}" }.join("\n")}"
exceptions << [ e, name ]
end
end
exit(1) unless exceptions.empty?