Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/msf/core/feature_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FeatureManager
MANAGER_COMMANDS = 'manager_commands'
METASPLOIT_PAYLOAD_WARNINGS = 'metasploit_payload_warnings'
DEFER_MODULE_LOADS = 'defer_module_loads'
SKIP_CHECKSUM_VALIDATION = 'skip_checksum_validation'
DNS = 'dns'
HIERARCHICAL_SEARCH_TABLE = 'hierarchical_search_table'
SMB_SESSION_TYPE = 'smb_session_type'
Expand Down Expand Up @@ -62,6 +63,13 @@ class FeatureManager
default_value: true,
developer_notes: 'Enabled in Metasploit 6.4.x'
}.freeze,
{
name: SKIP_CHECKSUM_VALIDATION,
description: 'When enabled skips module file checksum validation at boot, improving startup time. Use reload_all to refresh modules after changes.',
requires_restart: true,
default_value: false,
developer_notes: 'Useful for developers who want faster boot and can reload_all manually when modules change'
}.freeze,
{
name: SMB_SESSION_TYPE,
description: 'When enabled will allow for the creation/use of smb sessions',
Expand Down
20 changes: 12 additions & 8 deletions lib/msf/ui/console/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
elog(e)
end

# Check if files have been modified and force immediate loading if so
has_modified_metasploit_files = !Msf::Modules::Metadata::Store.valid_checksum?

if has_modified_metasploit_files
current_checksum = Msf::Modules::Metadata::Store.get_current_checksum
Msf::Modules::Metadata::Store.update_cache_checksum(current_checksum)
# Force immediate module loading when files have changed
opts['DeferModuleLoads'] = false
# Check if files have been modified and force immediate loading if so.
# Can be skipped via feature flag for faster dev boots (use reload_all to refresh).
has_modified_metasploit_files = false
unless Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::SKIP_CHECKSUM_VALIDATION)
has_modified_metasploit_files = !Msf::Modules::Metadata::Store.valid_checksum?

if has_modified_metasploit_files
current_checksum = Msf::Modules::Metadata::Store.get_current_checksum
Msf::Modules::Metadata::Store.update_cache_checksum(current_checksum)
# Force immediate module loading when files have changed
opts['DeferModuleLoads'] = false
end
end

if opts['DeferModuleLoads'].nil?
Expand Down
20 changes: 20 additions & 0 deletions spec/lib/msf/ui/console/driver_skip_checksum_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Skip checksum validation feature flag' do
it 'is registered in the FeatureManager' do
expect(Msf::FeatureManager.instance.exists?('skip_checksum_validation')).to be true
end

it 'is disabled by default' do
expect(Msf::FeatureManager.instance.enabled?('skip_checksum_validation')).to be false
end

it 'can be enabled' do
Msf::FeatureManager.instance.set('skip_checksum_validation', true)
expect(Msf::FeatureManager.instance.enabled?('skip_checksum_validation')).to be true
ensure
Msf::FeatureManager.instance.set('skip_checksum_validation', false)
end
end
Loading