1620 lines
54 KiB
HTML
1620 lines
54 KiB
HTML
|
|
<!DOCTYPE html>
|
|||
|
|
<html>
|
|||
|
|
<head>
|
|||
|
|
<meta charset="utf-8">
|
|||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|||
|
|
<title>
|
|||
|
|
Class: Msf::ExploitDriver
|
|||
|
|
|
|||
|
|
— 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::ExploitDriver";
|
|||
|
|
relpath = '../';
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|||
|
|
|
|||
|
|
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</head>
|
|||
|
|
<body>
|
|||
|
|
<div class="nav_wrap">
|
|||
|
|
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|||
|
|
<div id="resizer"></div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div id="main" tabindex="-1">
|
|||
|
|
<div id="header">
|
|||
|
|
<div id="menu">
|
|||
|
|
|
|||
|
|
<a href="../_index.html">Index (E)</a> »
|
|||
|
|
<span class='title'><span class='object_link'><a href="../Msf.html" title="Msf (module)">Msf</a></span></span>
|
|||
|
|
»
|
|||
|
|
<span class="title">ExploitDriver</span>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div id="search">
|
|||
|
|
|
|||
|
|
<a class="full_list_link" id="class_list_link"
|
|||
|
|
href="../class_list.html">
|
|||
|
|
|
|||
|
|
<svg width="24" height="24">
|
|||
|
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|||
|
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|||
|
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|||
|
|
</svg>
|
|||
|
|
</a>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
<div class="clear"></div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div id="content"><h1>Class: Msf::ExploitDriver
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h1>
|
|||
|
|
<div class="box_info">
|
|||
|
|
|
|||
|
|
<dl>
|
|||
|
|
<dt>Inherits:</dt>
|
|||
|
|
<dd>
|
|||
|
|
<span class="inheritName">Object</span>
|
|||
|
|
|
|||
|
|
<ul class="fullTree">
|
|||
|
|
<li>Object</li>
|
|||
|
|
|
|||
|
|
<li class="next">Msf::ExploitDriver</li>
|
|||
|
|
|
|||
|
|
</ul>
|
|||
|
|
<a href="#" class="inheritanceTree">show all</a>
|
|||
|
|
|
|||
|
|
</dd>
|
|||
|
|
</dl>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<dl>
|
|||
|
|
<dt>Defined in:</dt>
|
|||
|
|
<dd>lib/msf/core/exploit_driver.rb</dd>
|
|||
|
|
</dl>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<h2>Overview</h2><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>This class drives the exploitation process from start to finish for a given exploit module instance. It’s responsible for payload generation, encoding, and padding as well as initialization handlers and finally launching the exploit.</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="#exploit-instance_method" title="#exploit (instance method)">#<strong>exploit</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>:nodoc:.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#force_wait_for_session-instance_method" title="#force_wait_for_session (instance method)">#<strong>force_wait_for_session</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>:nodoc:.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#job_id-instance_method" title="#job_id (instance method)">#<strong>job_id</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>The identifier of the job this exploit is launched as, if it’s run as a job.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#keep_handler-instance_method" title="#keep_handler (instance method)">#<strong>keep_handler</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>:nodoc:.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#payload-instance_method" title="#payload (instance method)">#<strong>payload</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>:nodoc:.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#semaphore-instance_method" title="#semaphore (instance method)">#<strong>semaphore</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>To synchronize threads cleaning up the exploit and the handler.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#session-instance_method" title="#session (instance method)">#<strong>session</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>:nodoc:.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#use_job-instance_method" title="#use_job (instance method)">#<strong>use_job</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>:nodoc:.</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="#compatible_payload%3F-instance_method" title="#compatible_payload? (instance method)">#<strong>compatible_payload?</strong>(payload) ⇒ Boolean </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Checks to see if the supplied payload is compatible with the current exploit.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(framework) ⇒ ExploitDriver </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="note title constructor">constructor</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Initializes the exploit driver using the supplied framework instance.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="protected ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#job_cleanup_proc-instance_method" title="#job_cleanup_proc (instance method)">#<strong>job_cleanup_proc</strong>(ctx) ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="note title protected">protected</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Clean up the exploit and the handler after the job completes.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="protected ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#job_run_proc-instance_method" title="#job_run_proc (instance method)">#<strong>job_run_proc</strong>(ctx) ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="note title protected">protected</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Job run proc, sets up the exploit and kicks it off.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#run-instance_method" title="#run (instance method)">#<strong>run</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Kicks off an exploitation attempt and performs the following four major operations:.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#target_idx-instance_method" title="#target_idx (instance method)">#<strong>target_idx</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>This method returns the currently selected target index.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#target_idx=-instance_method" title="#target_idx= (instance method)">#<strong>target_idx=</strong>(target_idx) ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Specification of the exploit target index.</p>
|
|||
|
|
</div></span>
|
|||
|
|
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li class="public ">
|
|||
|
|
<span class="summary_signature">
|
|||
|
|
|
|||
|
|
<a href="#validate-instance_method" title="#validate (instance method)">#<strong>validate</strong> ⇒ Object </a>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span class="summary_desc"><div class='inline'>
|
|||
|
|
<p>Makes sure everything’s in tip-top condition prior to launching the exploit.</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>(framework) ⇒ <tt><span class='object_link'><a href="" title="Msf::ExploitDriver (class)">ExploitDriver</a></span></tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Initializes the exploit driver using the supplied framework instance.</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</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.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_framework'>framework</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_exploit'>exploit</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_use_job'>use_job</span> <span class='op'>=</span> <span class='kw'>false</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_job_id'>job_id</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_force_wait_for_session'>force_wait_for_session</span> <span class='op'>=</span> <span class='kw'>false</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_keep_handler'>keep_handler</span> <span class='op'>=</span> <span class='kw'>false</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_semaphore'>semaphore</span> <span class='op'>=</span> <span class='const'>Mutex</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</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="exploit=-instance_method"></span>
|
|||
|
|
<div class="method_details first">
|
|||
|
|
<h3 class="signature first" id="exploit-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>exploit</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>:nodoc:</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
191
|
|||
|
|
192
|
|||
|
|
193</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 191</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_exploit'>exploit</span>
|
|||
|
|
<span class='ivar'>@exploit</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="force_wait_for_session=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="force_wait_for_session-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>force_wait_for_session</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>:nodoc:</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
199
|
|||
|
|
200
|
|||
|
|
201</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 199</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_force_wait_for_session'>force_wait_for_session</span>
|
|||
|
|
<span class='ivar'>@force_wait_for_session</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="job_id=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="job_id-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>job_id</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>The identifier of the job this exploit is launched as, if it’s run as a job.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
198
|
|||
|
|
199
|
|||
|
|
200</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 198</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_job_id'>job_id</span>
|
|||
|
|
<span class='ivar'>@job_id</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="keep_handler=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="keep_handler-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>keep_handler</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>:nodoc:</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
201
|
|||
|
|
202
|
|||
|
|
203</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 201</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_keep_handler'>keep_handler</span>
|
|||
|
|
<span class='ivar'>@keep_handler</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="payload=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="payload-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>payload</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>:nodoc:</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
192
|
|||
|
|
193
|
|||
|
|
194</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 192</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_payload'>payload</span>
|
|||
|
|
<span class='ivar'>@payload</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="semaphore=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="semaphore-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>semaphore</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>To synchronize threads cleaning up the exploit and the handler</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
204
|
|||
|
|
205
|
|||
|
|
206</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 204</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_semaphore'>semaphore</span>
|
|||
|
|
<span class='ivar'>@semaphore</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="session=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="session-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>session</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>:nodoc:</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</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/exploit_driver.rb', line 200</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_session'>session</span>
|
|||
|
|
<span class='ivar'>@session</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<span id="use_job=-instance_method"></span>
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="use_job-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>use_job</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>:nodoc:</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
193
|
|||
|
|
194
|
|||
|
|
195</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 193</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_use_job'>use_job</span>
|
|||
|
|
<span class='ivar'>@use_job</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="compatible_payload?-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>compatible_payload?</strong>(payload) ⇒ <tt>Boolean</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Checks to see if the supplied payload is compatible with the current exploit. Assumes that target_idx is valid.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</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">
|
|||
|
|
|
|||
|
|
|
|||
|
|
54
|
|||
|
|
55
|
|||
|
|
56</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 54</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_compatible_payload?'>compatible_payload?</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
|
|||
|
|
<span class='op'>!</span><span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_compatible_payloads'>compatible_payloads</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_refname'>refname</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='id identifier rubyid_refname'>refname</span> <span class='op'>==</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_refname'>refname</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="job_cleanup_proc-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>job_cleanup_proc</strong>(ctx) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Clean up the exploit and the handler after the job completes.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
268
|
|||
|
|
269
|
|||
|
|
270
|
|||
|
|
271
|
|||
|
|
272
|
|||
|
|
273
|
|||
|
|
274
|
|||
|
|
275
|
|||
|
|
276
|
|||
|
|
277
|
|||
|
|
278</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 268</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_job_cleanup_proc'>job_cleanup_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='id identifier rubyid_ctx'>ctx</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Ensure that, no matter what, clean up of the handler occurs
|
|||
|
|
</span> <span class='id identifier rubyid_semaphore'>semaphore</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_stop_handler'>stop_handler</span> <span class='rbrace'>}</span>
|
|||
|
|
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_framework'>framework</span><span class='period'>.</span><span class='id identifier rubyid_events'>events</span><span class='period'>.</span><span class='id identifier rubyid_on_module_complete'>on_module_complete</span><span class='lparen'>(</span><span class='id identifier rubyid_exploit'>exploit</span><span class='rparen'>)</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Allow the exploit to cleanup after itself, that messy bugger.
|
|||
|
|
</span> <span class='id identifier rubyid_semaphore'>semaphore</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_cleanup'>cleanup</span> <span class='rbrace'>}</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="job_run_proc-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>job_run_proc</strong>(ctx) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Job run proc, sets up the exploit and kicks it off.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
211
|
|||
|
|
212
|
|||
|
|
213
|
|||
|
|
214
|
|||
|
|
215
|
|||
|
|
216
|
|||
|
|
217
|
|||
|
|
218
|
|||
|
|
219
|
|||
|
|
220
|
|||
|
|
221
|
|||
|
|
222
|
|||
|
|
223
|
|||
|
|
224
|
|||
|
|
225
|
|||
|
|
226
|
|||
|
|
227
|
|||
|
|
228
|
|||
|
|
229
|
|||
|
|
230
|
|||
|
|
231
|
|||
|
|
232
|
|||
|
|
233
|
|||
|
|
234
|
|||
|
|
235
|
|||
|
|
236
|
|||
|
|
237
|
|||
|
|
238
|
|||
|
|
239
|
|||
|
|
240
|
|||
|
|
241
|
|||
|
|
242
|
|||
|
|
243
|
|||
|
|
244
|
|||
|
|
245
|
|||
|
|
246
|
|||
|
|
247
|
|||
|
|
248
|
|||
|
|
249
|
|||
|
|
250
|
|||
|
|
251
|
|||
|
|
252
|
|||
|
|
253
|
|||
|
|
254
|
|||
|
|
255
|
|||
|
|
256
|
|||
|
|
257
|
|||
|
|
258
|
|||
|
|
259
|
|||
|
|
260
|
|||
|
|
261
|
|||
|
|
262
|
|||
|
|
263</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 211</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_job_run_proc'>job_run_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>begin</span>
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='id identifier rubyid_ctx'>ctx</span>
|
|||
|
|
<span class='comment'># Default session wait time..
|
|||
|
|
</span> <span class='id identifier rubyid_delay'>delay</span> <span class='op'>=</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_wfs_delay'>wfs_delay</span> <span class='op'>+</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_wfs_delay'>wfs_delay</span>
|
|||
|
|
<span class='id identifier rubyid_delay'>delay</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_passive?'>passive?</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Set the exploit up the bomb
|
|||
|
|
</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_setup'>setup</span>
|
|||
|
|
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_framework'>framework</span><span class='period'>.</span><span class='id identifier rubyid_events'>events</span><span class='period'>.</span><span class='id identifier rubyid_on_module_run'>on_module_run</span><span class='lparen'>(</span><span class='id identifier rubyid_exploit'>exploit</span><span class='rparen'>)</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Launch the exploit
|
|||
|
|
</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_exploit'>exploit</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Exception</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
|||
|
|
<span class='kw'>if</span> <span class='lbracket'>[</span><span class='op'>::</span><span class='const'>RuntimeError</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Interrupt</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rparen'>)</span>
|
|||
|
|
<span class='comment'># Wait for session, but don't wait long.
|
|||
|
|
</span> <span class='id identifier rubyid_delay'>delay</span> <span class='op'>=</span> <span class='float'>0.01</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='id identifier rubyid_fail_reason'>fail_reason</span> <span class='op'>=</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_handle_exception'>handle_exception</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Start bind handlers after exploit completion
|
|||
|
|
</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_start_handler'>start_handler</span> <span class='kw'>if</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_handler_bind?'>handler_bind?</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Wait the payload to acquire a session if this isn't a passive-style
|
|||
|
|
</span> <span class='comment'># exploit.
|
|||
|
|
</span> <span class='kw'>return</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_delay'>delay</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_force_wait_for_session'>force_wait_for_session</span> <span class='op'>==</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>or</span>
|
|||
|
|
<span class='lparen'>(</span><span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_passive?'>passive?</span> <span class='op'>==</span> <span class='kw'>false</span> <span class='kw'>and</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_handler_enabled?'>handler_enabled?</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>begin</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_session'>session</span> <span class='op'>=</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_wait_for_session'>wait_for_session</span><span class='lparen'>(</span><span class='id identifier rubyid_delay'>delay</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Interrupt</span><span class='comma'>,</span> <span class='const'>Timeout</span><span class='op'>::</span><span class='const'>ExitException</span>
|
|||
|
|
<span class='comment'># Don't let interrupt pass upward
|
|||
|
|
</span> <span class='comment'># We also want report a failure when the Timeout expires
|
|||
|
|
</span> <span class='kw'>end</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>return</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_session'>session</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_session'>session</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_fail_reason'>fail_reason</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Module/Failure.html" title="Msf::Module::Failure (module)">Failure</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Module/Failure.html#None-constant" title="Msf::Module::Failure::None (constant)">None</a></span></span>
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_fail_reason'>fail_reason</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Module/Failure.html" title="Msf::Module::Failure (module)">Failure</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Module/Failure.html#PayloadFailed-constant" title="Msf::Module::Failure::PayloadFailed (constant)">PayloadFailed</a></span></span>
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_fail_detail'>fail_detail</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>No session created</span><span class='tstring_end'>"</span></span>
|
|||
|
|
<span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_report_failure'>report_failure</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_fail_reason'>fail_reason</span> <span class='op'>&&</span> <span class='id identifier rubyid_fail_reason'>fail_reason</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Module/Failure.html" title="Msf::Module::Failure (module)">Failure</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Module/Failure.html#UserInterrupt-constant" title="Msf::Module::Failure::UserInterrupt (constant)">UserInterrupt</a></span></span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>Interrupt</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="run-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>run</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Kicks off an exploitation attempt and performs the following four major operations:</p>
|
|||
|
|
|
|||
|
|
<pre class="code ruby"><code class="ruby">- Generates the payload
|
|||
|
|
- Initializes & monitors the handler
|
|||
|
|
- Launches the exploit
|
|||
|
|
- Cleans up the handler
|
|||
|
|
</code></pre>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
124
|
|||
|
|
125
|
|||
|
|
126
|
|||
|
|
127
|
|||
|
|
128
|
|||
|
|
129
|
|||
|
|
130
|
|||
|
|
131
|
|||
|
|
132
|
|||
|
|
133
|
|||
|
|
134
|
|||
|
|
135
|
|||
|
|
136
|
|||
|
|
137
|
|||
|
|
138
|
|||
|
|
139
|
|||
|
|
140
|
|||
|
|
141
|
|||
|
|
142
|
|||
|
|
143
|
|||
|
|
144
|
|||
|
|
145
|
|||
|
|
146
|
|||
|
|
147
|
|||
|
|
148
|
|||
|
|
149
|
|||
|
|
150
|
|||
|
|
151
|
|||
|
|
152
|
|||
|
|
153
|
|||
|
|
154
|
|||
|
|
155
|
|||
|
|
156
|
|||
|
|
157
|
|||
|
|
158
|
|||
|
|
159
|
|||
|
|
160
|
|||
|
|
161
|
|||
|
|
162
|
|||
|
|
163
|
|||
|
|
164
|
|||
|
|
165
|
|||
|
|
166
|
|||
|
|
167
|
|||
|
|
168
|
|||
|
|
169
|
|||
|
|
170
|
|||
|
|
171
|
|||
|
|
172
|
|||
|
|
173
|
|||
|
|
174
|
|||
|
|
175
|
|||
|
|
176
|
|||
|
|
177
|
|||
|
|
178
|
|||
|
|
179
|
|||
|
|
180
|
|||
|
|
181
|
|||
|
|
182
|
|||
|
|
183
|
|||
|
|
184
|
|||
|
|
185
|
|||
|
|
186
|
|||
|
|
187
|
|||
|
|
188
|
|||
|
|
189</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 124</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
|
|||
|
|
<span class='comment'># First thing's first -- validate the state. Make sure all requirement
|
|||
|
|
</span> <span class='comment'># parameters are set, including those that are derived from the
|
|||
|
|
</span> <span class='comment'># datastore.
|
|||
|
|
</span> <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># After validation has occurred, it's time to set some values on the
|
|||
|
|
</span> <span class='comment'># exploit instance and begin preparing the payload
|
|||
|
|
</span> <span class='id identifier rubyid_exploit'>exploit</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'>TARGET</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_target_idx'>target_idx</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Default the session to nil
|
|||
|
|
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_session'>session</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Explicitly clear the module's job_id in case it was set in a previous
|
|||
|
|
</span> <span class='comment'># run
|
|||
|
|
</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_job_id'>job_id</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># If we are being instructed to run as a job then let's create that job
|
|||
|
|
</span> <span class='comment'># like a good person.
|
|||
|
|
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_use_job'>use_job</span> <span class='kw'>or</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_passive?'>passive?</span><span class='rparen'>)</span>
|
|||
|
|
<span class='comment'># Since references to the exploit and payload will hang around for
|
|||
|
|
</span> <span class='comment'># awhile in the job, make sure we copy them so further changes to
|
|||
|
|
</span> <span class='comment'># the datastore don't alter settings in existing jobs
|
|||
|
|
</span> <span class='id identifier rubyid_e'>e</span> <span class='op'>=</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_replicant'>replicant</span>
|
|||
|
|
<span class='id identifier rubyid_p'>p</span> <span class='op'>=</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_replicant'>replicant</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Assign the correct exploit instance to the payload
|
|||
|
|
</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_assoc_exploit'>assoc_exploit</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Generate the encoded version of the supplied payload for the
|
|||
|
|
</span> <span class='comment'># newly copied exploit module instance
|
|||
|
|
</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_generate_payload'>generate_payload</span><span class='lparen'>(</span><span class='id identifier rubyid_p'>p</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='lbracket'>[</span> <span class='id identifier rubyid_e'>e</span><span class='comma'>,</span> <span class='id identifier rubyid_p'>p</span> <span class='rbracket'>]</span>
|
|||
|
|
|
|||
|
|
<span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_job_id'>job_id</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_framework'>framework</span><span class='period'>.</span><span class='id identifier rubyid_jobs'>jobs</span><span class='period'>.</span><span class='id identifier rubyid_start_bg_job'>start_bg_job</span><span class='lparen'>(</span>
|
|||
|
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Exploit: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_refname'>refname</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
|||
|
|
<span class='id identifier rubyid_ctx'>ctx</span><span class='comma'>,</span>
|
|||
|
|
<span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_ctx_'>ctx_</span><span class='op'>|</span> <span class='id identifier rubyid_job_run_proc'>job_run_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx_'>ctx_</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|||
|
|
<span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_ctx_'>ctx_</span><span class='op'>|</span> <span class='id identifier rubyid_job_cleanup_proc'>job_cleanup_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx_'>ctx_</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|||
|
|
<span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_job_id'>job_id</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_job_id'>job_id</span>
|
|||
|
|
<span class='kw'>else</span>
|
|||
|
|
<span class='comment'># Generate the encoded version of the supplied payload on the
|
|||
|
|
</span> <span class='comment'># exploit module instance
|
|||
|
|
</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_generate_payload'>generate_payload</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># No need to copy since we aren't creating a job. We wait until
|
|||
|
|
</span> <span class='comment'># they're finished running to do anything else with them, so
|
|||
|
|
</span> <span class='comment'># nothing should be able to modify their datastore or other
|
|||
|
|
</span> <span class='comment'># settings until after they're done.
|
|||
|
|
</span> <span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='lbracket'>[</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span> <span class='rbracket'>]</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>begin</span>
|
|||
|
|
<span class='id identifier rubyid_job_run_proc'>job_run_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Interrupt</span>
|
|||
|
|
<span class='id identifier rubyid_job_cleanup_proc'>job_cleanup_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='gvar'>$!</span>
|
|||
|
|
<span class='kw'>ensure</span>
|
|||
|
|
<span class='comment'># For multi exploit targets.
|
|||
|
|
</span> <span class='comment'># Keep the payload handler until last target or interrupt
|
|||
|
|
</span> <span class='id identifier rubyid_job_cleanup_proc'>job_cleanup_proc</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_keep_handler'>keep_handler</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>return</span> <span class='id identifier rubyid_session'>session</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="target_idx-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>target_idx</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>This method returns the currently selected target index.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
46
|
|||
|
|
47
|
|||
|
|
48</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 46</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_target_idx'>target_idx</span>
|
|||
|
|
<span class='ivar'>@target_idx</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="target_idx=-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>target_idx=</strong>(target_idx) ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Specification of the exploit target index.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
31
|
|||
|
|
32
|
|||
|
|
33
|
|||
|
|
34
|
|||
|
|
35
|
|||
|
|
36
|
|||
|
|
37
|
|||
|
|
38
|
|||
|
|
39
|
|||
|
|
40
|
|||
|
|
41</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 31</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_target_idx='>target_idx=</span><span class='lparen'>(</span><span class='id identifier rubyid_target_idx'>target_idx</span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_target_idx'>target_idx</span><span class='rparen'>)</span>
|
|||
|
|
<span class='comment'># Make sure the target index is valid
|
|||
|
|
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_target_idx'>target_idx</span> <span class='op'>>=</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_targets'>targets</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Rex.html" title="Rex (module)">Rex</a></span></span><span class='op'>::</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Invalid target index.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Set the active target
|
|||
|
|
</span> <span class='ivar'>@target_idx</span> <span class='op'>=</span> <span class='id identifier rubyid_target_idx'>target_idx</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="method_details ">
|
|||
|
|
<h3 class="signature " id="validate-instance_method">
|
|||
|
|
|
|||
|
|
#<strong>validate</strong> ⇒ <tt>Object</tt>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
</h3><div class="docstring">
|
|||
|
|
<div class="discussion">
|
|||
|
|
|
|||
|
|
<p>Makes sure everything’s in tip-top condition prior to launching the exploit. For things that aren’t good to go, an exception is thrown.</p>
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="tags">
|
|||
|
|
|
|||
|
|
|
|||
|
|
</div><table class="source_code">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<pre class="lines">
|
|||
|
|
|
|||
|
|
|
|||
|
|
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</pre>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit_driver.rb', line 68</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate'>validate</span>
|
|||
|
|
<span class='comment'># First, validate that a target has been selected
|
|||
|
|
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_target_idx'>target_idx</span> <span class='op'>==</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="MissingTargetError.html" title="Msf::MissingTargetError (class)">MissingTargetError</a></span></span><span class='comma'>,</span>
|
|||
|
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A payload cannot be selected until a target is specified.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
|||
|
|
<span class='id identifier rubyid_caller'>caller</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Next, validate that a payload has been selected
|
|||
|
|
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span> <span class='op'>==</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="MissingPayloadError.html" title="Msf::MissingPayloadError (class)">MissingPayloadError</a></span></span><span class='comma'>,</span>
|
|||
|
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A payload has not been selected.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Make sure the payload is compatible after all
|
|||
|
|
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_compatible_payload?'>compatible_payload?</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="IncompatiblePayloadError.html" title="Msf::IncompatiblePayloadError (class)">IncompatiblePayloadError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="IncompatiblePayloadError.html#initialize-instance_method" title="Msf::IncompatiblePayloadError#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_refname'>refname</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_refname'>refname</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not a compatible payload.</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>unless</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:allow_no_cleanup</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_allow_no_cleanup'>allow_no_cleanup</span>
|
|||
|
|
<span class='comment'># Being able to cleanup requires a session to be created from a handler, and for that
|
|||
|
|
</span> <span class='comment'># session to be able to be able to clean up files
|
|||
|
|
</span> <span class='id identifier rubyid_can_cleanup'>can_cleanup</span> <span class='op'>=</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_handler_klass'>handler_klass</span> <span class='op'>!=</span> <span class='const'><span class='object_link'><a href="../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Handler.html" title="Msf::Handler (module)">Handler</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Handler/None.html" title="Msf::Handler::None (module)">None</a></span></span> <span class='op'>&&</span> <span class='id identifier rubyid_payload'>payload</span><span class='op'>&.</span><span class='id identifier rubyid_session'>session</span><span class='op'>&.</span><span class='id identifier rubyid_can_cleanup_files'>can_cleanup_files</span>
|
|||
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_needs_cleanup'>needs_cleanup</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_can_cleanup'>can_cleanup</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="IncompatiblePayloadError.html" title="Msf::IncompatiblePayloadError (class)">IncompatiblePayloadError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="IncompatiblePayloadError.html#initialize-instance_method" title="Msf::IncompatiblePayloadError#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_refname'>refname</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_refname'>refname</span><span class='embexpr_end'>}</span><span class='tstring_content'> cannot cleanup files created during exploit. To run anyway, set AllowNoCleanup to true</span><span class='tstring_end'>"</span></span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_needs_cleanup'>needs_cleanup</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_handler_enabled?'>handler_enabled?</span>
|
|||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ValidationError.html" title="Msf::ValidationError (class)">ValidationError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ValidationError.html#initialize-instance_method" title="Msf::ValidationError#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Cannot cleanup files created during exploit if payload handler is disabled. To run anyway, set AllowNoCleanup to true</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
<span class='kw'>end</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Associate the payload instance with the exploit
|
|||
|
|
</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_assoc_exploit'>assoc_exploit</span> <span class='op'>=</span> <span class='id identifier rubyid_exploit'>exploit</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Finally, validate options on the exploit module to ensure that things
|
|||
|
|
</span> <span class='comment'># are ready to operate as they should.
|
|||
|
|
</span> <span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_exploit'>exploit</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='rparen'>)</span>
|
|||
|
|
|
|||
|
|
<span class='comment'># Validate the payload's options. The payload's datastore is
|
|||
|
|
</span> <span class='comment'># most likely shared against the exploit's datastore, but in case it
|
|||
|
|
</span> <span class='comment'># isn't.
|
|||
|
|
</span> <span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='period'>.</span><span class='id identifier rubyid_datastore'>datastore</span><span class='rparen'>)</span>
|
|||
|
|
|
|||
|
|
<span class='kw'>return</span> <span class='kw'>true</span>
|
|||
|
|
<span class='kw'>end</span></pre>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div id="footer">
|
|||
|
|
Generated on Fri May 8 17:03:23 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>
|