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.

brutetargets.rb 909B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: binary -*-
  2. module Msf
  3. ###
  4. #
  5. # This module allows a compatible exploit to be called once for every valid target,
  6. # in succession, until no targets are left.
  7. #
  8. ###
  9. module Exploit::BruteTargets
  10. # Compatible exploit modules define a method call exploit_target, which is called once
  11. # for every target in the list. The very first target should always be a stub for enabling
  12. # the brute force mode.
  13. def exploit(*args)
  14. # Brute force through every available target
  15. if (not datastore['TARGET'] or datastore['TARGET'].to_i == 0)
  16. print_status("Brute forcing with #{(targets.length - 1)} possible targets")
  17. targets.each_index do |i|
  18. next if i == 0
  19. break if session_created?
  20. print_status("Trying target #{targets[i].name}...")
  21. exploit_target(targets[i])
  22. end
  23. # Otherwise, only try the specified target
  24. else
  25. exploit_target(target())
  26. end
  27. end
  28. end
  29. end