Adds timed module support, fixes #97

git-svn-id: file:///home/svn/framework3/trunk@4857 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2007-05-03 20:23:27 +00:00
parent 56b74bb586
commit 4b42797768
2 changed files with 40 additions and 0 deletions

View File

@ -18,6 +18,7 @@ class Auxiliary < Msf::Module
require 'msf/core/auxiliary/scanner' require 'msf/core/auxiliary/scanner'
require 'msf/core/auxiliary/report' require 'msf/core/auxiliary/report'
require 'msf/core/auxiliary/dos' require 'msf/core/auxiliary/dos'
require 'msf/core/auxiliary/timed'
# #
# Returns MODULE_AUX to indicate that this is an auxiliary module. # Returns MODULE_AUX to indicate that this is an auxiliary module.

View File

@ -0,0 +1,39 @@
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']
print_status("Running module for #{secs} seconds...")
begin
timeout(secs) { self.run_timed }
rescue Timeout::Error
end
end
end
end