Add some checks in buffer.rb and fix option in msfvenom

This commit is contained in:
Wei Chen 2018-04-11 13:02:35 -05:00
parent 13edf66fa3
commit 19e76329dc
2 changed files with 15 additions and 1 deletions

View File

@ -140,12 +140,26 @@ module Buffer
case encryption_opts[:format]
when 'aes256'
if encryption_opts[:iv].blank?
raise ArgumentError, 'Initialization vector is missing'
elsif encryption_opts[:key].blank?
raise ArgumentError, 'Encryption key is missing'
end
buf = Rex::Text.encrypt_aes256(encryption_opts[:iv], encryption_opts[:key], value)
when 'base64'
buf = Rex::Text.encode_base64(value)
when 'xor'
if encryption_opts[:key].blank?
raise ArgumentError, 'XOR key is missing'
end
buf = Rex::Text.xor(encryption_opts[:key], value)
when 'rc4'
if encryption_opts[:key].blank?
raise ArgumentError, 'Encryption key is missing'
end
buf = Rex::Text.rc4(encryption_opts[:key], value)
else
raise ArgumentError, "Unsupported encryption format: #{encryption_opts[:format]}", caller

View File

@ -121,7 +121,7 @@ def parse_args(args)
opts[:encryption_key] = e
end
opt.on('--encrypt-iv <value>', String, 'An init vector for the encryption') do |e|
opt.on('--encrypt-iv <value>', String, 'An initialization vector for the encryption') do |e|
opts[:encryption_iv] = e
end