CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/core/auxiliary/timed.rb
Views: 11784
1
# -*- coding: binary -*-
2
module Msf
3
4
###
5
#
6
# This module provides methods for time-limited modules
7
#
8
###
9
10
module Auxiliary::Timed
11
12
require 'timeout'
13
14
#
15
# Initializes an instance of a timed module
16
#
17
def initialize(info = {})
18
super
19
20
register_options(
21
[
22
OptInt.new('RUNTIME', [ true, "The number of seconds to run the test", 5 ] )
23
], Auxiliary::Timed)
24
25
end
26
27
#
28
# The command handler when launched from the console
29
#
30
def run
31
secs = datastore['RUNTIME'].to_i
32
print_status("Running module for #{secs} seconds...")
33
begin
34
Timeout.timeout(secs) { self.run_timed }
35
rescue Timeout::Error
36
end
37
end
38
39
end
40
end
41
42
43