dont try to run cmds on meterpreter sessions with a "sys" member, see #803
git-svn-id: file:///home/svn/framework3/trunk@8732 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
83419da78b
commit
607752f141
|
@ -1136,24 +1136,29 @@ class Core
|
|||
cmds.each do |cmd|
|
||||
framework.sessions.each_sorted do |s|
|
||||
session = framework.sessions.get(s)
|
||||
# Bail if this session doesn't have stdapi loaded
|
||||
# yet. See #803.
|
||||
next if not session.respond_to? :sys
|
||||
print_status("Running '#{cmd}' on session #{s} (#{session.tunnel_peer})")
|
||||
|
||||
if (session.type == "meterpreter")
|
||||
# If session.sys is nil, dont even try..
|
||||
if not (session.sys)
|
||||
print_error("Session #{s} does not have stdapi loaded, skipping...")
|
||||
next
|
||||
end
|
||||
c,args = cmd.split(' ', 2)
|
||||
begin
|
||||
process = session.sys.process.execute(c, args, {
|
||||
process = session.sys.process.execute(c, args,
|
||||
{
|
||||
'Channelized' => true,
|
||||
'Hidden' => true
|
||||
})
|
||||
rescue ::Rex::Post::Meterpreter::RequestError
|
||||
print_error("Failed: #{$!.class} #{$!}")
|
||||
end
|
||||
print_line(process.channel.read) if process and process.channel
|
||||
if process and process.channel and (data = process.channel.read)
|
||||
print_line(data)
|
||||
end
|
||||
elsif session.type == "shell"
|
||||
output = session.shell_command(cmd)
|
||||
if (output)
|
||||
if (output = session.shell_command(cmd))
|
||||
print_line(output)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue