Skip to content

Commit

Permalink
Land #19577, Fix crash when running meterpreter shell command
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 authored Oct 24, 2024
2 parents e899f16 + fdfda1f commit eddfda0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rex/post/meterpreter/extensions/stdapi/sys/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def Process._open(pid, perms, inherit = false)
#
# Executes an application using the arguments provided
# @param path [String] Path on the remote system to the executable to run
# @param arguments [String,Array<String>] Arguments to the process. When passed as a String (rather than an array of Strings),
# @param arguments [String,Array<String>] Arguments to the process. When passed as a String (rather than an array of Strings),
# this is treated as a string containing all arguments.
# @param opts [Hash] Optional settings to parameterise the process launch
# @option Hidden [Boolean] Is the process launched without creating a visible window
Expand Down Expand Up @@ -176,7 +176,7 @@ def Process.execute(path, arguments = '', opts = nil)
# Add arguments
# If process arguments were supplied
if arguments.kind_of?(Array)
request.add_tlv(TLV_TYPE_PROCESS_UNESCAPED_PATH, client.unicode_filter_decode( path ));
request.add_tlv(TLV_TYPE_PROCESS_UNESCAPED_PATH, client.unicode_filter_decode( path ))
# This flag is needed to disambiguate how to handle escaping special characters in the path when no arguments are provided
flags |= PROCESS_EXECUTE_FLAG_ARG_ARRAY
arguments.each do |arg|
Expand All @@ -188,8 +188,8 @@ def Process.execute(path, arguments = '', opts = nil)
if opts[:legacy_args]
request.add_tlv(TLV_TYPE_PROCESS_ARGUMENTS, opts[:legacy_args])
end
elsif arguments.kind_of?(String)
request.add_tlv(TLV_TYPE_PROCESS_PATH, client.unicode_filter_decode( path ));
elsif arguments.nil? || arguments.kind_of?(String)
request.add_tlv(TLV_TYPE_PROCESS_PATH, client.unicode_filter_decode( path ))
request.add_tlv(TLV_TYPE_PROCESS_ARGUMENTS, arguments)
else
raise ArgumentError.new('Unknown type for arguments')
Expand Down

0 comments on commit eddfda0

Please sign in to comment.