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

1426 lines
45 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Msf::Session::Interactive
&mdash; Documentation by YARD 0.9.37
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Msf::Session::Interactive";
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 (I)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Msf.html" title="Msf (module)">Msf</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Session.html" title="Msf::Session (module)">Session</a></span></span>
&raquo;
<span class="title">Interactive</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::Session::Interactive
</h1>
<div class="box_info">
<dl>
<dt>Includes:</dt>
<dd><span class='object_link'><a href="../../Rex/Ui/Interactive.html" title="Rex::Ui::Interactive (module)">Rex::Ui::Interactive</a></span></dd>
</dl>
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="Basic.html" title="Msf::Session::Basic (module)">Basic</a></span>, <span class='object_link'><a href="../Sessions/HWBridge.html" title="Msf::Sessions::HWBridge (class)">Msf::Sessions::HWBridge</a></span>, <span class='object_link'><a href="../Sessions/Meterpreter.html" title="Msf::Sessions::Meterpreter (class)">Msf::Sessions::Meterpreter</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/session/interactive.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>This class implements the stubs that are needed to provide an interactive session.</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="#rstream-instance_method" title="#rstream (instance method)">#<strong>rstream</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>The remote stream handle.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../../Rex/Ui/Interactive.html" title="Rex::Ui::Interactive (module)">Rex::Ui::Interactive</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Interactive.html#completed-instance_method" title="Rex::Ui::Interactive#completed (method)">#completed</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#interacting-instance_method" title="Rex::Ui::Interactive#interacting (method)">#interacting</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#next_session-instance_method" title="Rex::Ui::Interactive#next_session (method)">#next_session</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#on_command_proc-instance_method" title="Rex::Ui::Interactive#on_command_proc (method)">#on_command_proc</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#on_print_proc-instance_method" title="Rex::Ui::Interactive#on_print_proc (method)">#on_print_proc</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#on_run_command_error_proc-instance_method" title="Rex::Ui::Interactive#on_run_command_error_proc (method)">#on_run_command_error_proc</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#orig_suspend-instance_method" title="Rex::Ui::Interactive#orig_suspend (method)">#orig_suspend</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#orig_usr1-instance_method" title="Rex::Ui::Interactive#orig_usr1 (method)">#orig_usr1</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#orig_winch-instance_method" title="Rex::Ui::Interactive#orig_winch (method)">#orig_winch</a></span></p>
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../../Rex/Ui/Subscriber/Input.html" title="Rex::Ui::Subscriber::Input (module)">Rex::Ui::Subscriber::Input</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Subscriber/Input.html#user_input-instance_method" title="Rex::Ui::Subscriber::Input#user_input (method)">#user_input</a></span></p>
<h3 class="inherited">Attributes included from <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html" title="Rex::Ui::Subscriber::Output (module)">Rex::Ui::Subscriber::Output</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#user_output-instance_method" title="Rex::Ui::Subscriber::Output#user_output (method)">#user_output</a></span></p>
<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="#_interact-instance_method" title="#_interact (instance method)">#<strong>_interact</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Stub method that is meant to handler interaction.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#_interact_complete-instance_method" title="#_interact_complete (instance method)">#<strong>_interact_complete</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>If the session reaches EOF, deregister it.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#_interrupt-instance_method" title="#_interrupt (instance method)">#<strong>_interrupt</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Check to see if the user wants to abort.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#_suspend-instance_method" title="#_suspend (instance method)">#<strong>_suspend</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Check to see if we should suspend.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#_usr1-instance_method" title="#_usr1 (instance method)">#<strong>_usr1</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#abort_foreground-instance_method" title="#abort_foreground (instance method)">#<strong>abort_foreground</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#abort_foreground_supported-instance_method" title="#abort_foreground_supported (instance method)">#<strong>abort_foreground_supported</strong> &#x21d2; Object </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#cleanup-instance_method" title="#cleanup (instance method)">#<strong>cleanup</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Closes rstream.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#comm_channel-instance_method" title="#comm_channel (instance method)">#<strong>comm_channel</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(rstream, opts = {}) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Initializes the session.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#interactive%3F-instance_method" title="#interactive? (instance method)">#<strong>interactive?</strong> &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns that, yes, indeed, this session supports going interactive with the user.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#kill-instance_method" title="#kill (instance method)">#<strong>kill</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Terminate the session.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#run_cmd-instance_method" title="#run_cmd (instance method)">#<strong>run_cmd</strong>(cmd) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Run an arbitrary command as if it came from user input.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#tunnel_local-instance_method" title="#tunnel_local (instance method)">#<strong>tunnel_local</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the local information.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#tunnel_peer-instance_method" title="#tunnel_peer (instance method)">#<strong>tunnel_peer</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the remote peer information.</p>
</div></span>
</li>
<li class="protected ">
<span class="summary_signature">
<a href="#user_want_abort%3F-instance_method" title="#user_want_abort? (instance method)">#<strong>user_want_abort?</strong> &#x21d2; Boolean </a>
</span>
<span class="note title protected">protected</span>
<span class="summary_desc"><div class='inline'>
<p>Checks to see if the user wants to abort.</p>
</div></span>
</li>
</ul>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../../Rex/Ui/Interactive.html" title="Rex::Ui::Interactive (module)">Rex::Ui::Interactive</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Interactive.html#_local_fd-instance_method" title="Rex::Ui::Interactive#_local_fd (method)">#_local_fd</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#_remote_fd-instance_method" title="Rex::Ui::Interactive#_remote_fd (method)">#_remote_fd</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#_stream_read_local_write_remote-instance_method" title="Rex::Ui::Interactive#_stream_read_local_write_remote (method)">#_stream_read_local_write_remote</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#_stream_read_remote_write_local-instance_method" title="Rex::Ui::Interactive#_stream_read_remote_write_local (method)">#_stream_read_remote_write_local</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#_winch-instance_method" title="Rex::Ui::Interactive#_winch (method)">#_winch</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#detach-instance_method" title="Rex::Ui::Interactive#detach (method)">#detach</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#handle_suspend-instance_method" title="Rex::Ui::Interactive#handle_suspend (method)">#handle_suspend</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#handle_usr1-instance_method" title="Rex::Ui::Interactive#handle_usr1 (method)">#handle_usr1</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#handle_winch-instance_method" title="Rex::Ui::Interactive#handle_winch (method)">#handle_winch</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#interact-instance_method" title="Rex::Ui::Interactive#interact (method)">#interact</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#interact_stream-instance_method" title="Rex::Ui::Interactive#interact_stream (method)">#interact_stream</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#prompt-instance_method" title="Rex::Ui::Interactive#prompt (method)">#prompt</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#prompt_yesno-instance_method" title="Rex::Ui::Interactive#prompt_yesno (method)">#prompt_yesno</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#restore_suspend-instance_method" title="Rex::Ui::Interactive#restore_suspend (method)">#restore_suspend</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#restore_usr1-instance_method" title="Rex::Ui::Interactive#restore_usr1 (method)">#restore_usr1</a></span>, <span class='object_link'><a href="../../Rex/Ui/Interactive.html#restore_winch-instance_method" title="Rex::Ui::Interactive#restore_winch (method)">#restore_winch</a></span></p>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../../Rex/Ui/Subscriber.html" title="Rex::Ui::Subscriber (module)">Rex::Ui::Subscriber</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Subscriber.html#copy_ui-instance_method" title="Rex::Ui::Subscriber#copy_ui (method)">#copy_ui</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber.html#init_ui-instance_method" title="Rex::Ui::Subscriber#init_ui (method)">#init_ui</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber.html#reset_ui-instance_method" title="Rex::Ui::Subscriber#reset_ui (method)">#reset_ui</a></span></p>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../../Rex/Ui/Subscriber/Input.html" title="Rex::Ui::Subscriber::Input (module)">Rex::Ui::Subscriber::Input</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Subscriber/Input.html#gets-instance_method" title="Rex::Ui::Subscriber::Input#gets (method)">#gets</a></span></p>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html" title="Rex::Ui::Subscriber::Output (module)">Rex::Ui::Subscriber::Output</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#flush-instance_method" title="Rex::Ui::Subscriber::Output#flush (method)">#flush</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print-instance_method" title="Rex::Ui::Subscriber::Output#print (method)">#print</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print_blank_line-instance_method" title="Rex::Ui::Subscriber::Output#print_blank_line (method)">#print_blank_line</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print_error-instance_method" title="Rex::Ui::Subscriber::Output#print_error (method)">#print_error</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print_good-instance_method" title="Rex::Ui::Subscriber::Output#print_good (method)">#print_good</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print_line-instance_method" title="Rex::Ui::Subscriber::Output#print_line (method)">#print_line</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print_status-instance_method" title="Rex::Ui::Subscriber::Output#print_status (method)">#print_status</a></span>, <span class='object_link'><a href="../../Rex/Ui/Subscriber/Output.html#print_warning-instance_method" title="Rex::Ui::Subscriber::Output#print_warning (method)">#print_warning</a></span></p>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id="rstream=-instance_method"></span>
<div class="method_details first">
<h3 class="signature first" id="rstream-instance_method">
#<strong>rstream</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>The remote stream handle. Must inherit from Rex::IO::Stream.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
108
109
110</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 108</span>
<span class='kw'>def</span> <span class='id identifier rubyid_rstream'>rstream</span>
<span class='ivar'>@rstream</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="_interact-instance_method">
#<strong>_interact</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Stub method that is meant to handler interaction.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
115
116
117</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 115</span>
<span class='kw'>def</span> <span class='id identifier rubyid__interact'>_interact</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_session_interact'>on_session_interact</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="_interact_complete-instance_method">
#<strong>_interact_complete</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>If the session reaches EOF, deregister it.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
181
182
183
184</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 181</span>
<span class='kw'>def</span> <span class='id identifier rubyid__interact_complete'>_interact_complete</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_session_interact_completed'>on_session_interact_completed</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_framework'>framework</span><span class='period'>.</span><span class='id identifier rubyid_sessions'>sessions</span><span class='period'>.</span><span class='id identifier rubyid_deregister'>deregister</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>User exit</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="_interrupt-instance_method">
#<strong>_interrupt</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Check to see if the user wants to abort.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
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/session/interactive.rb', line 122</span>
<span class='kw'>def</span> <span class='id identifier rubyid__interrupt'>_interrupt</span>
<span class='kw'>begin</span>
<span class='id identifier rubyid_intent'>intent</span> <span class='op'>=</span> <span class='id identifier rubyid_user_want_abort?'>user_want_abort?</span>
<span class='comment'># Judge the user wants to abort the reverse shell session
</span> <span class='comment'># Or just want to abort the process running on the target machine
</span> <span class='comment'># If the latter, just send ASCII Control Character \u0003 (End of Text) to the socket fd
</span> <span class='comment'># The character will be handled by the line discipline program of the pseudo-terminal on target machine
</span> <span class='comment'># It will send the SEGINT signal to the foreground process
</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_intent'>intent</span>
<span class='comment'># TODO: Check the shell is interactive or not
</span> <span class='comment'># If the current shell is not interactive, the ASCII Control Character will not work
</span> <span class='kw'>if</span> <span class='id identifier rubyid_abort_foreground_supported'>abort_foreground_supported</span>
<span class='id identifier rubyid_print_status'>print_status</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Aborting foreground process in the shell session</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_abort_foreground'>abort_foreground</span>
<span class='kw'>end</span>
<span class='kw'>return</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='const'>Interrupt</span>
<span class='comment'># The user hit ctrl-c while we were handling a ctrl-c. Ignore
</span> <span class='kw'>end</span>
<span class='kw'>true</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="_suspend-instance_method">
#<strong>_suspend</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Check to see if we should suspend.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
163
164
165
166
167
168
169
170
171
172
173
174
175
176</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 163</span>
<span class='kw'>def</span> <span class='id identifier rubyid__suspend'>_suspend</span>
<span class='comment'># Ask the user if they would like to background the session
</span> <span class='id identifier rubyid_intent'>intent</span> <span class='op'>=</span> <span class='id identifier rubyid_prompt_yesno'>prompt_yesno</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Background session </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_intent'>intent</span>
<span class='comment'># User does not want to background the current session
</span> <span class='comment'># Assuming the target is *nix, we&#39;ll forward CTRL-Z to the foreground process on the target
</span> <span class='kw'>if</span> <span class='op'>!</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_platform'>platform</span><span class='op'>==</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>windows</span><span class='tstring_end'>&quot;</span></span> <span class='op'>&amp;&amp;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>shell</span><span class='tstring_end'>&quot;</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'>&quot;</span><span class='tstring_content'>Backgrounding foreground process in the shell session</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\u001A</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>return</span>
<span class='kw'>end</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_interacting'>interacting</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="_usr1-instance_method">
#<strong>_usr1</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
153
154
155
156
157
158</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 153</span>
<span class='kw'>def</span> <span class='id identifier rubyid__usr1'>_usr1</span>
<span class='comment'># A simple signal to exit vim in reverse shell
</span> <span class='comment'># Just for fun
</span> <span class='comment'># Make sure you have already executed `shell` meta-shell command to pop up an interactive shell
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\x1B\x1B\x1B:q!\r</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="abort_foreground-instance_method">
#<strong>abort_foreground</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
149
150
151</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 149</span>
<span class='kw'>def</span> <span class='id identifier rubyid_abort_foreground'>abort_foreground</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\u0003</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="abort_foreground_supported-instance_method">
#<strong>abort_foreground_supported</strong> &#x21d2; <tt>Object</tt> <span class="extras">(protected)</span>
</h3><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/session/interactive.rb', line 145</span>
<span class='kw'>def</span> <span class='id identifier rubyid_abort_foreground_supported'>abort_foreground_supported</span>
<span class='kw'>true</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="cleanup-instance_method">
#<strong>cleanup</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Closes rstream.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
94
95
96
97
98
99
100
101
102
103</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 94</span>
<span class='kw'>def</span> <span class='id identifier rubyid_cleanup'>cleanup</span>
<span class='kw'>begin</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_interacting'>interacting</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_interactive?'>interactive?</span>
<span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_rstream'>rstream</span><span class='rparen'>)</span>
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Exception</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_rstream'>rstream</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='kw'>super</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="comm_channel-instance_method">
#<strong>comm_channel</strong> &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
69
70
71
72
73
74</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 69</span>
<span class='kw'>def</span> <span class='id identifier rubyid_comm_channel'>comm_channel</span>
<span class='kw'>return</span> <span class='ivar'>@comm_info</span> <span class='kw'>if</span> <span class='ivar'>@comm_info</span>
<span class='kw'>if</span> <span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:channel</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_channel'>channel</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:client</span><span class='rparen'>)</span>
<span class='ivar'>@comm_info</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>via session </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_channel'>channel</span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_sid'>sid</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_channel'>channel</span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:sid</span><span class='rparen'>)</span>
<span class='kw'>end</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>(rstream, opts = {}) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Initializes the session.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
23
24
25
26
27
28
29
30
31
32
33</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 23</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_rstream'>rstream</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='comment'># A nil is passed in the case of non-stream interactive sessions (Meterpreter)
</span> <span class='kw'>if</span> <span class='id identifier rubyid_rstream'>rstream</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_rstream'>rstream</span> <span class='op'>=</span> <span class='id identifier rubyid_rstream'>rstream</span>
<span class='kw'>begin</span>
<span class='ivar'>@peer_info</span> <span class='op'>=</span> <span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_peerinfo'>peerinfo</span>
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Exception</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="interactive?-instance_method">
#<strong>interactive?</strong> &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns that, yes, indeed, this session supports going interactive with the user.</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">
39
40
41</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 39</span>
<span class='kw'>def</span> <span class='id identifier rubyid_interactive?'>interactive?</span>
<span class='kw'>true</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="kill-instance_method">
#<strong>kill</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Terminate the session</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
85
86
87
88
89</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 85</span>
<span class='kw'>def</span> <span class='id identifier rubyid_kill'>kill</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_reset_ui'>reset_ui</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_cleanup'>cleanup</span>
<span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="run_cmd-instance_method">
#<strong>run_cmd</strong>(cmd) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Run an arbitrary command as if it came from user input.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
79
80</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 79</span>
<span class='kw'>def</span> <span class='id identifier rubyid_run_cmd'>run_cmd</span><span class='lparen'>(</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="tunnel_local-instance_method">
#<strong>tunnel_local</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the local information.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
46
47
48
49
50
51
52
53
54</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 46</span>
<span class='kw'>def</span> <span class='id identifier rubyid_tunnel_local'>tunnel_local</span>
<span class='kw'>return</span> <span class='ivar'>@local_info</span> <span class='kw'>if</span> <span class='ivar'>@local_info</span>
<span class='kw'>begin</span>
<span class='ivar'>@local_info</span> <span class='op'>=</span> <span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_localinfo'>localinfo</span>
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_elog'><span class='object_link'><a href="../../top-level-namespace.html#elog-instance_method" title="#elog (method)">elog</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Interactive#tunnel_local error</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>error:</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
<span class='ivar'>@local_info</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="tunnel_peer-instance_method">
#<strong>tunnel_peer</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the remote peer information.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
59
60
61
62
63
64
65
66
67</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 59</span>
<span class='kw'>def</span> <span class='id identifier rubyid_tunnel_peer'>tunnel_peer</span>
<span class='kw'>return</span> <span class='ivar'>@peer_info</span> <span class='kw'>if</span> <span class='ivar'>@peer_info</span>
<span class='kw'>begin</span>
<span class='ivar'>@peer_info</span> <span class='op'>=</span> <span class='id identifier rubyid_rstream'>rstream</span><span class='period'>.</span><span class='id identifier rubyid_peerinfo'>peerinfo</span>
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
<span class='id identifier rubyid_elog'><span class='object_link'><a href="../../top-level-namespace.html#elog-instance_method" title="#elog (method)">elog</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Interactive#tunnel_peer error</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>error:</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
<span class='ivar'>@peer_info</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&#39;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="user_want_abort?-instance_method">
#<strong>user_want_abort?</strong> &#x21d2; <tt>Boolean</tt> <span class="extras">(protected)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Checks to see if the user wants to abort.</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">
189
190
191</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/session/interactive.rb', line 189</span>
<span class='kw'>def</span> <span class='id identifier rubyid_user_want_abort?'>user_want_abort?</span>
<span class='id identifier rubyid_prompt_yesno'>prompt_yesno</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Abort session </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</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:31 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>