Skip to content

Commit fbbaf69

Browse files
Land rapid7#18949, notify the user the DNS feature requires a restart
2 parents 923f4c9 + 8989b32 commit fbbaf69

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

docs/metasploit-framework.wiki/How-to-Configure-DNS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ control over the process of DNS queries.
1515

1616
## The DNS command
1717
Metasploit's DNS configuration is controlled by the `dns` command which has multiple subcommands. This command is only
18-
available when the `dns_feature` is enabled (`features set dns_feature true`). Once enabled, the current configuration
19-
can be printed by running `dns print`.
18+
available when the `dns` feature is enabled (`features set dns true`). Once enabled, the current configuration can be
19+
printed by running `dns print`.
2020

2121
```
2222
msf6 > dns print

lib/msf/core/feature_manager.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FeatureManager
2020
MANAGER_COMMANDS = 'manager_commands'
2121
METASPLOIT_PAYLOAD_WARNINGS = 'metasploit_payload_warnings'
2222
DEFER_MODULE_LOADS = 'defer_module_loads'
23-
DNS_FEATURE = 'dns_feature'
23+
DNS = 'dns'
2424
HIERARCHICAL_SEARCH_TABLE = 'hierarchical_search_table'
2525
SMB_SESSION_TYPE = 'smb_session_type'
2626
POSTGRESQL_SESSION_TYPE = 'postgresql_session_type'
@@ -91,15 +91,15 @@ class FeatureManager
9191
default_value: false
9292
}.freeze,
9393
{
94-
name: DNS_FEATURE,
95-
description: 'When enabled, allows configuration of DNS resolution behaviour in Metasploit',
96-
requires_restart: false,
94+
name: DNS,
95+
description: 'When enabled allows configuration of DNS resolution behaviour in Metasploit',
96+
requires_restart: true,
9797
default_value: false,
9898
developer_notes: 'Planned for default enablement in: Metasploit 6.4.x'
9999
}.freeze,
100100
{
101101
name: HIERARCHICAL_SEARCH_TABLE,
102-
description: 'When enabled, the search table is enhanced to show details on module actions and targets',
102+
description: 'When enabled the search table is enhanced to show details on module actions and targets',
103103
requires_restart: false,
104104
default_value: false,
105105
developer_notes: 'Planned for default enablement in: Metasploit 6.4.x'

lib/msf/core/framework.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def initialize(options={})
8282
require 'msf/core/cert_provider'
8383
Rex::Socket::Ssl.cert_provider = Msf::Ssl::CertProvider
8484

85-
if options.include?('CustomDnsResolver') && Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::DNS_FEATURE)
85+
if options.include?('CustomDnsResolver') && Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::DNS)
8686
self.dns_resolver = options['CustomDnsResolver']
8787
self.dns_resolver.set_framework(self)
8888
Rex::Socket._install_global_resolver(self.dns_resolver)

lib/msf/ui/console/command_dispatcher/dns.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def name
4848
def commands
4949
commands = {}
5050

51-
if framework.features.enabled?(Msf::FeatureManager::DNS_FEATURE)
51+
if framework.features.enabled?(Msf::FeatureManager::DNS)
5252
commands = {
5353
'dns' => "Manage Metasploit's DNS resolving behaviour"
5454
}
@@ -186,7 +186,10 @@ def cmd_dns_help(*args)
186186
# Manage Metasploit's DNS resolution rules
187187
#
188188
def cmd_dns(*args)
189-
return if driver.framework.dns_resolver.nil?
189+
if driver.framework.dns_resolver.nil?
190+
print_warning("Run the #{Msf::Ui::Tip.highlight("save")} command and restart the console for this feature configuration to take effect.")
191+
return
192+
end
190193

191194
args << 'print' if args.length == 0
192195
# Short-circuit help

lib/msf/ui/console/driver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
7070

7171
begin
7272
FeatureManager.instance.load_config
73-
rescue StandardException => e
73+
rescue StandardError => e
7474
elog(e)
7575
end
7676

@@ -82,7 +82,7 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
8282

8383
framework_create_options = opts.merge({ 'DeferModuleLoads' => true })
8484

85-
if Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::DNS_FEATURE)
85+
if Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::DNS)
8686
dns_resolver = Rex::Proto::DNS::CachedResolver.new
8787
dns_resolver.extend(Rex::Proto::DNS::CustomNameserverProvider)
8888
dns_resolver.load_config if dns_resolver.has_config?

lib/rex/proto/dns/custom_nameserver_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def flush
156156
# @return [Array<Array>] A list of nameservers, each with Rex::Socket options
157157
#
158158
def upstream_resolvers_for_packet(packet)
159-
unless feature_set.enabled?(Msf::FeatureManager::DNS_FEATURE)
159+
unless feature_set.enabled?(Msf::FeatureManager::DNS)
160160
return super
161161
end
162162
# Leaky abstraction: a packet could have multiple question entries,

0 commit comments

Comments
 (0)