v0.18 Hopeful MD5 resolution
This commit is contained in:
parent
1082a61c14
commit
f0163ce5d2
47
plugin.rb
47
plugin.rb
@ -4,7 +4,7 @@
|
||||
|
||||
# name: discourse-md5_authentication
|
||||
# about: A plugin to authenticate users with MD5 passwords from legacy systems
|
||||
# version: 0.17
|
||||
# version: 0.18
|
||||
# authors: saint@federated.computer
|
||||
# url: https://gitea.federated.computer/saint/discourse-md5_authentication.git
|
||||
|
||||
@ -138,7 +138,7 @@ after_initialize do
|
||||
length.times do
|
||||
result << ITOA64[value & 0x3f]
|
||||
value >>= 6
|
||||
Rails.logger.warn "to64 result: #{result}"
|
||||
Rails.logger.warn "MD5 -- to64 result: #{result}"
|
||||
end
|
||||
result
|
||||
end
|
||||
@ -152,7 +152,7 @@ after_initialize do
|
||||
salt = salt[0, 8]
|
||||
|
||||
magic = "$GT$"
|
||||
Rails.logger.warn "MD5 magic: #{magic}"
|
||||
Rails.logger.warn "MD5 -- MD5 magic: #{magic}"
|
||||
|
||||
ctx = Digest::MD5.new
|
||||
ctx.update(password)
|
||||
@ -184,24 +184,47 @@ after_initialize do
|
||||
end
|
||||
|
||||
final_digest = ctx.digest
|
||||
Rails.logger.warn "MD6 final_digest: #{final_digest}"
|
||||
Rails.logger.debug "MD5 -- MD5 final_digest: #{final_digest}"
|
||||
|
||||
1000.times do |i|
|
||||
ctx1 = Digest::MD5.new
|
||||
if i & 1 != 0
|
||||
Rails.logger.warn "MD5 -- AAA"
|
||||
ctx1.update(password)
|
||||
else
|
||||
Rails.logger.warn "MD5 -- BBB"
|
||||
ctx1.update(final_digest)
|
||||
end
|
||||
ctx1.update(salt) if i % 3 != 0
|
||||
ctx1.update(password) if i % 7 != 0
|
||||
if i & 1 != 0
|
||||
Rails.logger.warn "MD5 -- CCC"
|
||||
ctx1.update(final_digest)
|
||||
else
|
||||
Rails.logger.warn "MD5 -- DDD"
|
||||
ctx1.update(password)
|
||||
end
|
||||
final_digest = ctx1.digest
|
||||
end
|
||||
|
||||
Rails.logger.warn "MD5 -- MD5++ final_digest: #{final_digest}"
|
||||
|
||||
result = String.new
|
||||
Rails.logger.warn "A result: #{result}"
|
||||
Rails.logger.warn "MD5 -- A result: #{result}"
|
||||
result << to64((final_digest[0].ord << 16) | (final_digest[6].ord << 8) | final_digest[12].ord, 4)
|
||||
Rails.logger.warn "B result: #{result}"
|
||||
Rails.logger.warn "MD5 -- B result: #{result}"
|
||||
result << to64((final_digest[1].ord << 16) | (final_digest[7].ord << 8) | final_digest[13].ord, 4)
|
||||
Rails.logger.warn "C result: #{result}"
|
||||
Rails.logger.warn "MD5 -- C result: #{result}"
|
||||
result << to64((final_digest[2].ord << 16) | (final_digest[8].ord << 8) | final_digest[14].ord, 4)
|
||||
Rails.logger.warn "D result: #{result}"
|
||||
Rails.logger.warn "MD5 -- D result: #{result}"
|
||||
result << to64((final_digest[3].ord << 16) | (final_digest[9].ord << 8) | final_digest[15].ord, 4)
|
||||
Rails.logger.warn "E result: #{result}"
|
||||
Rails.logger.warn "MD5 -- E result: #{result}"
|
||||
result << to64((final_digest[4].ord << 16) | (final_digest[10].ord << 8) | final_digest[5].ord, 4)
|
||||
Rails.logger.warn "F result: #{result}"
|
||||
Rails.logger.warn "MD5 -- F result: #{result}"
|
||||
result << to64(final_digest[11].ord, 2)
|
||||
Rails.logger.warn "G result: #{result}"
|
||||
Rails.logger.warn "MD5 -- G result: #{result}"
|
||||
|
||||
Rails.logger.warn "magic salt result #{magic}#{salt}$#{result}"
|
||||
Rails.logger.warn "MD5 -- Magic Salt Result #{magic}#{salt}$#{result}"
|
||||
"#{magic}#{salt}$#{result}"
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user