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.

module_sets.rb 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # -*- coding: binary -*-
  2. #
  3. # Gems
  4. #
  5. require 'active_support/concern'
  6. #
  7. # Project
  8. #
  9. # Defines the MODULE_* constants
  10. require 'msf/core/constants'
  11. # Concerns the various type-specific module sets in a {Msf::ModuleManager}
  12. module Msf::ModuleManager::ModuleSets
  13. extend ActiveSupport::Concern
  14. #
  15. # Returns the set of loaded auxiliary module classes.
  16. #
  17. def auxiliary
  18. module_set(Msf::MODULE_AUX)
  19. end
  20. #
  21. # Returns the set of loaded encoder module classes.
  22. #
  23. def encoders
  24. module_set(Msf::MODULE_ENCODER)
  25. end
  26. #
  27. # Returns the set of loaded exploit module classes.
  28. #
  29. def exploits
  30. module_set(Msf::MODULE_EXPLOIT)
  31. end
  32. def init_module_set(type)
  33. self.enablement_by_type[type] = true
  34. case type
  35. when Msf::MODULE_PAYLOAD
  36. instance = Msf::PayloadSet.new
  37. else
  38. instance = Msf::ModuleSet.new(type)
  39. end
  40. self.module_set_by_type[type] = instance
  41. # Set the module set's framework reference
  42. instance.framework = self.framework
  43. end
  44. #
  45. # Provide a list of module names of a specific type
  46. #
  47. def module_names(set)
  48. module_set_by_type[set] ? module_set_by_type[set].keys.dup : []
  49. end
  50. #
  51. # Returns all of the modules of the specified type
  52. #
  53. def module_set(type)
  54. module_set_by_type[type]
  55. end
  56. #
  57. # Provide a list of the types of modules in the set
  58. #
  59. def module_types
  60. module_set_by_type.keys.dup
  61. end
  62. #
  63. # Returns the set of loaded nop module classes.
  64. #
  65. def nops
  66. module_set(Msf::MODULE_NOP)
  67. end
  68. #
  69. # Returns the set of loaded payload module classes.
  70. #
  71. def payloads
  72. module_set(Msf::MODULE_PAYLOAD)
  73. end
  74. #
  75. # Returns the set of loaded auxiliary module classes.
  76. #
  77. def post
  78. module_set(Msf::MODULE_POST)
  79. end
  80. def type_enabled?(type)
  81. enablement_by_type[type] || false
  82. end
  83. protected
  84. attr_accessor :enablement_by_type # :nodoc:
  85. attr_accessor :module_set_by_type # :nodoc:
  86. end