Files
metasploit-gs/api/Metasploit/Framework/CommunityStringCollection.html
T
jenkins-metasploit c3f5bd3de2 Reboot gh-pages
2026-05-08 17:08:43 +00:00

847 lines
24 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: Metasploit::Framework::CommunityStringCollection
&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 = "Metasploit::Framework::CommunityStringCollection";
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 (C)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Metasploit.html" title="Metasploit (module)">Metasploit</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Framework.html" title="Metasploit::Framework (module)">Framework</a></span></span>
&raquo;
<span class="title">CommunityStringCollection</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: Metasploit::Framework::CommunityStringCollection
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">Metasploit::Framework::CommunityStringCollection</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/metasploit/framework/community_string_collection.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>This class is responsible for taking datastore options from the snmp_login module and yielding appropriate <span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span>s to the <span class='object_link'><a href="LoginScanner/SNMP.html" title="Metasploit::Framework::LoginScanner::SNMP (class)">LoginScanner::SNMP</a></span>. This one has to be different from credentialCollection as it will only have a <span class='object_link'><a href="Credential.html#public-instance_method" title="Metasploit::Framework::Credential#public (method)">Metasploit::Framework::Credential#public</a></span> It may be slightly confusing that the attributes are called password and pass_file, because this is what the legacy module used. However, community Strings are now considered more to be public credentials than private ones.</p>
</div>
</div>
<div class="tags">
</div>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#pass_file-instance_method" title="#pass_file (instance method)">#<strong>pass_file</strong> &#x21d2; String </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Path to a file containing passwords, one per line.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#password-instance_method" title="#password (instance method)">#<strong>password</strong> &#x21d2; String </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#prepended_creds-instance_method" title="#prepended_creds (instance method)">#<strong>prepended_creds</strong> &#x21d2; Array&lt;Credential&gt; </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>List of credentials to be tried before any others.</p>
</div></span>
</li>
</ul>
<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="#each-instance_method" title="#each (instance method)">#<strong>each</strong> {|credential| ... } &#x21d2; void </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Combines all the provided credential sources into a stream of <span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span> objects, yielding them one at a time.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#empty%3F-instance_method" title="#empty? (instance method)">#<strong>empty?</strong> &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(opts = {}) &#x21d2; CommunityStringCollection </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'>
<p>A new instance of CommunityStringCollection.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#prepend_cred-instance_method" title="#prepend_cred (instance method)">#<strong>prepend_cred</strong>(cred) &#x21d2; self </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Add <span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">credentials</a></span> that will be yielded by <span class='object_link'><a href="#each-instance_method" title="Metasploit::Framework::CommunityStringCollection#each (method)">#each</a></span>.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(opts = {}) &#x21d2; <tt><span class='object_link'><a href="" title="Metasploit::Framework::CommunityStringCollection (class)">CommunityStringCollection</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of CommunityStringCollection.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<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>a customizable set of options</p>
</div>
</li>
</ul>
<p class="tag_title">Options Hash (<tt>opts</tt>):</p>
<ul class="option">
<li>
<span class="name">:pass_file</span>
<span class="type">(<tt>String</tt>)</span>
<span class="default">
</span>
&mdash; <div class='inline'>
<p>See <span class='object_link'><a href="#pass_file-instance_method" title="Metasploit::Framework::CommunityStringCollection#pass_file (method)">#pass_file</a></span></p>
</div>
</li>
<li>
<span class="name">:password</span>
<span class="type">(<tt>String</tt>)</span>
<span class="default">
</span>
&mdash; <div class='inline'>
<p>See <span class='object_link'><a href="#password-instance_method" title="Metasploit::Framework::CommunityStringCollection#password (method)">#password</a></span></p>
</div>
</li>
<li>
<span class="name">:prepended_creds</span>
<span class="type">(<tt>Array&lt;<span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span>&gt;</tt>)</span>
<span class="default">
&mdash; default:
<tt>[]</tt>
</span>
&mdash; <div class='inline'>
<p>See <span class='object_link'><a href="#prepended_creds-instance_method" title="Metasploit::Framework::CommunityStringCollection#prepended_creds (method)">#prepended_creds</a></span></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
31
32
33
34
35
36</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 31</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</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_opts'>opts</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_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
<span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute'>attribute</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_prepended_creds'>prepended_creds</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id="pass_file=-instance_method"></span>
<div class="method_details first">
<h3 class="signature first" id="pass_file-instance_method">
#<strong>pass_file</strong> &#x21d2; <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Path to a file containing passwords, one per line</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
15
16
17</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 15</span>
<span class='kw'>def</span> <span class='id identifier rubyid_pass_file'>pass_file</span>
<span class='ivar'>@pass_file</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="password=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="password-instance_method">
#<strong>password</strong> &#x21d2; <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
19
20
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 19</span>
<span class='kw'>def</span> <span class='id identifier rubyid_password'>password</span>
<span class='ivar'>@password</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id="prepended_creds=-instance_method"></span>
<div class="method_details ">
<h3 class="signature " id="prepended_creds-instance_method">
#<strong>prepended_creds</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span>&gt;</tt>
</h3><div class="docstring">
<div class="discussion">
<p>List of credentials to be tried before any others</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span>&gt;</tt>)</span>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><span class='object_link'><a href="#prepend_cred-instance_method" title="Metasploit::Framework::CommunityStringCollection#prepend_cred (method)">#prepend_cred</a></span></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
26
27
28</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 26</span>
<span class='kw'>def</span> <span class='id identifier rubyid_prepended_creds'>prepended_creds</span>
<span class='ivar'>@prepended_creds</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="each-instance_method">
#<strong>each</strong> {|credential| ... } &#x21d2; <tt>void</tt>
</h3><div class="docstring">
<div class="discussion">
<p class="note returns_void">This method returns an undefined value.</p>
<p>Combines all the provided credential sources into a stream of <span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Metasploit::Framework::Credential</a></span> objects, yielding them one at a time</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Yield Parameters:</p>
<ul class="yieldparam">
<li>
<span class='name'>credential</span>
<span class='type'>(<tt><span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Metasploit::Framework::Credential</a></span></tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 43</span>
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span>
<span class='kw'>begin</span>
<span class='kw'>if</span> <span class='id identifier rubyid_pass_file'>pass_file</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
<span class='id identifier rubyid_pass_fd'>pass_fd</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_pass_file'>pass_file</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>r:binary</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_pass_fd'>pass_fd</span><span class='period'>.</span><span class='id identifier rubyid_each_line'>each_line</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
<span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_chomp!'>chomp!</span>
<span class='kw'>yield</span> <span class='const'><span class='object_link'><a href="../../Metasploit.html" title="Metasploit (module)">Metasploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Framework.html" title="Metasploit::Framework (module)">Framework</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Credential.html#initialize-instance_method" title="Metasploit::Framework::Credential#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>public:</span> <span class='id identifier rubyid_line'>line</span><span class='comma'>,</span> <span class='label'>paired:</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>if</span> <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
<span class='kw'>yield</span> <span class='const'><span class='object_link'><a href="../../Metasploit.html" title="Metasploit (module)">Metasploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Framework.html" title="Metasploit::Framework (module)">Framework</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Credential.html#initialize-instance_method" title="Metasploit::Framework::Credential#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>public:</span> <span class='id identifier rubyid_password'>password</span><span class='comma'>,</span> <span class='label'>paired:</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>ensure</span>
<span class='id identifier rubyid_pass_fd'>pass_fd</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span> <span class='kw'>if</span> <span class='id identifier rubyid_pass_fd'>pass_fd</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_pass_fd'>pass_fd</span><span class='period'>.</span><span class='id identifier rubyid_closed?'>closed?</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="empty?-instance_method">
#<strong>empty?</strong> &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
62
63
64</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 62</span>
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_prepended_creds'>prepended_creds</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_pass_file'>pass_file</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="prepend_cred-instance_method">
#<strong>prepend_cred</strong>(cred) &#x21d2; <tt>self</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Add <span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">credentials</a></span> that will be yielded by <span class='object_link'><a href="#each-instance_method" title="Metasploit::Framework::CommunityStringCollection#each (method)">#each</a></span></p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>cred</span>
<span class='type'>(<tt><span class='object_link'><a href="Credential.html" title="Metasploit::Framework::Credential (class)">Credential</a></span></tt>)</span>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>self</tt>)</span>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><span class='object_link'><a href="#prepended_creds-instance_method" title="Metasploit::Framework::CommunityStringCollection#prepended_creds (method)">#prepended_creds</a></span></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
71
72
73
74</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/metasploit/framework/community_string_collection.rb', line 71</span>
<span class='kw'>def</span> <span class='id identifier rubyid_prepend_cred'>prepend_cred</span><span class='lparen'>(</span><span class='id identifier rubyid_cred'>cred</span><span class='rparen'>)</span>
<span class='id identifier rubyid_prepended_creds'>prepended_creds</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span> <span class='id identifier rubyid_cred'>cred</span>
<span class='kw'>self</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:04:03 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>