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

1015 lines
32 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::Exploit::AutoTarget
&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::Exploit::AutoTarget";
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="../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span>
&raquo;
<span class="title">AutoTarget</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::Exploit::AutoTarget
</h1>
<div class="box_info">
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="Remote.html" title="Msf::Exploit::Remote (class)">Remote</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/exploit/auto_target.rb</dd>
</dl>
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#auto_target%3F-instance_method" title="#auto_target? (instance method)">#<strong>auto_target?</strong> &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Checks to see if the auto-generated Automatic Targeting has been selected.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#auto_target_host-instance_method" title="#auto_target_host (instance method)">#<strong>auto_target_host</strong> &#x21d2; Mdm:Host<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Finds an &lt;Mdm::Host&gt; for the RHOST if one exists.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#auto_targeted_index-instance_method" title="#auto_targeted_index (instance method)">#<strong>auto_targeted_index</strong>(host = auto_target_host) &#x21d2; Integer<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the Target Index of the automatically selected Target from our Automatic Targeting routine.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#filter_by_os-instance_method" title="#filter_by_os (instance method)">#<strong>filter_by_os</strong>(host_record) &#x21d2; Array&lt;Msf::Module::Target&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the best matching Targets based on the target hosts OS information.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#filter_by_os_family-instance_method" title="#filter_by_os_family (instance method)">#<strong>filter_by_os_family</strong>(host_record) &#x21d2; Array&lt;Msf::Module::Target&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns all Targets that match the target hosts OS Family e.g Windows, Linux, OS X, etc.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#filter_by_os_name-instance_method" title="#filter_by_os_name (instance method)">#<strong>filter_by_os_name</strong>(potential_targets, host_record) &#x21d2; Array&lt;Msf::Module::Target&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns all Targets that match the target hosts OS Name e.g Windows 7, Windows XP, Windows Vista, etc.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#filter_by_os_sp-instance_method" title="#filter_by_os_sp (instance method)">#<strong>filter_by_os_sp</strong>(potential_targets, host_record) &#x21d2; Array&lt;Msf::Module::Target&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns all Targets that match the target hosts OS SP.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#select_target-instance_method" title="#select_target (instance method)">#<strong>select_target</strong>(host = auto_target_host) &#x21d2; Msf::Module::Target </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Chooses the best possible Target for what we know about the targeted host.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="auto_target?-instance_method">
#<strong>auto_target?</strong> &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks to see if the auto-generated Automatic Targeting has been selected. If the module had an already defined Automatic target, then we let the module handle the targeting itself.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
&mdash;
<div class='inline'>
<p>whether or not to use our automatic targeting routine</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
11
12
13
14
15
16
17
18
19</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 11</span>
<span class='kw'>def</span> <span class='id identifier rubyid_auto_target?'>auto_target?</span>
<span class='id identifier rubyid_selected_target'>selected_target</span> <span class='op'>=</span> <span class='id identifier rubyid_targets'>targets</span><span class='lbracket'>[</span><span class='id identifier rubyid_target_index'>target_index</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_target_index'>target_index</span>
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id identifier rubyid_selected_target'>selected_target</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='kw'>if</span> <span class='id identifier rubyid_selected_target'>selected_target</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>Automatic</span><span class='regexp_end'>/</span></span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_selected_target'>selected_target</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>AutoGenerated</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='kw'>true</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_auto_target_host'>auto_target_host</span>
<span class='kw'>true</span>
<span class='kw'>else</span>
<span class='kw'>false</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="auto_target_host-instance_method">
#<strong>auto_target_host</strong> &#x21d2; <tt>Mdm:Host</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Finds an &lt;Mdm::Host&gt; for the RHOST if one exists</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Mdm:Host</tt>)</span>
&mdash;
<div class='inline'>
<p>the Host record if one exists</p>
</div>
</li>
<li>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>if no Host record is present, or the DB is not active</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
50
51
52
53
54
55</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 50</span>
<span class='kw'>def</span> <span class='id identifier rubyid_auto_target_host'>auto_target_host</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:rhost</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_rhost'>rhost</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_framework'>framework</span><span class='period'>.</span><span class='id identifier rubyid_db'>db</span><span class='period'>.</span><span class='id identifier rubyid_active'>active</span>
<span class='id identifier rubyid_host'>host</span> <span class='op'>=</span> <span class='id identifier rubyid_framework'>framework</span><span class='period'>.</span><span class='id identifier rubyid_db'>db</span><span class='period'>.</span><span class='id identifier rubyid_get_host'>get_host</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>workspace:</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_workspace'>workspace</span><span class='comma'>,</span> <span class='label'>address:</span> <span class='id identifier rubyid_rhost'>rhost</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='id identifier rubyid_host'>host</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="auto_targeted_index-instance_method">
#<strong>auto_targeted_index</strong>(host = auto_target_host) &#x21d2; <tt>Integer</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the Target Index of the automatically selected Target from our Automatic Targeting routine.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>)</span>
&mdash;
<div class='inline'>
<p>the index of the selected Target</p>
</div>
</li>
<li>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>if no target could be selected</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
26
27
28
29
30
31
32
33</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 26</span>
<span class='kw'>def</span> <span class='id identifier rubyid_auto_targeted_index'>auto_targeted_index</span><span class='lparen'>(</span><span class='id identifier rubyid_host'>host</span><span class='op'>=</span><span class='id identifier rubyid_auto_target_host'>auto_target_host</span><span class='rparen'>)</span>
<span class='id identifier rubyid_selected_target'>selected_target</span> <span class='op'>=</span> <span class='id identifier rubyid_select_target'>select_target</span><span class='lparen'>(</span><span class='id identifier rubyid_host'>host</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_selected_target'>selected_target</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_targets'>targets</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span>
<span class='kw'>return</span> <span class='id identifier rubyid_index'>index</span> <span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span> <span class='op'>==</span> <span class='id identifier rubyid_selected_target'>selected_target</span>
<span class='kw'>end</span>
<span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="filter_by_os-instance_method">
#<strong>filter_by_os</strong>(host_record) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the best matching Targets based on the target hosts OS information. It looks at the OS Family, OS Name, and OS SP.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>host_record</span>
<span class='type'>(<tt>Mdm::Host</tt>)</span>
&mdash;
<div class='inline'>
<p>the target host record</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>an array of matching targets</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
62
63
64
65
66
67
68
69
70
71</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 62</span>
<span class='kw'>def</span> <span class='id identifier rubyid_filter_by_os'>filter_by_os</span><span class='lparen'>(</span><span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='id identifier rubyid_filtered_by_family'>filtered_by_family</span> <span class='op'>=</span> <span class='id identifier rubyid_filter_by_os_family'>filter_by_os_family</span><span class='lparen'>(</span><span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='id identifier rubyid_filtered_by_name'>filtered_by_name</span> <span class='op'>=</span> <span class='id identifier rubyid_filter_by_os_name'>filter_by_os_name</span><span class='lparen'>(</span><span class='id identifier rubyid_filtered_by_family'>filtered_by_family</span><span class='comma'>,</span> <span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='comment'># If Filtering by name gave us no results, then we reset back to the family filter group
</span> <span class='id identifier rubyid_filtered_by_name'>filtered_by_name</span> <span class='op'>=</span> <span class='id identifier rubyid_filtered_by_family'>filtered_by_family</span> <span class='kw'>if</span> <span class='id identifier rubyid_filtered_by_name'>filtered_by_name</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_filtered_by_sp'>filtered_by_sp</span> <span class='op'>=</span> <span class='id identifier rubyid_filter_by_os_sp'>filter_by_os_sp</span><span class='lparen'>(</span><span class='id identifier rubyid_filtered_by_name'>filtered_by_name</span><span class='comma'>,</span><span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='comment'># If Filtering by SP was a bust, revert back one level
</span> <span class='id identifier rubyid_filtered_by_sp'>filtered_by_sp</span> <span class='op'>=</span> <span class='id identifier rubyid_filtered_by_name'>filtered_by_name</span> <span class='kw'>if</span> <span class='id identifier rubyid_filtered_by_sp'>filtered_by_sp</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_filtered_by_sp'>filtered_by_sp</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="filter_by_os_family-instance_method">
#<strong>filter_by_os_family</strong>(host_record) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns all Targets that match the target hosts OS Family e.g Windows, Linux, OS X, etc</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>host_record</span>
<span class='type'>(<tt>Mdm::Host</tt>)</span>
&mdash;
<div class='inline'>
<p>the target host record</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>an array of matching targets</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
78
79
80
81
82
83
84
85
86
87
88</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 78</span>
<span class='kw'>def</span> <span class='id identifier rubyid_filter_by_os_family'>filter_by_os_family</span><span class='lparen'>(</span><span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_host_record'>host_record</span><span class='period'>.</span><span class='id identifier rubyid_os_family'>os_family</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span> <span class='op'>=</span> <span class='id identifier rubyid_targets'>targets</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_target'>target</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_host_record'>host_record</span><span class='period'>.</span><span class='id identifier rubyid_os_family'>os_family</span><span class='embexpr_end'>}</span><span class='regexp_end'>/</span></span>
<span class='id identifier rubyid_target'>target</span>
<span class='kw'>else</span>
<span class='kw'>nil</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</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="filter_by_os_name-instance_method">
#<strong>filter_by_os_name</strong>(potential_targets, host_record) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns all Targets that match the target hosts OS Name e.g Windows 7, Windows XP, Windows Vista, etc</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>potential_targets</span>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>the filtered targets that we wish to filter further</p>
</div>
</li>
<li>
<span class='name'>host_record</span>
<span class='type'>(<tt>Mdm::Host</tt>)</span>
&mdash;
<div class='inline'>
<p>the target host record</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>an array of matching targets</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
96
97
98
99
100
101
102
103</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 96</span>
<span class='kw'>def</span> <span class='id identifier rubyid_filter_by_os_name'>filter_by_os_name</span><span class='lparen'>(</span><span class='id identifier rubyid_potential_targets'>potential_targets</span><span class='comma'>,</span> <span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_host_record'>host_record</span><span class='period'>.</span><span class='id identifier rubyid_os_name'>os_name</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_potential_targets'>potential_targets</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_target'>target</span><span class='op'>|</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_target'>target</span> <span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_host_record'>host_record</span><span class='period'>.</span><span class='id identifier rubyid_os_name'>os_name</span><span class='embexpr_end'>}</span><span class='regexp_end'>/</span></span>
<span class='kw'>end</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="filter_by_os_sp-instance_method">
#<strong>filter_by_os_sp</strong>(potential_targets, host_record) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns all Targets that match the target hosts OS SP</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>potential_targets</span>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>the filtered targets that we wish to filter further</p>
</div>
</li>
<li>
<span class='name'>host_record</span>
<span class='type'>(<tt>Mdm::Host</tt>)</span>
&mdash;
<div class='inline'>
<p>the target host record</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span>&gt;</tt>)</span>
&mdash;
<div class='inline'>
<p>an array of matching targets</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
110
111
112
113
114
115
116
117</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 110</span>
<span class='kw'>def</span> <span class='id identifier rubyid_filter_by_os_sp'>filter_by_os_sp</span><span class='lparen'>(</span><span class='id identifier rubyid_potential_targets'>potential_targets</span><span class='comma'>,</span> <span class='id identifier rubyid_host_record'>host_record</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_host_record'>host_record</span><span class='period'>.</span><span class='id identifier rubyid_os_sp'>os_sp</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_potential_targets'>potential_targets</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_target'>target</span><span class='op'>|</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_target'>target</span> <span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_host_record'>host_record</span><span class='period'>.</span><span class='id identifier rubyid_os_sp'>os_sp</span><span class='embexpr_end'>}</span><span class='regexp_end'>/</span></span>
<span class='kw'>end</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="select_target-instance_method">
#<strong>select_target</strong>(host = auto_target_host) &#x21d2; <tt><span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Chooses the best possible Target for what we know about the targeted host.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="../Module/Target.html" title="Msf::Module::Target (class)">Msf::Module::Target</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>the Target that our automatic routine selected</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
39
40
41
42
43
44</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/auto_target.rb', line 39</span>
<span class='kw'>def</span> <span class='id identifier rubyid_select_target'>select_target</span><span class='lparen'>(</span><span class='id identifier rubyid_host'>host</span><span class='op'>=</span><span class='id identifier rubyid_auto_target_host'>auto_target_host</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_auto_target?'>auto_target?</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span> <span class='op'>=</span> <span class='id identifier rubyid_filter_by_os'>filter_by_os</span><span class='lparen'>(</span><span class='id identifier rubyid_host'>host</span><span class='rparen'>)</span>
<span class='id identifier rubyid_filtered_targets'>filtered_targets</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:01:28 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>