755 lines
32 KiB
HTML
755 lines
32 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>
|
||
Module: Msf::Exploit::Brute
|
||
|
||
— 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::Brute";
|
||
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 (B)</a> »
|
||
<span class='title'><span class='object_link'><a href="../../Msf.html" title="Msf (module)">Msf</a></span></span> » <span class='title'><span class='object_link'><a href="../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span>
|
||
»
|
||
<span class="title">Brute</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::Brute
|
||
|
||
|
||
|
||
</h1>
|
||
<div class="box_info">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<dl>
|
||
<dt>Defined in:</dt>
|
||
<dd>lib/msf/core/exploit/brute.rb</dd>
|
||
</dl>
|
||
|
||
</div>
|
||
|
||
<h2>Overview</h2><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>This modules provides a target-aware brute-forcing wrapper. It implements the exploit method and calls exploit_brute with target supplied information. If the selected target is not a bruteforce target, then single_exploit is called.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</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="#brute_exploit-instance_method" title="#brute_exploit (instance method)">#<strong>brute_exploit</strong>(addrs) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>This routine is called once per brute force iteration.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#brute_wait-instance_method" title="#brute_wait (instance method)">#<strong>brute_wait</strong>(delay) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Waits for the provide delay.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#exploit-instance_method" title="#exploit (instance method)">#<strong>exploit</strong> ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Entry point for initiating an exploit.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#import_from_datastore-instance_method" title="#import_from_datastore (instance method)">#<strong>import_from_datastore</strong>(hash, prefix = '') ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Imports information into the supplied hash from the datastore.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(info = {}) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Initializes an instance of an exploit module that supports brute force targets.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#single_exploit-instance_method" title="#single_exploit (instance method)">#<strong>single_exploit</strong> ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Call if the target is not a brute force target.</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="brute_exploit-instance_method">
|
||
|
||
#<strong>brute_exploit</strong>(addrs) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>This routine is called once per brute force iteration. The addresses parameter is a hash of addresses that are incremented each iteration and are derived from the target’s bruteforce information or the module’s datastore in case they are being overridden.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
152
|
||
153</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/brute.rb', line 152</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_brute_exploit'>brute_exploit</span><span class='lparen'>(</span><span class='id identifier rubyid_addrs'>addrs</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="brute_wait-instance_method">
|
||
|
||
#<strong>brute_wait</strong>(delay) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Waits for the provide delay.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
164
|
||
165
|
||
166</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/brute.rb', line 164</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_brute_wait'>brute_wait</span><span class='lparen'>(</span><span class='id identifier rubyid_delay'>delay</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='id identifier rubyid_delay'>delay</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="exploit-instance_method">
|
||
|
||
#<strong>exploit</strong> ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Entry point for initiating an exploit. This module wrappers the exploit method and determines whether or not the selected target supports brute force. If it does, it does some special things and wraps the brute forcing logic.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
38
|
||
39
|
||
40
|
||
41
|
||
42
|
||
43
|
||
44
|
||
45
|
||
46
|
||
47
|
||
48
|
||
49
|
||
50
|
||
51
|
||
52
|
||
53
|
||
54
|
||
55
|
||
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
|
||
85
|
||
86
|
||
87
|
||
88
|
||
89
|
||
90
|
||
91
|
||
92
|
||
93
|
||
94
|
||
95
|
||
96
|
||
97
|
||
98
|
||
99
|
||
100
|
||
101
|
||
102
|
||
103
|
||
104
|
||
105
|
||
106
|
||
107
|
||
108
|
||
109
|
||
110
|
||
111
|
||
112
|
||
113
|
||
114
|
||
115
|
||
116
|
||
117
|
||
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</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/brute.rb', line 38</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_exploit'>exploit</span>
|
||
<span class='comment'># Is the selected target a brute force target?
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_bruteforce?'>bruteforce?</span><span class='rparen'>)</span>
|
||
<span class='comment'># The step direction is automatically calculated
|
||
</span> <span class='id identifier rubyid_direction'>direction</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
||
|
||
<span class='id identifier rubyid_bf'>bf</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_bruteforce'>bruteforce</span>
|
||
|
||
<span class='comment'># Get the start and stop address hashes
|
||
</span> <span class='id identifier rubyid_start'>start</span> <span class='op'>=</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_start_addresses'>start_addresses</span> <span class='op'>?</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_start_addresses'>start_addresses</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
||
<span class='id identifier rubyid_stop'>stop</span> <span class='op'>=</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_stop_addresses'>stop_addresses</span> <span class='op'>?</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_stop_addresses'>stop_addresses</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
||
<span class='id identifier rubyid_step'>step</span> <span class='op'>=</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_step_size'>step_size</span>
|
||
<span class='id identifier rubyid_delay'>delay</span> <span class='op'>=</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_delay'>delay</span>
|
||
|
||
<span class='comment'># Enumerate each start address and try to figure out the direction
|
||
</span> <span class='id identifier rubyid_start'>start</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_addr'>addr</span><span class='op'>|</span>
|
||
<span class='comment'># If there's a stop address, figure out if it's above or below
|
||
</span> <span class='comment'># the start address
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_stop'>stop</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_stop'>stop</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'><</span> <span class='id identifier rubyid_addr'>addr</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_direction'>direction</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
|
||
<span class='kw'>else</span>
|
||
<span class='id identifier rubyid_direction'>direction</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='int'>1</span>
|
||
<span class='kw'>end</span>
|
||
<span class='comment'># If there's no stop address, infer the direction based on
|
||
</span> <span class='comment'># the default
|
||
</span> <span class='kw'>else</span>
|
||
<span class='id identifier rubyid_direction'>direction</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_bf'>bf</span><span class='period'>.</span><span class='id identifier rubyid_default_direction'>default_direction</span>
|
||
<span class='kw'>end</span>
|
||
<span class='rbrace'>}</span>
|
||
|
||
<span class='comment'># Import start/stop address overrides from the datastore
|
||
</span> <span class='id identifier rubyid_import_from_datastore'>import_from_datastore</span><span class='lparen'>(</span><span class='id identifier rubyid_start'>start</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Start</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_import_from_datastore'>import_from_datastore</span><span class='lparen'>(</span><span class='id identifier rubyid_stop'>stop</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stop</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># User-defined brute wait?
|
||
</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteWait</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='kw'>and</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteWait</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>></span> <span class='int'>0</span>
|
||
<span class='id identifier rubyid_delay'>delay</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteWait</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># User-defined brute step?
|
||
</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteStep</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='kw'>and</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteStep</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>></span> <span class='int'>0</span>
|
||
<span class='id identifier rubyid_step'>step</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteStep</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># Sane defaults
|
||
</span> <span class='id identifier rubyid_delay'>delay</span> <span class='op'>=</span> <span class='int'>1</span> <span class='kw'>if</span> <span class='id identifier rubyid_delay'>delay</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>or</span> <span class='id identifier rubyid_delay'>delay</span> <span class='op'>==</span> <span class='int'>0</span>
|
||
|
||
<span class='comment'># Okay, we've got all this crap out of the way, let's actually brute
|
||
</span> <span class='comment'># force
|
||
</span> <span class='id identifier rubyid_stopped'>stopped</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
||
<span class='id identifier rubyid_curr'>curr</span> <span class='op'>=</span> <span class='id identifier rubyid_start'>start</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
|
||
|
||
<span class='comment'># Automatically determine the step size based off the nop sled length
|
||
</span> <span class='kw'>if</span> <span class='id identifier rubyid_step'>step</span> <span class='op'>==</span> <span class='int'>0</span>
|
||
<span class='id identifier rubyid_step'>step</span> <span class='op'>=</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_nop_sled_size'>nop_sled_size</span>
|
||
|
||
<span class='kw'>if</span> <span class='id identifier rubyid_step'>step</span> <span class='op'>==</span> <span class='int'>0</span>
|
||
<span class='id identifier rubyid_raise'>raise</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="../OptionValidateError.html" title="Msf::OptionValidateError (class)">OptionValidateError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../OptionValidateError.html#initialize-instance_method" title="Msf::OptionValidateError#initialize (method)">new</a></span></span><span class='lparen'>(</span>
|
||
<span class='lbrace'>{</span>
|
||
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteStep</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>The step size for this exploit is invalid</span><span class='tstring_end'>'</span></span>
|
||
<span class='rbrace'>}</span>
|
||
<span class='rparen'>)</span>
|
||
<span class='kw'>end</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># Keep going until we run out of options
|
||
</span> <span class='kw'>while</span> <span class='lparen'>(</span><span class='id identifier rubyid_curr'>curr</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>!=</span> <span class='id identifier rubyid_stopped'>stopped</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Stop brute forcing once a session is found
|
||
</span> <span class='kw'>break</span> <span class='kw'>if</span> <span class='id identifier rubyid_session_created?'>session_created?</span>
|
||
|
||
<span class='comment'># Fire off an exploit attempt with the supplied addresses
|
||
</span> <span class='id identifier rubyid_brute_exploit'>brute_exploit</span><span class='lparen'>(</span><span class='id identifier rubyid_curr'>curr</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Give it time before we try again
|
||
</span> <span class='id identifier rubyid_brute_wait'>brute_wait</span><span class='lparen'>(</span><span class='id identifier rubyid_delay'>delay</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Scan each current key, increasing it or decreasing it by the
|
||
</span> <span class='comment'># step size according to its direction
|
||
</span> <span class='id identifier rubyid_curr'>curr</span><span class='period'>.</span><span class='id identifier rubyid_each_key'>each_key</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span>
|
||
|
||
<span class='comment'># Has movement been stopped on this address? If so, skip it.
|
||
</span> <span class='kw'>next</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_stopped'>stopped</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_k'>k</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Calculate the next address before we move it to see if
|
||
</span> <span class='comment'># we're going to go over
|
||
</span> <span class='id identifier rubyid_next_addr'>next_addr</span> <span class='op'>=</span> <span class='id identifier rubyid_step'>step</span> <span class='op'>*</span> <span class='id identifier rubyid_direction'>direction</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span>
|
||
|
||
<span class='comment'># If this item has hit a stop address, add it to the stopped
|
||
</span> <span class='comment'># hash and move it no further
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_stop'>stop</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='kw'>if</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_direction'>direction</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='int'>1</span> <span class='kw'>and</span> <span class='id identifier rubyid_curr'>curr</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='id identifier rubyid_next_addr'>next_addr</span> <span class='op'>>=</span> <span class='id identifier rubyid_stop'>stop</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>or</span>
|
||
<span class='lparen'>(</span><span class='id identifier rubyid_direction'>direction</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='op'>-</span><span class='int'>1</span> <span class='kw'>and</span> <span class='id identifier rubyid_curr'>curr</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='id identifier rubyid_next_addr'>next_addr</span> <span class='op'><</span> <span class='id identifier rubyid_stop'>stop</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_stopped'>stopped</span> <span class='op'><<</span> <span class='id identifier rubyid_k'>k</span>
|
||
<span class='kw'>next</span>
|
||
<span class='kw'>end</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># If it's not time to stop, move it
|
||
</span> <span class='id identifier rubyid_curr'>curr</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>+=</span> <span class='id identifier rubyid_next_addr'>next_addr</span>
|
||
<span class='rbrace'>}</span>
|
||
<span class='kw'>end</span>
|
||
<span class='kw'>else</span>
|
||
<span class='id identifier rubyid_single_exploit'>single_exploit</span>
|
||
<span class='kw'>end</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="import_from_datastore-instance_method">
|
||
|
||
#<strong>import_from_datastore</strong>(hash, prefix = '') ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Imports information into the supplied hash from the datastore. This is a way of allowing the user to override values for a specific brute force target by name without them actually being conveyed in the options list. This is a bit of a change from 2.x, but 2.x didn’t have per-target brute force addresses, which I think is more valuable.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
178
|
||
179
|
||
180
|
||
181
|
||
182
|
||
183
|
||
184</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/brute.rb', line 178</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_import_from_datastore'>import_from_datastore</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_each_key'>each_key</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span>
|
||
<span class='kw'>if</span> <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>+</span> <span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='lbracket'>[</span><span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>+</span> <span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span>
|
||
<span class='kw'>end</span>
|
||
<span class='rbrace'>}</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="initialize-instance_method">
|
||
|
||
#<strong>initialize</strong>(info = {}) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Initializes an instance of an exploit module that supports brute force targets.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
18
|
||
19
|
||
20
|
||
21
|
||
22
|
||
23
|
||
24
|
||
25
|
||
26
|
||
27
|
||
28
|
||
29
|
||
30</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/brute.rb', line 18</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
||
<span class='kw'>super</span>
|
||
|
||
<span class='comment'>#
|
||
</span> <span class='comment'># Register BruteWait and BruteStep as two advanced options for this
|
||
</span> <span class='comment'># exploit even though not all targets may be brute force targets.
|
||
</span> <span class='comment'>#
|
||
</span> <span class='id identifier rubyid_register_advanced_options'>register_advanced_options</span><span class='lparen'>(</span>
|
||
<span class='lbracket'>[</span>
|
||
<span class='const'><span class='object_link'><a href="../OptInt.html" title="Msf::OptInt (class)">OptInt</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../OptBase.html#initialize-instance_method" title="Msf::OptBase#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteWait</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Delay between brute force attempts</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span>
|
||
<span class='const'><span class='object_link'><a href="../OptInt.html" title="Msf::OptInt (class)">OptInt</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../OptBase.html#initialize-instance_method" title="Msf::OptBase#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BruteStep</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='lbracket'>[</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Step size between brute force attempts</span><span class='tstring_end'>"</span></span> <span class='rbracket'>]</span><span class='rparen'>)</span>
|
||
<span class='rbracket'>]</span><span class='comma'>,</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="../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Msf::Exploit::Brute (module)">Brute</a></span></span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="single_exploit-instance_method">
|
||
|
||
#<strong>single_exploit</strong> ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Call if the target is not a brute force target.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
158
|
||
159</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/brute.rb', line 158</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_single_exploit'>single_exploit</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div id="footer">
|
||
Generated on Fri May 8 17:01:06 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> |