@@ -32,7 +32,6 @@ def initialize
32
32
Opt ::CHOST ,
33
33
OptInt . new ( 'CONNECTION_TIMEOUT' , [ true , 'The timeout value for each probe' , 2 ] ) ,
34
34
OptInt . new ( 'RETRIES' , [ true , 'The number of retries per community string' , 0 ] ) ,
35
- OptInt . new ( 'BATCHSIZE' , [ true , 'The number of hosts to probe in each set' , 256 ] ) ,
36
35
OptEnum . new ( 'VERSION' , [ true , 'The SNMP version to scan' , 'all' , [ '1' , '2c' , 'all' ] ] ) ,
37
36
OptString . new ( 'PASSWORD' , [ false , 'The password to test' ] ) ,
38
37
OptPath . new ( 'PASS_FILE' , [ false , "File containing communities, one per line" ,
@@ -43,50 +42,42 @@ def initialize
43
42
deregister_options ( 'USERNAME' , 'USER_FILE' , 'USERPASS_FILE' )
44
43
end
45
44
45
+ # Operate on a single host so that we can take advantage of multithreading
46
+ def run_host ( ip )
46
47
47
- # Define our batch size
48
- def run_batch_size
49
- datastore [ 'BATCHSIZE' ] . to_i
50
- end
51
-
52
- # Operate on an entire batch of hosts at once
53
- def run_batch ( batch )
48
+ collection = Metasploit ::Framework ::CommunityStringCollection . new (
49
+ pass_file : datastore [ 'PASS_FILE' ] ,
50
+ password : datastore [ 'PASSWORD' ]
51
+ )
54
52
55
- batch . each do |ip |
56
- collection = Metasploit ::Framework ::CommunityStringCollection . new (
57
- pass_file : datastore [ 'PASS_FILE' ] ,
58
- password : datastore [ 'PASSWORD' ]
59
- )
53
+ scanner = Metasploit ::Framework ::LoginScanner ::SNMP . new (
54
+ host : ip ,
55
+ port : rport ,
56
+ cred_details : collection ,
57
+ stop_on_success : datastore [ 'STOP_ON_SUCCESS' ] ,
58
+ bruteforce_speed : datastore [ 'BRUTEFORCE_SPEED' ] ,
59
+ connection_timeout : datastore [ 'CONNECTION_TIMEOUT' ] ,
60
+ retries : datastore [ 'RETRIES' ] ,
61
+ version : datastore [ 'VERSION' ] ,
62
+ framework : framework ,
63
+ framework_module : self
64
+ )
60
65
61
- scanner = Metasploit ::Framework ::LoginScanner ::SNMP . new (
62
- host : ip ,
63
- port : rport ,
64
- cred_details : collection ,
65
- stop_on_success : datastore [ 'STOP_ON_SUCCESS' ] ,
66
- bruteforce_speed : datastore [ 'BRUTEFORCE_SPEED' ] ,
67
- connection_timeout : datastore [ 'CONNECTION_TIMEOUT' ] ,
68
- retries : datastore [ 'RETRIES' ] ,
69
- version : datastore [ 'VERSION' ] ,
70
- framework : framework ,
71
- framework_module : self
66
+ scanner . scan! do |result |
67
+ credential_data = result . to_h
68
+ credential_data . merge! (
69
+ module_fullname : self . fullname ,
70
+ workspace_id : myworkspace_id
72
71
)
73
-
74
- scanner . scan! do |result |
75
- credential_data = result . to_h
76
- credential_data . merge! (
77
- module_fullname : self . fullname ,
78
- workspace_id : myworkspace_id
79
- )
80
- if result . success?
81
- credential_core = create_credential ( credential_data )
82
- credential_data [ :core ] = credential_core
83
- create_credential_login ( credential_data )
84
-
85
- print_good "#{ ip } :#{ rport } - LOGIN SUCCESSFUL: #{ result . credential } (Access level: #{ result . access_level } )"
86
- else
87
- invalidate_login ( credential_data )
88
- print_error "#{ ip } :#{ rport } - LOGIN FAILED: #{ result . credential } (#{ result . status } )"
89
- end
72
+ if result . success?
73
+ credential_core = create_credential ( credential_data )
74
+ credential_data [ :core ] = credential_core
75
+ create_credential_login ( credential_data )
76
+
77
+ print_good "#{ ip } :#{ rport } - LOGIN SUCCESSFUL: #{ result . credential } (Access level: #{ result . access_level } ); Proof (sysDescr.0): #{ result . proof } "
78
+ else
79
+ invalidate_login ( credential_data )
80
+ print_error "#{ ip } :#{ rport } - LOGIN FAILED: #{ result . credential } (#{ result . status } )"
90
81
end
91
82
end
92
83
end
0 commit comments