diff --git a/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb b/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb index 1645f97bba..751eee39a4 100644 --- a/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb +++ b/lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb @@ -37,7 +37,7 @@ class Config # Returns a hash of requested environment variables, along with their values. # If a requested value doesn't exist in the response, then the value wasn't found. # - def getenv(var_names) + def getenvs(*var_names) request = Packet.create_request('stdapi_sys_config_getenv') var_names.each do |v| @@ -56,6 +56,13 @@ class Config return result end + # + # Returns the value of a single requested environment variable name + # + def getenv(var_name) + getenvs(var_name)[var_name] + end + # # Returns a hash of information about the remote computer. # diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb index b92dbf9620..fd8fe65353 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb @@ -279,8 +279,11 @@ class Console::CommandDispatcher::Stdapi::Sys print_line("Server username: #{client.sys.config.getuid}") end + # + # Get the value of one or more environment variables from the target. + # def cmd_getenv(*args) - vars = client.sys.config.getenv(args) + vars = client.sys.config.getenvs(*args) if vars.length == 0 print_error("None of the specified environment variables were found/set.")