Files
metasploit-gs/lib/msf/core/module/full_name.rb
T

108 lines
2.0 KiB
Ruby
Raw Normal View History

2014-10-16 15:24:59 -05:00
# @note {Msf::Module::ModuleInfo#name} is unrelated to {#fullname} and should instead be thought of as the title or
# summary of the module.
#
# Names related to {#fullname}, such as {#fullname}, {#refname}, and {#shortname}.
module Msf::Module::FullName
extend ActiveSupport::Concern
module ClassMethods
#
# Attributes
#
# @attribute refname
2015-04-13 13:21:41 +05:00
# The module's name that is assigned to it by the framework
2014-10-16 15:24:59 -05:00
# or derived from the path that the module is loaded from.
attr_accessor :refname
#
# Class Methods
#
def fullname
2017-11-20 10:45:39 -06:00
"#{type}/#{refname}"
2014-10-16 15:24:59 -05:00
end
2019-08-26 13:22:14 -05:00
#
# Classes themselves are never aliased (at the moment, anyway), but this is
# always just the {#fullname}.
#
def realname
fullname
end
def promptname
2017-11-29 20:52:14 -06:00
refname
end
2014-10-16 15:24:59 -05:00
def shortname
refname.split('/').last
end
2019-06-03 13:40:27 -05:00
#
# Returns a list of alternate names the module might go by.
#
def aliases
const_defined?(:Aliases) ? const_get(:Aliases) : []
end
2014-10-16 15:24:59 -05:00
end
#
# Instance Methods
#
attr_accessor :aliased_as
2014-10-16 15:24:59 -05:00
#
# Returns the module's framework full reference name. This is the
# short name that end-users work with (refname) plus the type
# of module prepended. Ex:
#
# payloads/windows/shell/reverse_tcp
#
def fullname
aliased_as || self.class.fullname
2014-10-16 15:24:59 -05:00
end
#
# Always return the module's framework full reference name, even when the
# module is aliased.
#
def realname
self.class.fullname
end
2014-10-16 15:24:59 -05:00
#
# Returns the module's framework reference name. This is the
# short name that end-users work with. Ex:
#
# windows/shell/reverse_tcp
#
def refname
fullname.delete_prefix("#{type}/")
2014-10-16 15:24:59 -05:00
end
#
# Returns the module's framework prompt-friendly name.
#
# windows/shell/reverse_tcp
#
def promptname
refname
end
#
# Returns the module's framework short name.
2014-10-16 15:24:59 -05:00
#
# reverse_tcp
#
def shortname
refname.split('/').last
2014-10-16 15:24:59 -05:00
end
2019-06-03 13:40:27 -05:00
def aliases
self.class.aliases
end
2015-04-13 13:21:41 +05:00
end