2007-05-03 20:23:27 +00:00
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This module provides methods for time-limited modules
|
|
|
|
#
|
|
|
|
###
|
|
|
|
|
|
|
|
module Auxiliary::Timed
|
|
|
|
|
|
|
|
require 'timeout'
|
|
|
|
|
|
|
|
#
|
|
|
|
# Initializes an instance of a timed module
|
|
|
|
#
|
|
|
|
def initialize(info = {})
|
|
|
|
super
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptInt.new('RUNTIME', [ true, "The number of seconds to run the test", 5 ] )
|
|
|
|
], Auxiliary::Timed)
|
2009-11-02 18:14:57 +00:00
|
|
|
|
2007-05-03 20:23:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# The command handler when launched from the console
|
|
|
|
#
|
|
|
|
def run
|
2010-07-07 18:14:51 +00:00
|
|
|
secs = datastore['RUNTIME'].to_i
|
2007-05-03 20:23:27 +00:00
|
|
|
print_status("Running module for #{secs} seconds...")
|
|
|
|
begin
|
2009-11-02 18:14:57 +00:00
|
|
|
Timeout.timeout(secs) { self.run_timed }
|
2007-05-03 20:23:27 +00:00
|
|
|
rescue Timeout::Error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-11-02 18:14:57 +00:00
|
|
|
end
|
|
|
|
|