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

1297 lines
50 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: Msf::Modules::Loader::Executable
&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::Executable";
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 (E)</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">Executable</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::Executable
</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::Executable</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/modules/loader/executable.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Concerns loading executables from a directory as modules</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>
<li class="protected ">
<span class="summary_signature">
<a href="#read_script_env_runtime-instance_method" title="#read_script_env_runtime (instance method)">#<strong>read_script_env_runtime</strong>(full_path) &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#script_runtime_available%3F-instance_method" title="#script_runtime_available? (instance method)">#<strong>script_runtime_available?</strong>(full_path) &#x21d2; Boolean </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>True if the scripts required runtime is available on the host, false otherwise.</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">
56
57
58
59
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</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 56</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'>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='kw'>next</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_full_entry_pathname'>full_entry_pathname</span> <span class='op'>=</span> <span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_full_entry_path'>full_entry_path</span><span class='rparen'>)</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='comment'># Assume that all modules are scripts for now, workaround
</span> <span class='comment'># filesystems where all files are labeled as executable.
</span> <span class='kw'>if</span> <span class='id identifier rubyid_script_path?'>script_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_entry_descendant_pathname'>entry_descendant_pathname</span> <span class='op'>=</span> <span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</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_pathname'>relative_entry_descendant_pathname</span> <span class='op'>=</span> <span class='id identifier rubyid_entry_descendant_pathname'>entry_descendant_pathname</span><span class='period'>.</span><span class='id identifier rubyid_relative_path_from'>relative_path_from</span><span class='lparen'>(</span><span class='id identifier rubyid_full_entry_pathname'>full_entry_pathname</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_relative_entry_descendant_pathname'>relative_entry_descendant_pathname</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
<span class='kw'>next</span> <span class='kw'>if</span> <span class='const'>File</span><span class='op'>::</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='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</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='comma'>,</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='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.*</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</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">
10
11
12</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 10</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">
19
20
21
22</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 19</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_script_path?'>script_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">
90
91
92
93
94
95
96
97
98
99
100
101
102</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 90</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='comment'># The extension is lost on loading, hit the disk to recover :(
</span> <span class='id identifier rubyid_partial_path'>partial_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='const'><span class='object_link'><a href="Base.html#DIRECTORY_BY_TYPE-constant" title="Msf::Modules::Loader::Base::DIRECTORY_BY_TYPE (constant)">DIRECTORY_BY_TYPE</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</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_partial_path'>partial_path</span><span class='rparen'>)</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='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_mod'>mod</span><span class='op'>|</span>
<span class='kw'>if</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_full_path'>full_path</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.*</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</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_mod'>mod</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.*</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span><span class='comma'>,</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_mod'>mod</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></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">
108
109
110
111
112</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 108</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">
118
119
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</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 118</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='kw'>unless</span> <span class='id identifier rubyid_script_path?'>script_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_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='const'>Errno</span><span class='op'>::</span><span class='const'>ENOENT</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_script_runtime_available?'>script_runtime_available?</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</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='const'>RuntimeError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to load module as the following runtime was not found on the path: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_read_script_env_runtime'>read_script_env_runtime</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Modules.html" title="Msf::Modules (module)">Modules</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../External.html" title="Msf::Modules::External (class)">External</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../External/Shim.html" title="Msf::Modules::External::Shim (class)">Shim</a></span></span><span class='period'>.</span><span class='id identifier rubyid_generate'><span class='object_link'><a href="../External/Shim.html#generate-class_method" title="Msf::Modules::External::Shim.generate (method)">generate</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='comma'>,</span> <span class='ivar'>@module_manager</span><span class='period'>.</span><span class='id identifier rubyid_framework'>framework</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_content'>content</span>
<span class='kw'>return</span> <span class='id identifier rubyid_content'>content</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_elog'><span class='object_link'><a href="../../../top-level-namespace.html#elog-instance_method" title="#elog (method)">elog</a></span></span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to load module </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_full_path'>full_path</span><span class='embexpr_end'>}</span><span class='tstring_content'>, unknown module type</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>LoadError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</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_e'>e</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_elog'><span class='object_link'><a href="../../../top-level-namespace.html#elog-instance_method" title="#elog (method)">elog</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to load module </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_full_path'>full_path</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>error:</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
<span class='comment'># XXX migrate this to a full load_error when we can tell the user why the
</span> <span class='comment'># module did not load and/or how to resolve it.
</span> <span class='comment'># load_error(full_path, e)
</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="read_script_env_runtime-instance_method">
#<strong>read_script_env_runtime</strong>(full_path) &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
26
27
28
29
30
31
32</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 26</span>
<span class='kw'>def</span> <span class='id identifier rubyid_read_script_env_runtime'>read_script_env_runtime</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='comment'># Extract the runtime from the first line of the script, i.e.
</span> <span class='comment'># #!/usr/bin/env python
</span> <span class='comment'># //usr/bin/env go run &quot;$0&quot; &quot;$@&quot;; exit &quot;$?&quot;
</span> <span class='id identifier rubyid_first_line'>first_line</span> <span class='op'>=</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='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_gets'>gets</span> <span class='rbrace'>}</span>
<span class='id identifier rubyid_first_line'>first_line</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>\A(?:#!|/)/usr/bin/env\s+(\w+)</span><span class='regexp_end'>}</span></span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="script_runtime_available?-instance_method">
#<strong>script_runtime_available?</strong>(full_path) &#x21d2; <tt>Boolean</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns True if the scripts required runtime is available on the host, false otherwise.</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'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The full path to the module file.</p>
</div>
</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 if the script's required runtime is available on the host, false otherwise</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
36
37
38
39
40
41
42
43
44
45</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/modules/loader/executable.rb', line 36</span>
<span class='kw'>def</span> <span class='id identifier rubyid_script_runtime_available?'>script_runtime_available?</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_script_path?'>script_path?</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='comment'># Modules currently use /usr/bin/env - in the future absolute paths may need to be supported
</span> <span class='id identifier rubyid_script_runtime'>script_runtime</span> <span class='op'>=</span> <span class='id identifier rubyid_read_script_env_runtime'>read_script_env_runtime</span><span class='lparen'>(</span><span class='id identifier rubyid_full_path'>full_path</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='op'>!</span><span class='op'>!</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'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_find_full_path'>find_full_path</span><span class='lparen'>(</span><span class='id identifier rubyid_script_runtime'>script_runtime</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_script_runtime'>script_runtime</span>
<span class='comment'># If the script runtime isn&#39;t known, we assume the script is executable
</span> <span class='kw'>true</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>