1313# Recoded in Ruby by h00die-gr3y (h00die.gr3y[at]gmail.com)
1414###
1515module Msf ::Exploit ::LaravelCryptoKiller
16+ # Check if cipher is valid
17+ # @param [String] <cipher_mode> The cipher_mode
18+ #
19+ # @return [Boolean] true if mode is ok or false if mode is not valid
20+ def valid_cipher? ( cipher_mode )
21+ ciphers ||= OpenSSL ::Cipher . ciphers
22+ ciphers . include? ( cipher_mode . downcase )
23+ end
24+
1625 # Perform AES encryption in CBC mode (compatible with Laravel)
1726 # @param [String] <value> The value that will be encrypted
1827 # @param [String] <iv> The IV parameter used for encryption
@@ -21,6 +30,11 @@ module Msf::Exploit::LaravelCryptoKiller
2130 #
2231 # @return [String] The encrypted value or nil if unsuccessful
2332 def aes_encrypt ( value , iv , key , cipher_mode )
33+ # Check cipher mode
34+ unless valid_cipher? ( cipher_mode )
35+ vprint_error ( "Cipher is not valid: #{ cipher_mode } " )
36+ return
37+ end
2438 # Create a new AES cipher in CBC mode
2539 cipher = OpenSSL ::Cipher . new ( cipher_mode )
2640 cipher . encrypt
@@ -45,6 +59,11 @@ def aes_encrypt(value, iv, key, cipher_mode)
4559 #
4660 # @return [String] The decrypted value or nil if unsuccessful
4761 def aes_decrypt ( encrypted_value , iv , key , cipher_mode )
62+ # Check cipher mode
63+ unless valid_cipher? ( cipher_mode )
64+ vprint_error ( "Cipher is not valid: #{ cipher_mode } " )
65+ return
66+ end
4867 # Create AES cipher in CBC mode
4968 cipher = OpenSSL ::Cipher . new ( cipher_mode )
5069 cipher . decrypt
0 commit comments