@@ -83,67 +83,30 @@ def run_host(ip)
83
83
)
84
84
85
85
scanner . scan! do |result |
86
+ credential_data = result . to_h
87
+ credential_data . merge! (
88
+ module_fullname : self . fullname ,
89
+ workspace_id : myworkspace_id
90
+ )
86
91
case result . status
87
92
when Metasploit ::Model ::Login ::Status ::SUCCESSFUL
88
93
print_brute :level => :good , :ip => ip , :msg => "Success: '#{ result . credential } '"
89
- do_report ( ip , rport , result )
94
+ credential_core = create_credential ( credential_data )
95
+ credential_data [ :core ] = credential_core
96
+ create_credential_login ( credential_data )
90
97
:next_user
91
98
when Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
92
99
print_brute :level => :verror , :ip => ip , :msg => "Could not connect"
93
- invalidate_login (
94
- address : ip ,
95
- port : rport ,
96
- protocol : 'tcp' ,
97
- public : result . credential . public ,
98
- private : result . credential . private ,
99
- realm_key : result . credential . realm_key ,
100
- realm_value : result . credential . realm ,
101
- status : result . status
102
- )
100
+ invalidate_login ( credential_data )
103
101
:abort
104
102
when Metasploit ::Model ::Login ::Status ::INCORRECT
105
103
print_brute :level => :verror , :ip => ip , :msg => "Failed: '#{ result . credential } '"
106
- invalidate_login (
107
- address : ip ,
108
- port : rport ,
109
- protocol : 'tcp' ,
110
- public : result . credential . public ,
111
- private : result . credential . private ,
112
- realm_key : result . credential . realm_key ,
113
- realm_value : result . credential . realm ,
114
- status : result . status
115
- )
104
+ invalidate_login ( credential_data )
116
105
end
117
106
end
118
107
119
108
end
120
109
121
- def do_report ( ip , port , result )
122
- service_data = {
123
- address : ip ,
124
- port : port ,
125
- service_name : 'http' ,
126
- protocol : 'tcp' ,
127
- workspace_id : myworkspace_id
128
- }
129
-
130
- credential_data = {
131
- module_fullname : self . fullname ,
132
- origin_type : :service ,
133
- private_data : result . credential . private ,
134
- private_type : :password ,
135
- username : result . credential . public ,
136
- } . merge ( service_data )
137
-
138
- credential_core = create_credential ( credential_data )
139
-
140
- login_data = {
141
- core : credential_core ,
142
- last_attempted_at : DateTime . now ,
143
- status : result . status
144
- } . merge ( service_data )
145
-
146
- create_credential_login ( login_data )
147
- end
110
+
148
111
149
112
end
0 commit comments