mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-24 18:16:24 +01:00
Fix edge cases in Python and C meterpreters
This commit is contained in:
parent
5422a15c79
commit
a470c4dc3a
c/meterpreter/source/extensions/stdapi/server/sys/process
python/meterpreter
@ -107,11 +107,14 @@ DWORD request_sys_process_close(Remote *remote, Packet *packet)
|
||||
|
||||
BOOL needs_quoting(PCHAR str)
|
||||
{
|
||||
BOOL bNeedsQuoting = FALSE;
|
||||
// Initial value is to need quoting, in case it's an empty arg
|
||||
BOOL bNeedsQuoting = TRUE;
|
||||
char* pArgIndex = str;
|
||||
// Check whether we'll need to quote the argument
|
||||
while (*pArgIndex != '\0')
|
||||
{
|
||||
// The arg is not empty
|
||||
bNeedsQuoting = FALSE;
|
||||
if (*pArgIndex == '\v' || *pArgIndex == ' ' || *pArgIndex == '\t')
|
||||
{
|
||||
bNeedsQuoting = TRUE;
|
||||
|
@ -1435,11 +1435,15 @@ def stdapi_sys_process_execute(request, response):
|
||||
arg_string = ""
|
||||
cmd_string = cmd + ' ' + arg_string
|
||||
|
||||
# In case we're not using a subshell:
|
||||
cmd_array = [cmd]
|
||||
cmd_array.extend(shlex.split(arg_string))
|
||||
if arg_string == '':
|
||||
# Everything was just provided in a single argument. Need to split it out.
|
||||
cmd_array = shlex.split(cmd)
|
||||
else:
|
||||
# In case we're not using a subshell:
|
||||
cmd_array = [cmd]
|
||||
cmd_array.extend(shlex.split(arg_string))
|
||||
|
||||
if os.path.isfile('/bin/sh') and (flags & PROCESS_EXECUTE_FLAG_SUBSHELL):
|
||||
if (flags & PROCESS_EXECUTE_FLAG_SUBSHELL) and os.path.isfile('/bin/sh'):
|
||||
cmd_array = ['/bin/sh', '-c', cmd_string]
|
||||
|
||||
if (flags & PROCESS_EXECUTE_FLAG_CHANNELIZED):
|
||||
|
Loading…
x
Reference in New Issue
Block a user