914 lines
30 KiB
HTML
914 lines
30 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>
|
||
Module: Msf::Handler::FindPort
|
||
|
||
— 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::Handler::FindPort";
|
||
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 (F)</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="../Handler.html" title="Msf::Handler (module)">Handler</a></span></span>
|
||
»
|
||
<span class="title">FindPort</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::Handler::FindPort
|
||
|
||
|
||
|
||
</h1>
|
||
<div class="box_info">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<dl>
|
||
<dt>Includes:</dt>
|
||
<dd><span class='object_link'><a href="../Handler.html" title="Msf::Handler (module)">Msf::Handler</a></span></dd>
|
||
</dl>
|
||
|
||
|
||
|
||
|
||
<dl>
|
||
<dt>Included in:</dt>
|
||
<dd><span class='object_link'><a href="FindShell.html" title="Msf::Handler::FindShell (module)">FindShell</a></span>, <span class='object_link'><a href="FindTag.html" title="Msf::Handler::FindTag (module)">FindTag</a></span>, <span class='object_link'><a href="FindTty.html" title="Msf::Handler::FindTty (module)">FindTty</a></span></dd>
|
||
</dl>
|
||
|
||
|
||
|
||
<dl>
|
||
<dt>Defined in:</dt>
|
||
<dd>lib/msf/core/handler/find_port.rb</dd>
|
||
</dl>
|
||
|
||
</div>
|
||
|
||
<h2>Overview</h2><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>This handlers implements port-based findsock handling.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div>
|
||
|
||
|
||
<h2>Constant Summary</h2>
|
||
|
||
<h3 class="inherited">Constants included
|
||
from <span class='object_link'><a href="../Handler.html" title="Msf::Handler (module)">Msf::Handler</a></span></h3>
|
||
<p class="inherited"><span class='object_link'><a href="../Handler.html#Claimed-constant" title="Msf::Handler::Claimed (constant)">Claimed</a></span>, <span class='object_link'><a href="../Handler.html#Unused-constant" title="Msf::Handler::Unused (constant)">Unused</a></span></p>
|
||
|
||
|
||
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
||
<ul class="summary">
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#_handler_return_value-instance_method" title="#_handler_return_value (instance method)">#<strong>_handler_return_value</strong> ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>:nodoc:.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
|
||
|
||
|
||
|
||
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../Handler.html" title="Msf::Handler (module)">Msf::Handler</a></span></h3>
|
||
<p class="inherited"><span class='object_link'><a href="../Handler.html#exploit_config-instance_method" title="Msf::Handler#exploit_config (method)">#exploit_config</a></span>, <span class='object_link'><a href="../Handler.html#parent_payload-instance_method" title="Msf::Handler#parent_payload (method)">#parent_payload</a></span>, <span class='object_link'><a href="../Handler.html#pending_connections-instance_method" title="Msf::Handler#pending_connections (method)">#pending_connections</a></span>, <span class='object_link'><a href="../Handler.html#session_waiter_event-instance_method" title="Msf::Handler#session_waiter_event (method)">#session_waiter_event</a></span>, <span class='object_link'><a href="../Handler.html#sessions-instance_method" title="Msf::Handler#sessions (method)">#sessions</a></span></p>
|
||
|
||
|
||
|
||
<h2>
|
||
Class Method Summary
|
||
<small><a href="#" class="summary_toggle">collapse</a></small>
|
||
</h2>
|
||
|
||
<ul class="summary">
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#general_handler_type-class_method" title="general_handler_type (class method)">.<strong>general_handler_type</strong> ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Returns the connection oriented general handler type, in this case ‘find’.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#handler_type-class_method" title="handler_type (class method)">.<strong>handler_type</strong> ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Returns the string representation of the handler type, in this case ‘find_port’.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
<h2>
|
||
Instance Method Summary
|
||
<small><a href="#" class="summary_toggle">collapse</a></small>
|
||
</h2>
|
||
|
||
<ul class="summary">
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#_check_shell-instance_method" title="#_check_shell (instance method)">#<strong>_check_shell</strong>(sock) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Checks to see if a shell has been allocated on the connection.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#_find_prefix-instance_method" title="#_find_prefix (instance method)">#<strong>_find_prefix</strong>(sock) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Prefix to the stage if necessary.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#_send_id-instance_method" title="#_send_id (instance method)">#<strong>_send_id</strong>(sock) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Sends the identifier if there is one.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="protected ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#create_session-instance_method" title="#create_session (instance method)">#<strong>create_session</strong>(sock, opts = {}) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
<span class="note title protected">protected</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Wrapper to create session that makes sure we actually have a session to create…</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
<li class="public ">
|
||
<span class="summary_signature">
|
||
|
||
<a href="#handler-instance_method" title="#handler (instance method)">#<strong>handler</strong>(sock) ⇒ Object </a>
|
||
|
||
|
||
|
||
</span>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<span class="summary_desc"><div class='inline'>
|
||
<p>Check to see if there’s a shell on the supplied sock.</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 the find port handler and adds the client port option that is required for port-based findsock payloads to function.</p>
|
||
</div></span>
|
||
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Handler.html" title="Msf::Handler (module)">Msf::Handler</a></span></h3>
|
||
<p class="inherited"><span class='object_link'><a href="../Handler.html#add_handler-instance_method" title="Msf::Handler#add_handler (method)">#add_handler</a></span>, <span class='object_link'><a href="../Handler.html#cleanup_handler-instance_method" title="Msf::Handler#cleanup_handler (method)">#cleanup_handler</a></span>, <span class='object_link'><a href="../Handler.html#handle_connection-instance_method" title="Msf::Handler#handle_connection (method)">#handle_connection</a></span>, <span class='object_link'><a href="../Handler.html#handler_name-instance_method" title="Msf::Handler#handler_name (method)">#handler_name</a></span>, <span class='object_link'><a href="../Handler.html#interrupt_wait_for_session-instance_method" title="Msf::Handler#interrupt_wait_for_session (method)">#interrupt_wait_for_session</a></span>, <span class='object_link'><a href="../Handler.html#register_session-instance_method" title="Msf::Handler#register_session (method)">#register_session</a></span>, <span class='object_link'><a href="../Handler.html#setup_handler-instance_method" title="Msf::Handler#setup_handler (method)">#setup_handler</a></span>, <span class='object_link'><a href="../Handler.html#start_handler-instance_method" title="Msf::Handler#start_handler (method)">#start_handler</a></span>, <span class='object_link'><a href="../Handler.html#stop_handler-instance_method" title="Msf::Handler#stop_handler (method)">#stop_handler</a></span>, <span class='object_link'><a href="../Handler.html#wait_for_session-instance_method" title="Msf::Handler#wait_for_session (method)">#wait_for_session</a></span>, <span class='object_link'><a href="../Handler.html#wfs_delay-instance_method" title="Msf::Handler#wfs_delay (method)">#wfs_delay</a></span></p>
|
||
|
||
<div id="instance_attr_details" class="attr_details">
|
||
<h2>Instance Attribute Details</h2>
|
||
|
||
|
||
<span id="_handler_return_value=-instance_method"></span>
|
||
<div class="method_details first">
|
||
<h3 class="signature first" id="_handler_return_value-instance_method">
|
||
|
||
#<strong>_handler_return_value</strong> ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</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">
|
||
|
||
|
||
145
|
||
146
|
||
147</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 145</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid__handler_return_value'>_handler_return_value</span>
|
||
<span class='ivar'>@_handler_return_value</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
|
||
<div id="class_method_details" class="method_details_list">
|
||
<h2>Class Method Details</h2>
|
||
|
||
|
||
<div class="method_details first">
|
||
<h3 class="signature first" id="general_handler_type-class_method">
|
||
|
||
.<strong>general_handler_type</strong> ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Returns the connection oriented general handler type, in this case ‘find’.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
26
|
||
27
|
||
28</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 26</span>
|
||
|
||
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_general_handler_type'>general_handler_type</span>
|
||
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>find</span><span class='tstring_end'>"</span></span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="handler_type-class_method">
|
||
|
||
.<strong>handler_type</strong> ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Returns the string representation of the handler type, in this case ‘find_port’.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
18
|
||
19
|
||
20</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 18</span>
|
||
|
||
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_handler_type'>handler_type</span>
|
||
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>find_port</span><span class='tstring_end'>"</span></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="_check_shell-instance_method">
|
||
|
||
#<strong>_check_shell</strong>(sock) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Checks to see if a shell has been allocated on the connection. This is only done for payloads that use the CommandShell session.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
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</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 117</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid__check_shell'>_check_shell</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_ebuf'>ebuf</span> <span class='op'>=</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'>Text</span><span class='period'>.</span><span class='id identifier rubyid_rand_text_alphanumeric'>rand_text_alphanumeric</span><span class='lparen'>(</span><span class='int'>16</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Send any identifying information that the find sock may need on
|
||
</span> <span class='comment'># the other side, such as a tag. If we do actually send something,
|
||
</span> <span class='comment'># wait a bit longer to let the remote side find us.
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid__send_id'>_send_id</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span><span class='rparen'>)</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'>ThreadSafe</span><span class='period'>.</span><span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='float'>1.5</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># Make sure the read buffer is empty before we test for a shell
|
||
</span> <span class='id identifier rubyid_sock'>sock</span><span class='period'>.</span><span class='id identifier rubyid_get_once'>get_once</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span><span class='int'>1</span><span class='rparen'>)</span>
|
||
<span class='comment'># Check to see if the shell exists
|
||
</span> <span class='id identifier rubyid_sock'>sock</span><span class='period'>.</span><span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\necho </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ebuf'>ebuf</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Try to read a response
|
||
</span> <span class='id identifier rubyid_rbuf'>rbuf</span> <span class='op'>=</span> <span class='id identifier rubyid_sock'>sock</span><span class='period'>.</span><span class='id identifier rubyid_get_once'>get_once</span>
|
||
|
||
<span class='comment'># If it contains our string, then we rock
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_rbuf'>rbuf</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ebuf'>ebuf</span><span class='embexpr_end'>}</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_print_status'>print_status</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Found shell.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
|
||
<span class='kw'>return</span> <span class='kw'>true</span>
|
||
<span class='kw'>else</span>
|
||
<span class='kw'>return</span> <span class='kw'>false</span>
|
||
<span class='kw'>end</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="_find_prefix-instance_method">
|
||
|
||
#<strong>_find_prefix</strong>(sock) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Prefix to the stage if necessary.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
74
|
||
75</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 74</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid__find_prefix'>_find_prefix</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="_send_id-instance_method">
|
||
|
||
#<strong>_send_id</strong>(sock) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Sends the identifier if there is one.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
80
|
||
81</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 80</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid__send_id'>_send_id</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="create_session-instance_method">
|
||
|
||
#<strong>create_session</strong>(sock, opts = {}) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Wrapper to create session that makes sure we actually have a session to create…</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
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</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 87</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_create_session'>create_session</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_go'>go</span> <span class='op'>=</span> <span class='kw'>true</span>
|
||
|
||
<span class='comment'># Give the payload a chance to run
|
||
</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'>ThreadSafe</span><span class='period'>.</span><span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='float'>1.5</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># This is a hack. If the session is a shell, we check to see if it's
|
||
</span> <span class='comment'># functional by sending an echo which tells us whether or not we're good
|
||
</span> <span class='comment'># to go.
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_session'>session</span> <span class='kw'>and</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>shell</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_go'>go</span> <span class='op'>=</span> <span class='id identifier rubyid__check_shell'>_check_shell</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span>
|
||
<span class='kw'>else</span>
|
||
<span class='id identifier rubyid_print_status'>print_status</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Trying to use connection...</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='comment'># If we're good to go, create the session.
|
||
</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_go'>go</span> <span class='op'>==</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>super</span> <span class='op'>:</span> <span class='kw'>nil</span>
|
||
|
||
|
||
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span>
|
||
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__handler_return_value'>_handler_return_value</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Handler.html#Claimed-constant" title="Msf::Handler::Claimed (constant)">Claimed</a></span></span>
|
||
<span class='kw'>end</span>
|
||
|
||
<span class='kw'>return</span> <span class='id identifier rubyid_rv'>rv</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="method_details ">
|
||
<h3 class="signature " id="handler-instance_method">
|
||
|
||
#<strong>handler</strong>(sock) ⇒ <tt>Object</tt>
|
||
|
||
|
||
|
||
|
||
|
||
</h3><div class="docstring">
|
||
<div class="discussion">
|
||
|
||
<p>Check to see if there’s a shell on the supplied sock. This check currently only works for shells.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
47
|
||
48
|
||
49
|
||
50
|
||
51
|
||
52
|
||
53
|
||
54
|
||
55
|
||
56
|
||
57
|
||
58
|
||
59
|
||
60
|
||
61
|
||
62
|
||
63
|
||
64
|
||
65
|
||
66
|
||
67</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 47</span>
|
||
|
||
<span class='kw'>def</span> <span class='id identifier rubyid_handler'>handler</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span>
|
||
<span class='kw'>return</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_sock'>sock</span>
|
||
|
||
<span class='id identifier rubyid__find_prefix'>_find_prefix</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># Flush the receive buffer
|
||
</span> <span class='id identifier rubyid_sock'>sock</span><span class='period'>.</span><span class='id identifier rubyid_get_once'>get_once</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span>
|
||
|
||
<span class='comment'># If this is a multi-stage payload, then we just need to blindly
|
||
</span> <span class='comment'># transmit the stage and create the session, hoping that it works.
|
||
</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_payload_type'>payload_type</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="../Payload.html" title="Msf::Payload (class)">Payload</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Payload/Type.html" title="Msf::Payload::Type (module)">Type</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Payload/Type.html#Single-constant" title="Msf::Payload::Type::Single (constant)">Single</a></span></span><span class='rparen'>)</span>
|
||
<span class='id identifier rubyid_handle_connection'>handle_connection</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>datastore:</span> <span class='id identifier rubyid_datastore'>datastore</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
||
<span class='comment'># Otherwise, check to see if we found a session. We really need
|
||
</span> <span class='comment'># to improve this, as we could create a session when the exploit
|
||
</span> <span class='comment'># really didn't succeed.
|
||
</span> <span class='kw'>else</span>
|
||
<span class='id identifier rubyid_create_session'>create_session</span><span class='lparen'>(</span><span class='id identifier rubyid_sock'>sock</span><span class='rparen'>)</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__handler_return_value'>_handler_return_value</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 the find port handler and adds the client port option that is required for port-based findsock payloads to function.</p>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="tags">
|
||
|
||
|
||
</div><table class="source_code">
|
||
<tr>
|
||
<td>
|
||
<pre class="lines">
|
||
|
||
|
||
34
|
||
35
|
||
36
|
||
37
|
||
38
|
||
39
|
||
40
|
||
41</pre>
|
||
</td>
|
||
<td>
|
||
<pre class="code"><span class="info file"># File 'lib/msf/core/handler/find_port.rb', line 34</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='id identifier rubyid_register_options'>register_options</span><span class='lparen'>(</span>
|
||
<span class='lbracket'>[</span>
|
||
<span class='const'><span class='object_link'><a href="../Opt.html" title="Msf::Opt (module)">Opt</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Opt.html#CPORT-constant" title="Msf::Opt::CPORT (constant)">CPORT</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>64000</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='int'>1024</span><span class='rparen'>)</span><span class='comma'>,</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="../Handler.html" title="Msf::Handler (module)">Handler</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Msf::Handler::FindPort (module)">FindPort</a></span></span><span class='rparen'>)</span>
|
||
<span class='kw'>end</span></pre>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div id="footer">
|
||
Generated on Fri May 8 17:01:16 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> |