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
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Allow the user to terminate this session
|
||||
#
|
||||
def kill
|
||||
framework.sessions.deregister(self)
|
||||
end
|
||||
|
||||
#
|
||||
# The framework instance that created this session.
|
||||
#
|
||||
|
|
|
@ -56,6 +56,16 @@ module Interactive
|
|||
def run_cmd(cmd)
|
||||
end
|
||||
|
||||
#
|
||||
# Terminate the session
|
||||
#
|
||||
def kill
|
||||
self.interacting = false if self.interactive?
|
||||
self.reset_ui
|
||||
self.cleanup
|
||||
super()
|
||||
end
|
||||
|
||||
#
|
||||
# Closes rstream.
|
||||
#
|
||||
|
|
|
@ -25,11 +25,13 @@ class Core
|
|||
"-h" => [ false, "Help banner." ],
|
||||
"-l" => [ false, "List all active sessions." ],
|
||||
"-v" => [ false, "List verbose fields." ],
|
||||
"-q" => [ false, "Quiet mode." ])
|
||||
"-q" => [ false, "Quiet mode." ],
|
||||
"-k" => [ true, "Terminate session." ])
|
||||
|
||||
@@jobs_opts = Rex::Parser::Arguments.new(
|
||||
"-h" => [ false, "Help banner." ],
|
||||
"-k" => [ true, "Terminate the specified job name." ],
|
||||
"-a" => [ false, "Terminate all running jobs." ],
|
||||
"-l" => [ false, "List all running jobs." ])
|
||||
|
||||
@@persist_opts = Rex::Parser::Arguments.new(
|
||||
|
@ -226,9 +228,14 @@ class Core
|
|||
# Terminate the supplied job name
|
||||
when "-k"
|
||||
print_line("Stopping 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"
|
||||
print(
|
||||
"Usage: jobs [options]\n\n" +
|
||||
|
@ -600,6 +607,10 @@ class Core
|
|||
when "-l"
|
||||
method = 'list'
|
||||
|
||||
when "-k"
|
||||
method = 'kill'
|
||||
sid = val
|
||||
|
||||
# Display help banner
|
||||
when "-h"
|
||||
print(
|
||||
|
@ -612,6 +623,12 @@ class Core
|
|||
|
||||
# Now, perform the actual method
|
||||
case method
|
||||
|
||||
when 'kill'
|
||||
if ((session = framework.sessions.get(sid)))
|
||||
session.kill
|
||||
end
|
||||
|
||||
when 'interact'
|
||||
if ((session = framework.sessions.get(sid)))
|
||||
if (session.interactive?)
|
||||
|
|
|
@ -71,12 +71,10 @@ module Interactive
|
|||
#
|
||||
# Whether or not the session is currently being interacted with
|
||||
#
|
||||
attr_reader :interacting
|
||||
attr_accessor :interacting
|
||||
|
||||
protected
|
||||
|
||||
attr_writer :interacting # :nodoc:
|
||||
|
||||
#
|
||||
# The original suspend proc.
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue