Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timed.rb 626B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: binary -*-
  2. module Msf
  3. ###
  4. #
  5. # This module provides methods for time-limited modules
  6. #
  7. ###
  8. module Auxiliary::Timed
  9. require 'timeout'
  10. #
  11. # Initializes an instance of a timed module
  12. #
  13. def initialize(info = {})
  14. super
  15. register_options(
  16. [
  17. OptInt.new('RUNTIME', [ true, "The number of seconds to run the test", 5 ] )
  18. ], Auxiliary::Timed)
  19. end
  20. #
  21. # The command handler when launched from the console
  22. #
  23. def run
  24. secs = datastore['RUNTIME'].to_i
  25. print_status("Running module for #{secs} seconds...")
  26. begin
  27. Timeout.timeout(secs) { self.run_timed }
  28. rescue Timeout::Error
  29. end
  30. end
  31. end
  32. end