Class: Msf::Modules::Metadata::Obj
- Inherits:
-
Object
- Object
- Msf::Modules::Metadata::Obj
- Defined in:
- lib/msf/core/modules/metadata/obj.rb
Instance Attribute Summary collapse
- #aliases ⇒ Array<String> readonly
- #arch ⇒ String readonly
- #author ⇒ Array<String> readonly
- #autofilter_ports ⇒ Array<Integer> readonly
- #autofilter_services ⇒ Array<String> readonly
- #check ⇒ Boolean readonly
- #default_credential ⇒ Boolean (also: #default_cred?) readonly
- #description ⇒ String readonly
- #disclosure_date ⇒ Date readonly
- #fullname ⇒ String readonly
- #is_install_path ⇒ Boolean readonly
- #mod_time ⇒ Time readonly
- #name ⇒ String readonly
- #notes ⇒ Hash readonly
- #platform ⇒ Boolean readonly
- #post_auth ⇒ Boolean (also: #post_auth?) readonly
- #rank ⇒ Integer readonly
- #ref_name ⇒ String readonly
- #references ⇒ Array<String> readonly
- #rport ⇒ Integer readonly
- #session_types ⇒ Array<String> readonly
- #targets ⇒ Array<String> readonly
- #type ⇒ String readonly
Class Method Summary collapse
-
.from_hash(obj_hash) ⇒ Object
Initialize this object from a hash.
Instance Method Summary collapse
-
#initialize(module_instance, obj_hash = nil) ⇒ Obj
constructor
A new instance of Obj.
- #path ⇒ Object
-
#to_json(*args) ⇒ Object
Returns the JSON representation of the module metadata.
- #update_mod_time(mod_time) ⇒ Object
Constructor Details
#initialize(module_instance, obj_hash = nil) ⇒ Obj
Returns a new instance of Obj.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 60 def initialize(module_instance, obj_hash = nil) unless obj_hash.nil? init_from_hash(obj_hash) return end @name = module_instance.name @fullname = module_instance.realname @aliases = module_instance.aliases @disclosure_date = module_instance.disclosure_date @rank = module_instance.rank.to_i @type = module_instance.type @description = module_instance.description.to_s.strip @author = module_instance..map{|x| x.to_s} @references = module_instance.references.map{|x| [x.ctx_id, x.ctx_val].join("-") } @post_auth = module_instance.post_auth? @default_credential = module_instance.default_cred? @platform = module_instance.platform_to_s # Done to ensure that differences do not show up for the same array grouping sort_platform_string @arch = module_instance.arch_to_s @rport = module_instance.datastore['RPORT'] @path = module_instance.file_path @mod_time = ::File.mtime(@path) rescue Time.now @ref_name = module_instance.class.refname @needs_cleanup = module_instance.respond_to?(:needs_cleanup) && module_instance.needs_cleanup if module_instance.respond_to?(:autofilter_ports) @autofilter_ports = module_instance.autofilter_ports end if module_instance.respond_to?(:autofilter_services) @autofilter_services = module_instance.autofilter_services end install_path = Msf::Config.install_root.to_s if (@path.to_s.include? (install_path)) @path = @path.sub(install_path, '') @is_install_path = true end if module_instance.respond_to?(:targets) and module_instance.targets @targets = module_instance.targets.map{|x| x.name} end # Store whether a module has a check method @check = module_instance.has_check? @notes = module_instance.notes @session_types = module_instance.respond_to?(:session_types) && module_instance.session_types # Due to potentially non-standard ASCII we force UTF-8 to ensure no problem with JSON serialization force_encoding(::Encoding::UTF_8) end |
Instance Attribute Details
#aliases ⇒ Array<String> (readonly)
16 17 18 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 16 def aliases @aliases end |
#arch ⇒ String (readonly)
32 33 34 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 32 def arch @arch end |
#author ⇒ Array<String> (readonly)
24 25 26 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 24 def @author end |
#autofilter_ports ⇒ Array<Integer> (readonly)
36 37 38 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 36 def autofilter_ports @autofilter_ports end |
#autofilter_services ⇒ Array<String> (readonly)
38 39 40 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 38 def autofilter_services @autofilter_services end |
#check ⇒ Boolean (readonly)
48 49 50 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 48 def check @check end |
#default_credential ⇒ Boolean (readonly) Also known as: default_cred?
53 54 55 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 53 def default_credential @default_credential end |
#description ⇒ String (readonly)
26 27 28 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 26 def description @description end |
#disclosure_date ⇒ Date (readonly)
20 21 22 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 20 def disclosure_date @disclosure_date end |
#fullname ⇒ String (readonly)
14 15 16 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 14 def fullname @fullname end |
#is_install_path ⇒ Boolean (readonly)
44 45 46 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 44 def is_install_path @is_install_path end |
#mod_time ⇒ Time (readonly)
42 43 44 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 42 def mod_time @mod_time end |
#name ⇒ String (readonly)
12 13 14 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 12 def name @name end |
#notes ⇒ Hash (readonly)
56 57 58 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 56 def notes @notes end |
#platform ⇒ Boolean (readonly)
30 31 32 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 30 def platform @platform end |
#post_auth ⇒ Boolean (readonly) Also known as: post_auth?
50 51 52 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 50 def post_auth @post_auth end |
#rank ⇒ Integer (readonly)
18 19 20 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 18 def rank @rank end |
#ref_name ⇒ String (readonly)
46 47 48 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 46 def ref_name @ref_name end |
#references ⇒ Array<String> (readonly)
28 29 30 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 28 def references @references end |
#rport ⇒ Integer (readonly)
34 35 36 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 34 def rport @rport end |
#session_types ⇒ Array<String> (readonly)
58 59 60 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 58 def session_types @session_types end |
#targets ⇒ Array<String> (readonly)
40 41 42 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 40 def targets @targets end |
#type ⇒ String (readonly)
22 23 24 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 22 def type @type end |
Class Method Details
Instance Method Details
#path ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 161 def path if @is_install_path return ::File.join(Msf::Config.install_root, @path) end @path end |
#to_json(*args) ⇒ Object
Returns the JSON representation of the module metadata
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 120 def to_json(*args) { 'name' => @name, 'fullname' => @fullname, 'aliases' => @aliases, 'rank' => @rank, 'disclosure_date' => @disclosure_date.nil? ? nil : @disclosure_date.to_s, 'type' => @type, 'author' => @author, 'description' => @description, 'references' => @references, 'platform' => @platform, 'arch' => @arch, 'rport' => @rport, 'autofilter_ports' => @autofilter_ports, 'autofilter_services'=> @autofilter_services, 'targets' => @targets, 'mod_time' => @mod_time.to_s, 'path' => @path, 'is_install_path' => @is_install_path, 'ref_name' => @ref_name, 'check' => @check, 'post_auth' => @post_auth, 'default_credential' => @default_credential, 'notes' => @notes, 'session_types' => @session_types, 'needs_cleanup' => @needs_cleanup }.to_json(*args) end |
#update_mod_time(mod_time) ⇒ Object
157 158 159 |
# File 'lib/msf/core/modules/metadata/obj.rb', line 157 def update_mod_time(mod_time) @mod_time = mod_time end |