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

1446 lines
41 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>
Module: Msf::Module::Alert
&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::Module::Alert";
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 (A)</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="../Module.html" title="Msf::Module (class)">Module</a></span></span>
&raquo;
<span class="title">Alert</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>Module: Msf::Module::Alert
</h1>
<div class="box_info">
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="../Module.html" title="Msf::Module (class)">Msf::Module</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/module/alert.rb</dd>
</dl>
</div>
<h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Alert/ClassMethods.html" title="Msf::Module::Alert::ClassMethods (module)">ClassMethods</a></span>
</p>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="protected ">
<span class="summary_signature">
<a href="#alerts-instance_method" title="#alerts (instance method)">#<strong>alerts</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the value of attribute alerts.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#you_have_been_warned-instance_method" title="#you_have_been_warned (instance method)">#<strong>you_have_been_warned</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the value of attribute you_have_been_warned.</p>
</div></span>
</li>
</ul>
<h2>
Class Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#included-class_method" title="included (class method)">.<strong>included</strong>(base) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
</ul>
<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="#add_alert-instance_method" title="#add_alert (instance method)">#<strong>add_alert</strong>(level, msg, &amp;block) &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Add an alert for _this instance_ of a module (see <span class='object_link'><a href="Alert/ClassMethods.html#add_alert-instance_method" title="Msf::Module::Alert::ClassMethods#add_alert (method)">ClassMethods#add_alert</a></span>).</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#add_error-instance_method" title="#add_error (instance method)">#<strong>add_error</strong>(msg = nil, &amp;block) &#x21d2; true<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Add a error that will be provided to the user as early possible when using this instance of a module, either when they select it with the use` command, when the module is about to start running, or when the module generates its output.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#add_info-instance_method" title="#add_info (instance method)">#<strong>add_info</strong>(msg = nil, &amp;block) &#x21d2; true<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Add an info message that will be provided to the user as early possible when using this instance of a module, either when they select it with the use` command, when the module is about to start running, or when the module generates its output.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#add_warning-instance_method" title="#add_warning (instance method)">#<strong>add_warning</strong>(msg = nil, &amp;block) &#x21d2; true<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Add a warning that will be provided to the user as early possible when using this instance of a module, either when they select it with the use` command, when the module is about to start running, or when the module generates its output.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#alert_user-instance_method" title="#alert_user (instance method)">#<strong>alert_user</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Display alerts with print_warning` for warnings and `print_error` for errors.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#errors-instance_method" title="#errors (instance method)">#<strong>errors</strong> &#x21d2; Array&lt;String&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>A list of error strings to show the user.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#get_alerts-instance_method" title="#get_alerts (instance method)">#<strong>get_alerts</strong>(level) &#x21d2; Array&lt;String&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Similar to <span class='object_link'><a href="Alert/ClassMethods.html#get_alerts-instance_method" title="Msf::Module::Alert::ClassMethods#get_alerts (method)">ClassMethods#get_alerts</a></span>, but executes each registered block in the context of this module instance and returns a flattened list of strings.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#infos-instance_method" title="#infos (instance method)">#<strong>infos</strong> &#x21d2; Array&lt;String&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>A list of info strings to show the user.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#is_usable%3F-instance_method" title="#is_usable? (instance method)">#<strong>is_usable?</strong> &#x21d2; true, false </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>This method allows modules to tell the framework if they are usable on the system that they are being loaded on in a generic fashion.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#warnings-instance_method" title="#warnings (instance method)">#<strong>warnings</strong> &#x21d2; Array&lt;String&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>A list of warning strings to show the user.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#without_prompt-instance_method" title="#without_prompt (instance method)">#<strong>without_prompt</strong>(&amp;block) &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Temporarily set the prompt mode to false to ensure that there are not additional lines printed A workaround for the prompting bug spotted in <a href="https://github.com/rapid7/metasploit-framework/pull/18761#issuecomment-1916645095">github.com/rapid7/metasploit-framework/pull/18761#issuecomment-1916645095</a>.</p>
</div></span>
</li>
</ul>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id="alerts=-instance_method"></span>
<div class="method_details first">
<h3 class="signature first" id="alerts-instance_method">
#<strong>alerts</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute alerts.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
225
226
227</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 225</span>
<span class='kw'>def</span> <span class='id identifier rubyid_alerts'>alerts</span>
<span class='ivar'>@alerts</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="you_have_been_warned=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="you_have_been_warned-instance_method">
#<strong>you_have_been_warned</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute you_have_been_warned.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
225
226
227</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 225</span>
<span class='kw'>def</span> <span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span>
<span class='ivar'>@you_have_been_warned</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="included-class_method">
.<strong>included</strong>(base) &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
124
125
126</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 124</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Alert/ClassMethods.html" title="Msf::Module::Alert::ClassMethods (module)">ClassMethods</a></span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</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="add_alert-instance_method">
#<strong>add_alert</strong>(level, msg, &amp;block) &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Add an alert for _this instance_ of a module (see <span class='object_link'><a href="Alert/ClassMethods.html#add_alert-instance_method" title="Msf::Module::Alert::ClassMethods#add_alert (method)">Msf::Module::Alert::ClassMethods#add_alert</a></span>)</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
228
229
230
231
232
233
234
235
236
237
238</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 228</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add_alert'>add_alert</span><span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span><span class='lbracket'>[</span><span class='id identifier rubyid_level'>level</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span><span class='lbracket'>[</span><span class='id identifier rubyid_level'>level</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_block'>block</span>
<span class='kw'>true</span>
<span class='kw'>elsif</span> <span class='id identifier rubyid_msg'>msg</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span><span class='lbracket'>[</span><span class='id identifier rubyid_level'>level</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_msg'>msg</span>
<span class='kw'>true</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="add_error-instance_method">
#<strong>add_error</strong>(msg = nil, &amp;block) &#x21d2; <tt>true</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Add a error that will be provided to the user as early possible when using this instance of a module, either when they select it with the use` command, when the module is about to start running, or when the module generates its output. Adding an error will cause #is_usable to return `false`.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>msg</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
&mdash;
<div class='inline'>
<p>an optional error message</p>
</div>
</li>
<li>
<span class='name'>block</span>
<span class='type'>(<tt>Proc</tt>)</span>
&mdash;
<div class='inline'>
<p>an optional block that will be executed in the context of the module instance at alert time to generate the error message. If provided the msg parameter is ignored.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>whether or not the message was added to the list of errors</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
155
156
157</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 155</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add_error'>add_error</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_add_alert'>add_alert</span><span class='lparen'>(</span><span class='symbol'>:error</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="add_info-instance_method">
#<strong>add_info</strong>(msg = nil, &amp;block) &#x21d2; <tt>true</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Add an info message that will be provided to the user as early possible when using this instance of a module, either when they select it with the use` command, when the module is about to start running, or when the module generates its output.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>msg</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
&mdash;
<div class='inline'>
<p>an optional info message</p>
</div>
</li>
<li>
<span class='name'>block</span>
<span class='type'>(<tt>Proc</tt>)</span>
&mdash;
<div class='inline'>
<p>an optional block that will be executed in the context of the module instance at alert time to generate the message. If provided the msg parameter is ignored.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>whether or not the message was added to the list of info messages</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
170
171
172</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 170</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add_info'>add_info</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_add_alert'>add_alert</span><span class='lparen'>(</span><span class='symbol'>:info</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="add_warning-instance_method">
#<strong>add_warning</strong>(msg = nil, &amp;block) &#x21d2; <tt>true</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Add a warning that will be provided to the user as early possible when using this instance of a module, either when they select it with the use` command, when the module is about to start running, or when the module generates its output.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>msg</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
&mdash;
<div class='inline'>
<p>an optional warning message</p>
</div>
</li>
<li>
<span class='name'>block</span>
<span class='type'>(<tt>Proc</tt>)</span>
&mdash;
<div class='inline'>
<p>an optional block that will be executed in the context of the module instance at alert time to generate the warning message. If provided the msg parameter is ignored.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>whether or not the message was added to the list of warnings</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
139
140
141</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 139</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add_warning'>add_warning</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_add_alert'>add_alert</span><span class='lparen'>(</span><span class='symbol'>:warning</span><span class='comma'>,</span> <span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="alert_user-instance_method">
#<strong>alert_user</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Display alerts with print_warning` for warnings and `print_error` for errors. Alerts that have already been displayed by this module instance with this method will not be displayed again.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 243</span>
<span class='kw'>def</span> <span class='id identifier rubyid_alert_user'>alert_user</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_msg'>msg</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span><span class='lbracket'>[</span><span class='id identifier rubyid_msg'>msg</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_without_prompt'>without_prompt</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='label'>prefix:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span><span class='lbracket'>[</span><span class='id identifier rubyid_msg'>msg</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>true</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_warnings'>warnings</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_msg'>msg</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span><span class='lbracket'>[</span><span class='id identifier rubyid_msg'>msg</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_without_prompt'>without_prompt</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_print_warning'>print_warning</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='label'>prefix:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span><span class='lbracket'>[</span><span class='id identifier rubyid_msg'>msg</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>true</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_infos'>infos</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_msg'>msg</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_msg'>msg</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span><span class='lbracket'>[</span><span class='id identifier rubyid_msg'>msg</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span>
<span class='comment'># Make prefix an empty string to avoid adding clutter (timestamps, rhost, rport, etc.) to the output
</span> <span class='id identifier rubyid_without_prompt'>without_prompt</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_print_status'>print_status</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span><span class='comma'>,</span> <span class='label'>prefix:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_you_have_been_warned'>you_have_been_warned</span><span class='lbracket'>[</span><span class='id identifier rubyid_msg'>msg</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>true</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="errors-instance_method">
#<strong>errors</strong> &#x21d2; <tt>Array&lt;String&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a list of error strings to show the user.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>a list of error strings to show the user</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
195
196
197</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 195</span>
<span class='kw'>def</span> <span class='id identifier rubyid_errors'>errors</span>
<span class='id identifier rubyid_get_alerts'>get_alerts</span><span class='lparen'>(</span><span class='symbol'>:error</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="get_alerts-instance_method">
#<strong>get_alerts</strong>(level) &#x21d2; <tt>Array&lt;String&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Similar to <span class='object_link'><a href="Alert/ClassMethods.html#get_alerts-instance_method" title="Msf::Module::Alert::ClassMethods#get_alerts (method)">Msf::Module::Alert::ClassMethods#get_alerts</a></span>, but executes each registered block in the context of this module instance and returns a flattened list of strings. (see <span class='object_link'><a href="Alert/ClassMethods.html#get_alerts-instance_method" title="Msf::Module::Alert::ClassMethods#get_alerts (method)">Msf::Module::Alert::ClassMethods#get_alerts</a></span>)</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>level</span>
<span class='type'>(<tt>Symbol</tt>)</span>
&mdash;
<div class='inline'>
<p>The alert level to return</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
209
210
211
212
213
214
215
216
217
218
219
220
221</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 209</span>
<span class='kw'>def</span> <span class='id identifier rubyid_get_alerts'>get_alerts</span><span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span><span class='rparen'>)</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span><span class='lbracket'>[</span><span class='id identifier rubyid_level'>level</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_all_alerts'>all_alerts</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_get_alerts'>get_alerts</span><span class='lparen'>(</span><span class='id identifier rubyid_level'>level</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alerts'>alerts</span><span class='lbracket'>[</span><span class='id identifier rubyid_level'>level</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_all_alerts'>all_alerts</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_alert'>alert</span><span class='op'>|</span>
<span class='kw'>case</span> <span class='id identifier rubyid_alert'>alert</span>
<span class='kw'>when</span> <span class='const'>Proc</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance_exec'>instance_exec</span> <span class='op'>&amp;</span><span class='id identifier rubyid_alert'>alert</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_alert'>alert</span>
<span class='kw'>end</span>
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="infos-instance_method">
#<strong>infos</strong> &#x21d2; <tt>Array&lt;String&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a list of info strings to show the user.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>a list of info strings to show the user</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
200
201
202</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 200</span>
<span class='kw'>def</span> <span class='id identifier rubyid_infos'>infos</span>
<span class='id identifier rubyid_get_alerts'>get_alerts</span><span class='lparen'>(</span><span class='symbol'>:info</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="is_usable?-instance_method">
#<strong>is_usable?</strong> &#x21d2; <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>This method allows modules to tell the framework if they are usable on the system that they are being loaded on in a generic fashion. By default, all modules are indicated as being usable. An example of where this is useful is if the module depends on something external to ruby, such as a binary.</p>
<p>This looks to have been abandoned at some point in the past, but it may be time to resurrect it.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
&mdash;
<div class='inline'>
<p>whether or not the module has encountered any fatal errors thus far.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
185
186
187</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 185</span>
<span class='kw'>def</span> <span class='id identifier rubyid_is_usable?'>is_usable?</span>
<span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="warnings-instance_method">
#<strong>warnings</strong> &#x21d2; <tt>Array&lt;String&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a list of warning strings to show the user.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>a list of warning strings to show the user</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
190
191
192</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 190</span>
<span class='kw'>def</span> <span class='id identifier rubyid_warnings'>warnings</span>
<span class='id identifier rubyid_get_alerts'>get_alerts</span><span class='lparen'>(</span><span class='symbol'>:warning</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="without_prompt-instance_method">
#<strong>without_prompt</strong>(&amp;block) &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Temporarily set the prompt mode to false to ensure that there are not additional lines printed A workaround for the prompting bug spotted in <a href="https://github.com/rapid7/metasploit-framework/pull/18761#issuecomment-1916645095">github.com/rapid7/metasploit-framework/pull/18761#issuecomment-1916645095</a></p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/module/alert.rb', line 270</span>
<span class='kw'>def</span> <span class='id identifier rubyid_without_prompt'>without_prompt</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='comment'># Some user outputs cannot have their prompting value configured, i.e. WebConsolePipe
</span> <span class='kw'>return</span> <span class='kw'>yield</span> <span class='kw'>unless</span> <span class='id identifier rubyid_user_output'>user_output</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:prompting</span><span class='rparen'>)</span>
<span class='kw'>begin</span>
<span class='kw'>if</span> <span class='id identifier rubyid_user_output'>user_output</span>
<span class='id identifier rubyid_previous_prompting_value'>previous_prompting_value</span> <span class='op'>=</span> <span class='id identifier rubyid_user_output'>user_output</span><span class='period'>.</span><span class='id identifier rubyid_prompting?'>prompting?</span>
<span class='id identifier rubyid_user_output'>user_output</span><span class='period'>.</span><span class='id identifier rubyid_prompting'>prompting</span><span class='lparen'>(</span><span class='kw'>false</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>yield</span>
<span class='kw'>ensure</span>
<span class='id identifier rubyid_user_output'>user_output</span><span class='period'>.</span><span class='id identifier rubyid_prompting'>prompting</span><span class='lparen'>(</span><span class='id identifier rubyid_previous_prompting_value'>previous_prompting_value</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_user_output'>user_output</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:01:05 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>