Module: Msf::Auxiliary::Timed

Defined in:
lib/msf/core/auxiliary/timed.rb

Overview

This module provides methods for time-limited modules

Instance Method Summary collapse

Instance Method Details

#initialize(info = {}) ⇒ Object

Initializes an instance of a timed module


17
18
19
20
21
22
23
24
25
# File 'lib/msf/core/auxiliary/timed.rb', line 17

def initialize(info = {})
  super

  register_options(
    [
      OptInt.new('RUNTIME', [ true, "The number of seconds to run the test", 5 ] )
    ], Auxiliary::Timed)

end

#runObject

The command handler when launched from the console


30
31
32
33
34
35
36
37
# File 'lib/msf/core/auxiliary/timed.rb', line 30

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