check for empty args to sessions -c
git-svn-id: file:///home/svn/framework3/trunk@8616 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
b391abd32d
commit
cc4b13a0a0
|
@ -1083,10 +1083,12 @@ class Core
|
||||||
when "-q"
|
when "-q"
|
||||||
quiet = true
|
quiet = true
|
||||||
|
|
||||||
|
# Run a command on all sessions
|
||||||
when "-c"
|
when "-c"
|
||||||
method = 'cmd'
|
method = 'cmd'
|
||||||
cmds << val
|
if (val)
|
||||||
|
cmds << val
|
||||||
|
end
|
||||||
|
|
||||||
when "-v"
|
when "-v"
|
||||||
verbose = true
|
verbose = true
|
||||||
|
@ -1094,7 +1096,7 @@ class Core
|
||||||
# Interact with the supplied session identifier
|
# Interact with the supplied session identifier
|
||||||
when "-i"
|
when "-i"
|
||||||
method = 'interact'
|
method = 'interact'
|
||||||
sid = val
|
sid = val
|
||||||
|
|
||||||
# Display the list of active sessions
|
# Display the list of active sessions
|
||||||
when "-l"
|
when "-l"
|
||||||
|
@ -1111,6 +1113,7 @@ class Core
|
||||||
method = 'detach'
|
method = 'detach'
|
||||||
sid = val
|
sid = val
|
||||||
|
|
||||||
|
# Run a script on all meterpreter sessions
|
||||||
when "-s"
|
when "-s"
|
||||||
method = 'scriptall'
|
method = 'scriptall'
|
||||||
script = val
|
script = val
|
||||||
|
@ -1129,32 +1132,36 @@ class Core
|
||||||
case method
|
case method
|
||||||
|
|
||||||
when 'cmd'
|
when 'cmd'
|
||||||
cmds.each do |cmd|
|
if (cmds.length > 0)
|
||||||
framework.sessions.each_sorted do |s|
|
cmds.each do |cmd|
|
||||||
session = framework.sessions.get(s)
|
framework.sessions.each_sorted do |s|
|
||||||
print_status("Running '#{cmd}' on session #{s} (#{session.tunnel_peer})")
|
session = framework.sessions.get(s)
|
||||||
if (session.type == "meterpreter")
|
print_status("Running '#{cmd}' on session #{s} (#{session.tunnel_peer})")
|
||||||
c,args = cmd.split(' ', 2)
|
if (session.type == "meterpreter")
|
||||||
begin
|
c,args = cmd.split(' ', 2)
|
||||||
process = session.sys.process.execute(c, args, {
|
begin
|
||||||
'Channelized' => true,
|
process = session.sys.process.execute(c, args, {
|
||||||
'Hidden' => true
|
'Channelized' => true,
|
||||||
})
|
'Hidden' => true
|
||||||
rescue ::Rex::Post::Meterpreter::RequestError
|
})
|
||||||
print_error("Failed: #{$!.class} #{$!}")
|
rescue ::Rex::Post::Meterpreter::RequestError
|
||||||
end
|
print_error("Failed: #{$!.class} #{$!}")
|
||||||
print_line(process.channel.read) if process and process.channel
|
end
|
||||||
elsif session.type == "shell"
|
print_line(process.channel.read) if process and process.channel
|
||||||
output = session.shell_command(cmd)
|
elsif session.type == "shell"
|
||||||
if (output)
|
output = session.shell_command(cmd)
|
||||||
print_line(output)
|
if (output)
|
||||||
|
print_line(output)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
# If the session isn't a meterpreter or shell type, it
|
||||||
|
# could be a VNC session (which can't run commands) or
|
||||||
|
# something custom (which we don't know how to run
|
||||||
|
# commands on), so don't bother.
|
||||||
end
|
end
|
||||||
# If the session isn't a meterpreter or shell type, it
|
|
||||||
# could be a VNC session (which can't run commands) or
|
|
||||||
# something custom (which we don't know how to run
|
|
||||||
# commands on), so don't bother.
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
print_error("No command specified!")
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'kill'
|
when 'kill'
|
||||||
|
|
Loading…
Reference in New Issue