Support for killing sessions from the UI and killing all running jobs with jobs -a
git-svn-id: file:///home/svn/framework3/trunk@4361 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
e67f32c9e5
commit
8a797e6bcc
|
@ -185,6 +185,14 @@ module Session
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Allow the user to terminate this session
|
||||||
|
#
|
||||||
|
def kill
|
||||||
|
framework.sessions.deregister(self)
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# The framework instance that created this session.
|
# The framework instance that created this session.
|
||||||
#
|
#
|
||||||
|
|
|
@ -56,6 +56,16 @@ module Interactive
|
||||||
def run_cmd(cmd)
|
def run_cmd(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Terminate the session
|
||||||
|
#
|
||||||
|
def kill
|
||||||
|
self.interacting = false if self.interactive?
|
||||||
|
self.reset_ui
|
||||||
|
self.cleanup
|
||||||
|
super()
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Closes rstream.
|
# Closes rstream.
|
||||||
#
|
#
|
||||||
|
|
|
@ -25,11 +25,13 @@ class Core
|
||||||
"-h" => [ false, "Help banner." ],
|
"-h" => [ false, "Help banner." ],
|
||||||
"-l" => [ false, "List all active sessions." ],
|
"-l" => [ false, "List all active sessions." ],
|
||||||
"-v" => [ false, "List verbose fields." ],
|
"-v" => [ false, "List verbose fields." ],
|
||||||
"-q" => [ false, "Quiet mode." ])
|
"-q" => [ false, "Quiet mode." ],
|
||||||
|
"-k" => [ true, "Terminate session." ])
|
||||||
|
|
||||||
@@jobs_opts = Rex::Parser::Arguments.new(
|
@@jobs_opts = Rex::Parser::Arguments.new(
|
||||||
"-h" => [ false, "Help banner." ],
|
"-h" => [ false, "Help banner." ],
|
||||||
"-k" => [ true, "Terminate the specified job name." ],
|
"-k" => [ true, "Terminate the specified job name." ],
|
||||||
|
"-a" => [ false, "Terminate all running jobs." ],
|
||||||
"-l" => [ false, "List all running jobs." ])
|
"-l" => [ false, "List all running jobs." ])
|
||||||
|
|
||||||
@@persist_opts = Rex::Parser::Arguments.new(
|
@@persist_opts = Rex::Parser::Arguments.new(
|
||||||
|
@ -226,9 +228,14 @@ class Core
|
||||||
# Terminate the supplied job name
|
# Terminate the supplied job name
|
||||||
when "-k"
|
when "-k"
|
||||||
print_line("Stopping job: #{val}...")
|
print_line("Stopping job: #{val}...")
|
||||||
|
|
||||||
framework.jobs.stop_job(val)
|
framework.jobs.stop_job(val)
|
||||||
|
|
||||||
|
when "-a"
|
||||||
|
print_line("Stopping all jobs...")
|
||||||
|
framework.jobs.each_key do |i|
|
||||||
|
framework.jobs.stop_job(i)
|
||||||
|
end
|
||||||
|
|
||||||
when "-h"
|
when "-h"
|
||||||
print(
|
print(
|
||||||
"Usage: jobs [options]\n\n" +
|
"Usage: jobs [options]\n\n" +
|
||||||
|
@ -600,6 +607,10 @@ class Core
|
||||||
when "-l"
|
when "-l"
|
||||||
method = 'list'
|
method = 'list'
|
||||||
|
|
||||||
|
when "-k"
|
||||||
|
method = 'kill'
|
||||||
|
sid = val
|
||||||
|
|
||||||
# Display help banner
|
# Display help banner
|
||||||
when "-h"
|
when "-h"
|
||||||
print(
|
print(
|
||||||
|
@ -612,6 +623,12 @@ class Core
|
||||||
|
|
||||||
# Now, perform the actual method
|
# Now, perform the actual method
|
||||||
case method
|
case method
|
||||||
|
|
||||||
|
when 'kill'
|
||||||
|
if ((session = framework.sessions.get(sid)))
|
||||||
|
session.kill
|
||||||
|
end
|
||||||
|
|
||||||
when 'interact'
|
when 'interact'
|
||||||
if ((session = framework.sessions.get(sid)))
|
if ((session = framework.sessions.get(sid)))
|
||||||
if (session.interactive?)
|
if (session.interactive?)
|
||||||
|
|
|
@ -71,12 +71,10 @@ module Interactive
|
||||||
#
|
#
|
||||||
# Whether or not the session is currently being interacted with
|
# Whether or not the session is currently being interacted with
|
||||||
#
|
#
|
||||||
attr_reader :interacting
|
attr_accessor :interacting
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
attr_writer :interacting # :nodoc:
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The original suspend proc.
|
# The original suspend proc.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue