Skip to content

Commit 78c5808

Browse files
author
Brent Cook
committed
Land rapid7#5314, set snmp defaults for constrained values
2 parents 60e2517 + 5b2627c commit 78c5808

File tree

2 files changed

+7
-4
lines changed
  • lib/metasploit/framework/login_scanner
  • spec/lib/metasploit/framework/login_scanner

2 files changed

+7
-4
lines changed

lib/metasploit/framework/login_scanner/snmp.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ module LoginScanner
1111
class SNMP
1212
include Metasploit::Framework::LoginScanner::Base
1313

14+
DEFAULT_TIMEOUT = 2
1415
DEFAULT_PORT = 161
16+
DEFAULT_RETRIES = 0
17+
DEFAULT_VERSION = 'all'
1518
LIKELY_PORTS = [ 161, 162 ]
1619
LIKELY_SERVICE_NAMES = [ 'snmp' ]
1720
PRIVATE_TYPES = [ :password ]
@@ -112,11 +115,13 @@ def has_write_access?(snmp_client, value)
112115

113116
end
114117

115-
# Sets the connection timeout approrpiately for SNMP
118+
# Sets the connection timeout appropriately for SNMP
116119
# if the user did not set it.
117120
def set_sane_defaults
118-
self.connection_timeout = 2 if self.connection_timeout.nil?
121+
self.connection_timeout = DEFAULT_TIMEOUT if self.connection_timeout.nil?
119122
self.port = DEFAULT_PORT if self.port.nil?
123+
self.retries = DEFAULT_RETRIES if self.retries.nil?
124+
self.version = DEFAULT_VERSION if self.version.nil?
120125
end
121126

122127
# This method takes an snmp client and tests whether

spec/lib/metasploit/framework/login_scanner/snmp_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
snmp_scanner.host = '127.0.0.1'
3838
snmp_scanner.port = 161
3939
snmp_scanner.connection_timeout = 1
40-
snmp_scanner.retries = 0
41-
snmp_scanner.version = 'all'
4240
snmp_scanner.stop_on_success = true
4341
snmp_scanner.cred_details = detail_group
4442
end

0 commit comments

Comments
 (0)