Skip to content

Commit 5fba54d

Browse files
committed
Add addtional timing options
1 parent 7f2add2 commit 5fba54d

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

lib/metasploit/framework/login_scanner/snmp.rb

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,35 @@ class SNMP
1717
PRIVATE_TYPES = [ :password ]
1818
REALM_KEY = nil
1919

20+
# @!attribute retries
21+
# @return [Fixnum] The number of retries
22+
attr_accessor :retries
23+
24+
validates :retries,
25+
presence: true,
26+
numericality: {
27+
only_integer: true,
28+
greater_than_or_equal_to: 0
29+
}
30+
31+
# @!attribute version
32+
# @return [String] The SNMP version to scan
33+
attr_accessor :version
34+
35+
validates :version,
36+
presence: true,
37+
inclusion: { in: ['1', '2c', 'all'] }
38+
39+
# This method returns an array of versions to scan
40+
# @return [Array] An array of versions
41+
def versions
42+
case version
43+
when '1'; [:SNMPv1]
44+
when '2c'; [:SNMPv2c]
45+
when 'all'; [:SNMPv1,:SNMPv2c]
46+
end
47+
end
48+
2049
# This method attempts a single login with a single credential against the target
2150
# @param credential [Credential] The credential object to attmpt to login with
2251
# @return [Metasploit::Framework::LoginScanner::Result] The LoginScanner Result object
@@ -29,14 +58,14 @@ def attempt_login(credential)
2958
service_name: 'snmp'
3059
}
3160

32-
[:SNMPv1, :SNMPv2c].each do |version|
61+
versions.each do |version|
3362
snmp_client = ::SNMP::Manager.new(
3463
:Host => host,
3564
:Port => port,
3665
:Community => credential.public,
3766
:Version => version,
3867
:Timeout => connection_timeout,
39-
:Retries => 2,
68+
:Retries => retries,
4069
:Transport => ::SNMP::RexUDPTransport,
4170
:Socket => ::Rex::Socket::Udp.create('Context' => { 'Msf' => framework, 'MsfExploit' => framework_module })
4271
)

modules/auxiliary/scanner/snmp/snmp_login.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def initialize
3030
[
3131
Opt::RPORT(161),
3232
Opt::CHOST,
33+
OptInt.new('CONNECTION_TIMEOUT', [true, 'The timeout value for each probe', 1]),
34+
OptInt.new('RETRIES', [true, 'The number of retries per community string', 0]),
3335
OptInt.new('BATCHSIZE', [true, 'The number of hosts to probe in each set', 256]),
36+
OptEnum.new('VERSION', [true, 'The SNMP version to scan', 'all', ['1','2c','all']]),
3437
OptString.new('PASSWORD', [ false, 'The password to test' ]),
3538
OptPath.new('PASS_FILE', [ false, "File containing communities, one per line",
3639
File.join(Msf::Config.data_directory, "wordlists", "snmp_default_pass.txt")
@@ -61,9 +64,11 @@ def run_batch(batch)
6164
cred_details: collection,
6265
stop_on_success: datastore['STOP_ON_SUCCESS'],
6366
bruteforce_speed: datastore['BRUTEFORCE_SPEED'],
64-
connection_timeout: 2,
67+
connection_timeout: datastore['CONNECTION_TIMEOUT'],
68+
retries: datastore['RETRIES'],
69+
version: datastore['VERSION'],
6570
framework: framework,
66-
framework_module: self,
71+
framework_module: self
6772
)
6873

6974
scanner.scan! do |result|

0 commit comments

Comments
 (0)