Add check_smf_bcrypt for bcrypt(sha1(user+pass))

This commit is contained in:
Travis Burtrum 2016-08-07 22:32:32 -04:00
parent 57c2c06c7a
commit 6bc90f3004

View File

@ -105,15 +105,7 @@ after_initialize do
end
def self.check_all(password, crypted_pass)
AlternativePassword::check_vbulletin(password, crypted_pass) ||
AlternativePassword::check_vbulletin5(password, crypted_pass) ||
AlternativePassword::check_ipb(password, crypted_pass) ||
AlternativePassword::check_smf(password, crypted_pass) ||
AlternativePassword::check_md5(password, crypted_pass) ||
AlternativePassword::check_wordpress(password, crypted_pass) ||
AlternativePassword::check_bcrypt(password, crypted_pass) ||
AlternativePassword::check_sha256(password, crypted_pass) ||
AlternativePassword::check_wbblite(password, crypted_pass)
AlternativePassword::check_smf_bcrypt(password, crypted_pass)
end
def self.check_bcrypt(password, crypted_pass)
@ -150,6 +142,17 @@ after_initialize do
hash == sha1.hexdigest
end
def self.check_smf_bcrypt(password, crypted_pass)
user, hash = crypted_pass.split(':', 2)
sha1 = Digest::SHA1.new
sha1.update user + password
begin
BCrypt::Password.new(hash) == sha1.hexdigest
rescue
false
end
end
def self.check_ipb(password, crypted_pass)
salt, hash = crypted_pass.split(':', 2)
!salt.nil? && hash == Digest::MD5.hexdigest(Digest::MD5.hexdigest(salt) + Digest::MD5.hexdigest(password))