Files
metasploit-gs/api/Msf/Modules/Loader/Directory.html
T
jenkins-metasploit c3f5bd3de2 Reboot gh-pages
2026-05-08 17:08:43 +00:00

1074 lines
36 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: Msf::Modules::Loader::Directory
&mdash; Documentation by YARD 0.9.37
</title>
<link rel="stylesheet" href="../../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Msf::Modules::Loader::Directory";
relpath = '../../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../../_index.html">Index (D)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../../Msf.html" title="Msf (module)">Msf</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Modules.html" title="Msf::Modules (module)">Modules</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Loader.html" title="Msf::Modules::Loader (module)">Loader</a></span></span>
&raquo;
<span class="title">Directory</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: Msf::Modules::Loader::Directory
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName"><span class='object_link'><a href="Base.html" title="Msf::Modules::Loader::Base (class)">Base</a></span></span>
<ul class="fullTree">
<li>Object</li>
<li class="next"><span class='object_link'><a href="Base.html" title="Msf::Modules::Loader::Base (class)">Base</a></span></li>
<li class="next">Msf::Modules::Loader::Directory</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/modules/loader/directory.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Concerns loading Ruby modules from a directory</p>
</div>
</div>
<div class="tags">
</div>
<h2>Constant Summary</h2>
<h3 class="inherited">Constants inherited
from <span class='object_link'><a href="Base.html" title="Msf::Modules::Loader::Base (class)">Base</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Base.html#DIRECTORY_BY_TYPE-constant" title="Msf::Modules::Loader::Base::DIRECTORY_BY_TYPE (constant)">Base::DIRECTORY_BY_TYPE</a></span>, <span class='object_link'><a href="Base.html#MODULE_EXTENSION-constant" title="Msf::Modules::Loader::Base::MODULE_EXTENSION (constant)">Base::MODULE_EXTENSION</a></span>, <span class='object_link'><a href="Base.html#MODULE_SEPARATOR-constant" title="Msf::Modules::Loader::Base::MODULE_SEPARATOR (constant)">Base::MODULE_SEPARATOR</a></span>, <span class='object_link'><a href="Base.html#NAMESPACE_MODULE_CONTENT-constant" title="Msf::Modules::Loader::Base::NAMESPACE_MODULE_CONTENT (constant)">Base::NAMESPACE_MODULE_CONTENT</a></span>, <span class='object_link'><a href="Base.html#NAMESPACE_MODULE_LINE-constant" title="Msf::Modules::Loader::Base::NAMESPACE_MODULE_LINE (constant)">Base::NAMESPACE_MODULE_LINE</a></span>, <span class='object_link'><a href="Base.html#NAMESPACE_MODULE_NAMES-constant" title="Msf::Modules::Loader::Base::NAMESPACE_MODULE_NAMES (constant)">Base::NAMESPACE_MODULE_NAMES</a></span>, <span class='object_link'><a href="Base.html#TYPE_BY_DIRECTORY-constant" title="Msf::Modules::Loader::Base::TYPE_BY_DIRECTORY (constant)">Base::TYPE_BY_DIRECTORY</a></span>, <span class='object_link'><a href="Base.html#UNIT_TEST_REGEX-constant" title="Msf::Modules::Loader::Base::UNIT_TEST_REGEX (constant)">Base::UNIT_TEST_REGEX</a></span></p>
<h2>Instance Attribute Summary</h2>
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Base.html" title="Msf::Modules::Loader::Base (class)">Base</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Base.html#module_manager-instance_method" title="Msf::Modules::Loader::Base#module_manager (method)">#module_manager</a></span></p>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="protected ">
<span class="summary_signature">
<a href="#each_module_reference_name-instance_method" title="#each_module_reference_name (instance method)">#<strong>each_module_reference_name</strong>(path, opts = {}) {|parent_path, type, module_reference_name| ... } &#x21d2; void </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Yields the module_reference_name for each module file found under the directory path.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#loadable%3F-instance_method" title="#loadable? (instance method)">#<strong>loadable?</strong>(path) &#x21d2; true, false </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns true if the path is a directory.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#loadable_module%3F-instance_method" title="#loadable_module? (instance method)">#<strong>loadable_module?</strong>(parent_path, type, module_reference_name, cached_metadata: nil) &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>True this loader can load the module, false otherwise.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#module_path-instance_method" title="#module_path (instance method)">#<strong>module_path</strong>(parent_path, type, module_reference_name) &#x21d2; String </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the full path to the module file on disk.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#read_module_content-instance_method" title="#read_module_content (instance method)">#<strong>read_module_content</strong>(parent_path, type, module_reference_name) &#x21d2; String </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Loads the module content from the on disk file.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#read_module_content_from_path-instance_method" title="#read_module_content_from_path (instance method)">#<strong>read_module_content_from_path</strong>(full_path) &#x21d2; String </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Loads the module content from the on disk file.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Msf::Modules::Loader::Base (class)">Base</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Base.html#create_namespace_module-instance_method" title="Msf::Modules::Loader::Base#create_namespace_module (method)">#create_namespace_module</a></span>, <span class='object_link'><a href="Base.html#current_module-instance_method" title="Msf::Modules::Loader::Base#current_module (method)">#current_module</a></span>, <span class='object_link'><a href="Base.html#initialize-instance_method" title="Msf::Modules::Loader::Base#initialize (method)">#initialize</a></span>, <span class='object_link'><a href="Base.html#load_error-instance_method" title="Msf::Modules::Loader::Base#load_error (method)">#load_error</a></span>, <span class='object_link'><a href="Base.html#load_module-instance_method" title="Msf::Modules::Loader::Base#load_module (method)">#load_module</a></span>, <span class='object_link'><a href="Base.html#load_modules-instance_method" title="Msf::Modules::Loader::Base#load_modules (method)">#load_modules</a></span>, <span class='object_link'><a href="Base.html#load_warning-instance_method" title="Msf::Modules::Loader::Base#load_warning (method)">#load_warning</a></span>, <span class='object_link'><a href="Base.html#module_path%3F-instance_method" title="Msf::Modules::Loader::Base#module_path? (method)">#module_path?</a></span>, <span class='object_link'><a href="Base.html#module_reference_name_from_path-instance_method" title="Msf::Modules::Loader::Base#module_reference_name_from_path (method)">#module_reference_name_from_path</a></span>, <span class='object_link'><a href="Base.html#namespace_module_name-instance_method" title="Msf::Modules::Loader::Base#namespace_module_name (method)">#namespace_module_name</a></span>, <span class='object_link'><a href="Base.html#namespace_module_names-instance_method" title="Msf::Modules::Loader::Base#namespace_module_names (method)">#namespace_module_names</a></span>, <span class='object_link'><a href="Base.html#namespace_module_transaction-instance_method" title="Msf::Modules::Loader::Base#namespace_module_transaction (method)">#namespace_module_transaction</a></span>, <span class='object_link'><a href="Base.html#reload_module-instance_method" title="Msf::Modules::Loader::Base#reload_module (method)">#reload_module</a></span>, <span class='object_link'><a href="Base.html#restore_namespace_module-instance_method" title="Msf::Modules::Loader::Base#restore_namespace_module (method)">#restore_namespace_module</a></span>, <span class='object_link'><a href="Base.html#reverse_relative_name-class_method" title="Msf::Modules::Loader::Base.reverse_relative_name (method)">reverse_relative_name</a></span>, <span class='object_link'><a href="Base.html#script_path%3F-instance_method" title="Msf::Modules::Loader::Base#script_path? (method)">#script_path?</a></span>, <span class='object_link'><a href="Base.html#typed_path-class_method" title="Msf::Modules::Loader::Base.typed_path (method)">typed_path</a></span>, <span class='object_link'><a href="Base.html#typed_path-instance_method" title="Msf::Modules::Loader::Base#typed_path (method)">#typed_path</a></span></p>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="Base.html#initialize-instance_method" title="Msf::Modules::Loader::Base#initialize (method)">Msf::Modules::Loader::Base</a></span></p>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="each_module_reference_name-instance_method">
#<strong>each_module_reference_name</strong>(path, opts = {}) {|parent_path, type, module_reference_name| ... } &#x21d2; <tt>void</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p class="note returns_void">This method returns an undefined value.</p>
<p>Yields the module_reference_name for each module file found under the directory path.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path to the directory.</p>
</div>
</li>
<li>
<span class='name'>opts</span>
<span class='type'>(<tt>Hash</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
&mdash;
<div class='inline'>
<p>Input Hash.</p>
</div>
</li>
</ul>
<p class="tag_title">Yields:</p>
<ul class="yield">
<li>
<span class='type'>(<tt>parent_path</tt>, <tt>type</tt>, <tt>module_reference_name</tt>)</span>
&mdash;
<div class='inline'>
<p>Gives the path and the module_reference_name of the module found under the path.</p>
</div>
</li>
</ul>
<p class="tag_title">Yield Parameters:</p>
<ul class="yieldparam">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path to the directory.</p>
</div>
</li>
<li>
<span class='name'>type</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The type correlated with the directory under path.</p>
</div>
</li>
<li>
<span class='name'>module_reference_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The canonical name for referencing the module.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/directory.rb', line 36</span>
<span class='kw'>def</span> <span class='id identifier rubyid_each_module_reference_name'>each_module_reference_name</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='id identifier rubyid_whitelist'>whitelist</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:whitelist</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='op'>::</span><span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span>
<span class='id identifier rubyid_full_entry_path'>full_entry_path</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_entry'>entry</span><span class='rparen'>)</span>
<span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_singularize'>singularize</span>
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span><span class='lparen'>(</span><span class='id identifier rubyid_full_entry_path'>full_entry_path</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_module_manager'>module_manager</span><span class='period'>.</span><span class='id identifier rubyid_type_enabled?'>type_enabled?</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
<span class='id identifier rubyid_type_dir_prefix'>type_dir_prefix</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_full_entry_path'>full_entry_path</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='op'>::</span><span class='const'>File</span><span class='op'>::</span><span class='const'>SEPARATOR</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='comment'># Try to load modules from all the files in the supplied path
</span> <span class='const'><span class='object_link'><a href="../../../Rex.html" title="Rex (module)">Rex</a></span></span><span class='op'>::</span><span class='const'>Find</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_full_entry_path'>full_entry_path</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry_descendant_path'>entry_descendant_path</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_module_path?'>module_path?</span><span class='lparen'>(</span><span class='id identifier rubyid_entry_descendant_path'>entry_descendant_path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_relative_entry_descendant_path'>relative_entry_descendant_path</span> <span class='op'>=</span> <span class='id identifier rubyid_entry_descendant_path'>entry_descendant_path</span><span class='period'>.</span><span class='id identifier rubyid_delete_prefix'>delete_prefix</span><span class='lparen'>(</span><span class='id identifier rubyid_type_dir_prefix'>type_dir_prefix</span><span class='rparen'>)</span>
<span class='kw'>next</span> <span class='kw'>if</span> <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_basename'>basename</span><span class='lparen'>(</span><span class='id identifier rubyid_relative_entry_descendant_path'>relative_entry_descendant_path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>example</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># The module_reference_name doesn&#39;t have a file extension
</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span> <span class='op'>=</span> <span class='id identifier rubyid_module_reference_name_from_path'>module_reference_name_from_path</span><span class='lparen'>(</span><span class='id identifier rubyid_relative_entry_descendant_path'>relative_entry_descendant_path</span><span class='rparen'>)</span>
<span class='kw'>yield</span> <span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="loadable?-instance_method">
#<strong>loadable?</strong>(path) &#x21d2; <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns true if the path is a directory</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>Path under which there are modules</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>)</span>
&mdash;
<div class='inline'>
<p>if path is a directory</p>
</div>
</li>
<li>
<span class='type'>(<tt>false</tt>)</span>
&mdash;
<div class='inline'>
<p>otherwise</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
11
12
13</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/directory.rb', line 11</span>
<span class='kw'>def</span> <span class='id identifier rubyid_loadable?'>loadable?</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="loadable_module?-instance_method">
#<strong>loadable_module?</strong>(parent_path, type, module_reference_name, cached_metadata: nil) &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns True this loader can load the module, false otherwise.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>parent_path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>Root directory to load modules from</p>
</div>
</li>
<li>
<span class='name'>type</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>Such as auxiliary, exploit, etc</p>
</div>
</li>
<li>
<span class='name'>module_reference_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The module reference name, without the type prefix</p>
</div>
</li>
<li>
<span class='name'>cached_metadata</span>
<span class='type'>(<tt>nil</tt>, <tt><span class='object_link'><a href="../Metadata/Obj.html" title="Msf::Modules::Metadata::Obj (class)">Msf::Modules::Metadata::Obj</a></span></tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
&mdash;
<div class='inline'>
<p>True this loader can load the module, false otherwise</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
20
21
22
23</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/directory.rb', line 20</span>
<span class='kw'>def</span> <span class='id identifier rubyid_loadable_module?'>loadable_module?</span><span class='lparen'>(</span><span class='id identifier rubyid_parent_path'>parent_path</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span><span class='comma'>,</span> <span class='label'>cached_metadata:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_full_path'>full_path</span> <span class='op'>=</span> <span class='id identifier rubyid_cached_metadata'>cached_metadata</span><span class='op'>&amp;.</span><span class='id identifier rubyid_path'>path</span> <span class='op'>||</span> <span class='id identifier rubyid_module_path'>module_path</span><span class='lparen'>(</span><span class='id identifier rubyid_parent_path'>parent_path</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_module_path?'>module_path?</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="module_path-instance_method">
#<strong>module_path</strong>(parent_path, type, module_reference_name) &#x21d2; <tt>String</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the full path to the module file on disk.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>parent_path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path under which the module exists. This is not necessarily the same path as passed to <span class='object_link'><a href="Base.html#load_modules-instance_method" title="Msf::Modules::Loader::Base#load_modules (method)">Base#load_modules</a></span>: it may just be derived from that path.</p>
</div>
</li>
<li>
<span class='name'>type</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The type of module.</p>
</div>
</li>
<li>
<span class='name'>module_reference_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The canonical name for referring to the module.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>Path to module file on disk.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
65
66
67
68
69
70</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/directory.rb', line 65</span>
<span class='kw'>def</span> <span class='id identifier rubyid_module_path'>module_path</span><span class='lparen'>(</span><span class='id identifier rubyid_parent_path'>parent_path</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_typed_path'>typed_path</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_typed_path'>typed_path</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_full_path'>full_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_parent_path'>parent_path</span><span class='comma'>,</span> <span class='id identifier rubyid_typed_path'>typed_path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_full_path'>full_path</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="read_module_content-instance_method">
#<strong>read_module_content</strong>(parent_path, type, module_reference_name) &#x21d2; <tt>String</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Loads the module content from the on disk file.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>parent_path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path under which the module exists. This is not necessarily the same path as passed to <span class='object_link'><a href="Base.html#load_modules-instance_method" title="Msf::Modules::Loader::Base#load_modules (method)">Base#load_modules</a></span>: it may just be derived from that path.</p>
</div>
</li>
<li>
<span class='name'>type</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The type of module.</p>
</div>
</li>
<li>
<span class='name'>module_reference_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The canonical name for referring to the module.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>module content that can be module_evaled into the <span class='object_link'><a href="Base.html#create_namespace_module-instance_method" title="Msf::Modules::Loader::Base#create_namespace_module (method)">Base#create_namespace_module</a></span></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
76
77
78
79
80</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/directory.rb', line 76</span>
<span class='kw'>def</span> <span class='id identifier rubyid_read_module_content'>read_module_content</span><span class='lparen'>(</span><span class='id identifier rubyid_parent_path'>parent_path</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_full_path'>full_path</span> <span class='op'>=</span> <span class='id identifier rubyid_module_path'>module_path</span><span class='lparen'>(</span><span class='id identifier rubyid_parent_path'>parent_path</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_module_reference_name'>module_reference_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_read_module_content_from_path'>read_module_content_from_path</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="read_module_content_from_path-instance_method">
#<strong>read_module_content_from_path</strong>(full_path) &#x21d2; <tt>String</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Loads the module content from the on disk file.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>full_path</span>
<span class='type'></span>
&mdash;
<div class='inline'>
<p>Path to the module to be read</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>module content that can be module_evaled into the <span class='object_link'><a href="Base.html#create_namespace_module-instance_method" title="Msf::Modules::Loader::Base#create_namespace_module (method)">Base#create_namespace_module</a></span></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/directory.rb', line 86</span>
<span class='kw'>def</span> <span class='id identifier rubyid_read_module_content_from_path'>read_module_content_from_path</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='id identifier rubyid_module_content'>module_content</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>begin</span>
<span class='comment'># force to read in binary mode so Pro modules won&#39;t be truncated on Windows
</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>rb</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
<span class='comment'># Pass the size of the file as it leads to faster reads due to fewer buffer resizes. Greatest effect on Windows.
</span> <span class='comment'># @see http://www.ruby-forum.com/topic/209005
</span> <span class='comment'># @see https://github.com/ruby/ruby/blob/ruby_1_8_7/io.c#L1205
</span> <span class='comment'># @see https://github.com/ruby/ruby/blob/ruby_1_9_3/io.c#L2038
</span> <span class='id identifier rubyid_module_content'>module_content</span> <span class='op'>=</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_stat'>stat</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>ENOENT</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_error'>error</span>
<span class='id identifier rubyid_load_error'>load_error</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='comma'>,</span> <span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_module_content'>module_content</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:03:34 2026 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.1.5).
</div>
</div>
</body>
</html>