Path: blob/master/lib/msf/core/auxiliary/timed.rb
19778 views
# -*- coding: binary -*-1module Msf23###4#5# This module provides methods for time-limited modules6#7###89module Auxiliary::Timed1011require 'timeout'1213#14# Initializes an instance of a timed module15#16def initialize(info = {})17super1819register_options(20[21OptInt.new('RUNTIME', [ true, "The number of seconds to run the test", 5 ] )22], Auxiliary::Timed)2324end2526#27# The command handler when launched from the console28#29def run30secs = datastore['RUNTIME'].to_i31print_status("Running module for #{secs} seconds...")32begin33Timeout.timeout(secs) { self.run_timed }34rescue Timeout::Error35end36end3738end39end40414243