@@ -32,33 +32,32 @@ def initialize(info={})
32
32
end
33
33
34
34
35
- # Initializes CredentialCollection and SymantecWebGateway
36
- def init ( ip )
37
- @cred_collection = Metasploit ::Framework ::CredentialCollection . new (
38
- blank_passwords : datastore [ 'BLANK_PASSWORDS' ] ,
39
- pass_file : datastore [ 'PASS_FILE' ] ,
40
- password : datastore [ 'PASSWORD' ] ,
41
- user_file : datastore [ 'USER_FILE' ] ,
42
- userpass_file : datastore [ 'USERPASS_FILE' ] ,
43
- username : datastore [ 'USERNAME' ] ,
44
- user_as_pass : datastore [ 'USER_AS_PASS' ]
45
- )
46
-
47
- @scanner = Metasploit ::Framework ::LoginScanner ::SymantecWebGateway . new (
48
- configure_http_login_scanner (
49
- host : ip ,
50
- port : datastore [ 'RPORT' ] ,
51
- cred_details : @cred_collection ,
52
- stop_on_success : datastore [ 'STOP_ON_SUCCESS' ] ,
53
- bruteforce_speed : datastore [ 'BRUTEFORCE_SPEED' ] ,
54
- connection_timeout : 5
35
+ def scanner ( ip )
36
+ @scanner ||= lambda {
37
+ cred_collection = Metasploit ::Framework ::CredentialCollection . new (
38
+ blank_passwords : datastore [ 'BLANK_PASSWORDS' ] ,
39
+ pass_file : datastore [ 'PASS_FILE' ] ,
40
+ password : datastore [ 'PASSWORD' ] ,
41
+ user_file : datastore [ 'USER_FILE' ] ,
42
+ userpass_file : datastore [ 'USERPASS_FILE' ] ,
43
+ username : datastore [ 'USERNAME' ] ,
44
+ user_as_pass : datastore [ 'USER_AS_PASS' ]
55
45
)
56
- )
57
- end
46
+
47
+ return Metasploit ::Framework ::LoginScanner ::SymantecWebGateway . new (
48
+ configure_http_login_scanner (
49
+ host : ip ,
50
+ port : datastore [ 'RPORT' ] ,
51
+ cred_details : cred_collection ,
52
+ stop_on_success : datastore [ 'STOP_ON_SUCCESS' ] ,
53
+ bruteforce_speed : datastore [ 'BRUTEFORCE_SPEED' ] ,
54
+ connection_timeout : 5
55
+ ) )
56
+ } . call
57
+ end
58
58
59
59
60
- # Reports a good login credential
61
- def do_report ( ip , port , result )
60
+ def report_good_cred ( ip , port , result )
62
61
service_data = {
63
62
address : ip ,
64
63
port : port ,
@@ -86,49 +85,43 @@ def do_report(ip, port, result)
86
85
end
87
86
88
87
88
+ def report_bad_cred ( ip , rport , result )
89
+ invalidate_login (
90
+ address : ip ,
91
+ port : rport ,
92
+ protocol : 'tcp' ,
93
+ public : result . credential . public ,
94
+ private : result . credential . private ,
95
+ realm_key : result . credential . realm_key ,
96
+ realm_value : result . credential . realm ,
97
+ status : result . status ,
98
+ proof : result . proof
99
+ )
100
+ end
101
+
102
+
89
103
# Attempts to login
90
104
def bruteforce ( ip )
91
- @ scanner. scan! do |result |
105
+ scanner ( ip ) . scan! do |result |
92
106
case result . status
93
107
when Metasploit ::Model ::Login ::Status ::SUCCESSFUL
94
- print_brute :level => :good , :ip => ip , :msg => "Success: '#{ result . credential } '"
95
- do_report ( ip , rport , result )
108
+ print_brute ( :level => :good , :ip => ip , :msg => "Success: '#{ result . credential } '" )
109
+ report_good_cred ( ip , rport , result )
96
110
when Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
97
- vprint_brute :level => :verror , :ip => ip , :msg => result . proof
98
- invalidate_login (
99
- address : ip ,
100
- port : rport ,
101
- protocol : 'tcp' ,
102
- public : result . credential . public ,
103
- private : result . credential . private ,
104
- realm_key : result . credential . realm_key ,
105
- realm_value : result . credential . realm ,
106
- status : result . status ,
107
- proof : result . proof
108
- )
111
+ vprint_brute ( :level => :verror , :ip => ip , :msg => result . proof )
112
+ report_bad_cred ( ip , rport , result )
109
113
when Metasploit ::Model ::Login ::Status ::INCORRECT
110
- vprint_brute :level => :verror , :ip => ip , :msg => "Failed: '#{ result . credential } '"
111
- invalidate_login (
112
- address : ip ,
113
- port : rport ,
114
- protocol : 'tcp' ,
115
- public : result . credential . public ,
116
- private : result . credential . private ,
117
- realm_key : result . credential . realm_key ,
118
- realm_value : result . credential . realm ,
119
- status : result . status ,
120
- proof : result . proof
121
- )
114
+ vprint_brute ( :level => :verror , :ip => ip , :msg => "Failed: '#{ result . credential } '" )
115
+ report_bad_cred ( ip , rport , result )
122
116
end
123
117
end
124
118
end
125
119
126
120
127
121
# Start here
128
122
def run_host ( ip )
129
- init ( ip )
130
- unless @scanner . check_setup
131
- print_brute :level => :error , :ip => ip , :msg => 'Target is not Symantec Web Gateway'
123
+ unless scanner ( ip ) . check_setup
124
+ print_brute ( :level => :error , :ip => ip , :msg => 'Target is not Symantec Web Gateway' )
132
125
return
133
126
end
134
127
0 commit comments