Files
metasploit-gs/lib/msf/core/auxiliary/timed.rb
T
HD Moore c0aca105de closes #2205. This is actually part of the bigger datastore bug
git-svn-id: file:///home/svn/framework3/trunk@9722 4d416f70-5f16-0410-b530-b9f4589650da
2010-07-07 18:14:51 +00:00

41 lines
585 B
Ruby

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)
end
#
# The command handler when launched from the console
#
def run
secs = datastore['RUNTIME'].to_i
print_status("Running module for #{secs} seconds...")
begin
Timeout.timeout(secs) { self.run_timed }
rescue Timeout::Error
end
end
end
end