if the command we're running has spaces and we got no options for it, split it up correctly using Shellwords, fixes issues with running commands on java meterp
git-svn-id: file:///home/svn/framework3/trunk@13102 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
ba3594b7c4
commit
d876b8d297
|
@ -8,14 +8,20 @@ module Common
|
|||
def cmd_exec(cmd, opts=nil, time_out=15)
|
||||
case session.type
|
||||
when /meterpreter/
|
||||
if opts.nil? and cmd =~ /\s*/
|
||||
opts = Shellwords.shellwords(cmd)
|
||||
cmd = opts.shift
|
||||
opts = opts.join
|
||||
end
|
||||
session.response_timeout = time_out
|
||||
cmd = session.sys.process.execute(cmd, opts, {'Hidden' => true, 'Channelized' => true})
|
||||
process = session.sys.process.execute(cmd, opts, {'Hidden' => true, 'Channelized' => true})
|
||||
o = ""
|
||||
while (d = cmd.channel.read)
|
||||
while (d = process.channel.read)
|
||||
break if d == ""
|
||||
o << d
|
||||
end
|
||||
cmd.channel.close
|
||||
process.channel.close
|
||||
process.close
|
||||
cmd.close
|
||||
when /shell/
|
||||
o = session.shell_command_token("#{cmd} #{opts}", time_out)
|
||||
|
|
Loading…
Reference in New Issue