Skip to content

Commit b5c4fd0

Browse files
committed
use the same instance
OpenSSL::Digest.new('sha256')
1 parent 5ee8696 commit b5c4fd0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/exploits/linux/http/empire_skywalker.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,11 @@ def aes_encrypt_then_hmac(key, data)
348348

349349
def aes_decrypt(key, data)
350350
mac = data[-10..]
351-
expected = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, data[..-11])[..9]
352-
raise "Invalid ciphertext received." unless OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, mac) == OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, expected)
351+
sha256_digest = OpenSSL::Digest.new('sha256')
352+
expected = OpenSSL::HMAC.digest(sha256_digest, key, data[..-11])[..9]
353+
unless OpenSSL::HMAC.digest(sha256_digest, key, mac) == OpenSSL::HMAC.digest(sha256_digest, key, expected)
354+
raise "Invalid ciphertext received."
355+
end
353356

354357
size = key.length * 8
355358
raise ArgumentError.new('AES key width must be 128 or 256 bits') unless (size == 128 || size == 256)

0 commit comments

Comments
 (0)