379 lines
14 KiB
HTML
379 lines
14 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>
|
||
|
|
Module: Msf::Exploit::KernelMode
|
||
|
|
|
||
|
|
— Documentation by YARD 0.9.37
|
||
|
|
|
||
|
|
</title>
|
||
|
|
|
||
|
|
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
||
|
|
|
||
|
|
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
||
|
|
|
||
|
|
<script type="text/javascript">
|
||
|
|
pathId = "Msf::Exploit::KernelMode";
|
||
|
|
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 (K)</a> »
|
||
|
|
<span class='title'><span class='object_link'><a href="../../Msf.html" title="Msf (module)">Msf</a></span></span> » <span class='title'><span class='object_link'><a href="../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span>
|
||
|
|
»
|
||
|
|
<span class="title">KernelMode</span>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="search">
|
||
|
|
|
||
|
|
<a class="full_list_link" id="class_list_link"
|
||
|
|
href="../../class_list.html">
|
||
|
|
|
||
|
|
<svg width="24" height="24">
|
||
|
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
||
|
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
||
|
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
||
|
|
</svg>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
<div class="clear"></div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="content"><h1>Module: Msf::Exploit::KernelMode
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</h1>
|
||
|
|
<div class="box_info">
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<dl>
|
||
|
|
<dt>Defined in:</dt>
|
||
|
|
<dd>lib/msf/core/exploit/kernel_mode.rb</dd>
|
||
|
|
</dl>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<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="#encapsulate_kernel_payload-instance_method" title="#encapsulate_kernel_payload (instance method)">#<strong>encapsulate_kernel_payload</strong>(reqs, raw) ⇒ Object </a>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</span>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<span class="note title protected">protected</span>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<span class="summary_desc"><div class='inline'>
|
||
|
|
<p>Encapsulates the supplied raw payload within a kernel-mode payload.</p>
|
||
|
|
</div></span>
|
||
|
|
|
||
|
|
</li>
|
||
|
|
|
||
|
|
|
||
|
|
<li class="public ">
|
||
|
|
<span class="summary_signature">
|
||
|
|
|
||
|
|
<a href="#encode_begin-instance_method" title="#encode_begin (instance method)">#<strong>encode_begin</strong>(real_payload, reqs) ⇒ Object </a>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</span>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<span class="summary_desc"><div class='inline'>
|
||
|
|
<p>The way that the kernel-mode mixin works is by replacing the payload to be encoded with one that encapsulates the kernel-mode payload as well.</p>
|
||
|
|
</div></span>
|
||
|
|
|
||
|
|
</li>
|
||
|
|
|
||
|
|
|
||
|
|
<li class="public ">
|
||
|
|
<span class="summary_signature">
|
||
|
|
|
||
|
|
<a href="#wfs_delay-instance_method" title="#wfs_delay (instance method)">#<strong>wfs_delay</strong> ⇒ Object </a>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</span>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<span class="summary_desc"><div class='inline'>
|
||
|
|
<p>Increase the default delay by five seconds since some kernel-mode payloads may not run immediately.</p>
|
||
|
|
</div></span>
|
||
|
|
|
||
|
|
</li>
|
||
|
|
|
||
|
|
|
||
|
|
</ul>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<div id="instance_method_details" class="method_details_list">
|
||
|
|
<h2>Instance Method Details</h2>
|
||
|
|
|
||
|
|
|
||
|
|
<div class="method_details first">
|
||
|
|
<h3 class="signature first" id="encapsulate_kernel_payload-instance_method">
|
||
|
|
|
||
|
|
#<strong>encapsulate_kernel_payload</strong>(reqs, raw) ⇒ <tt>Object</tt> <span class="extras">(protected)</span>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</h3><div class="docstring">
|
||
|
|
<div class="discussion">
|
||
|
|
|
||
|
|
<p>Encapsulates the supplied raw payload within a kernel-mode payload.</p>
|
||
|
|
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="tags">
|
||
|
|
|
||
|
|
|
||
|
|
</div><table class="source_code">
|
||
|
|
<tr>
|
||
|
|
<td>
|
||
|
|
<pre class="lines">
|
||
|
|
|
||
|
|
|
||
|
|
33
|
||
|
|
34
|
||
|
|
35
|
||
|
|
36
|
||
|
|
37
|
||
|
|
38
|
||
|
|
39
|
||
|
|
40
|
||
|
|
41
|
||
|
|
42
|
||
|
|
43
|
||
|
|
44
|
||
|
|
45
|
||
|
|
46
|
||
|
|
47
|
||
|
|
48
|
||
|
|
49
|
||
|
|
50
|
||
|
|
51
|
||
|
|
52
|
||
|
|
53
|
||
|
|
54
|
||
|
|
55
|
||
|
|
56
|
||
|
|
57
|
||
|
|
58
|
||
|
|
59
|
||
|
|
60
|
||
|
|
61
|
||
|
|
62</pre>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/kernel_mode.rb', line 33</span>
|
||
|
|
|
||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_encapsulate_kernel_payload'>encapsulate_kernel_payload</span><span class='lparen'>(</span><span class='id identifier rubyid_reqs'>reqs</span><span class='comma'>,</span> <span class='id identifier rubyid_raw'>raw</span><span class='rparen'>)</span>
|
||
|
|
<span class='id identifier rubyid_new_raw'>new_raw</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
||
|
|
<span class='id identifier rubyid_ext_opt'>ext_opt</span> <span class='op'>=</span> <span class='id identifier rubyid_reqs'>reqs</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExtendedOptions</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
||
|
|
|
||
|
|
<span class='comment'># Prepend and append any buffers that were specified in the extended
|
||
|
|
</span> <span class='comment'># options. This can be used do perform stack adjustments and other
|
||
|
|
</span> <span class='comment'># such things against the user-mode payload rather than the
|
||
|
|
</span> <span class='comment'># encapsulating payload.
|
||
|
|
</span> <span class='id identifier rubyid_raw'>raw</span> <span class='op'>=</span>
|
||
|
|
<span class='lparen'>(</span><span class='id identifier rubyid_ext_opt'>ext_opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>PrependUser</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>+</span>
|
||
|
|
<span class='id identifier rubyid_raw'>raw</span> <span class='op'>+</span>
|
||
|
|
<span class='lparen'>(</span><span class='id identifier rubyid_ext_opt'>ext_opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>AppendUser</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
||
|
|
|
||
|
|
<span class='comment'># If this is a win32 target platform, try to encapsulate it in a
|
||
|
|
</span> <span class='comment'># win32 kernel-mode payload.
|
||
|
|
</span> <span class='kw'>if</span> <span class='id identifier rubyid_target_platform'>target_platform</span><span class='period'>.</span><span class='id identifier rubyid_supports?'>supports?</span><span class='lparen'>(</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="../Module.html" title="Msf::Module (class)">Module</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Module/PlatformList.html" title="Msf::Module::PlatformList (class)">PlatformList</a></span></span><span class='period'>.</span><span class='id identifier rubyid_win32'><span class='object_link'><a href="../Module/PlatformList.html#win32-class_method" title="Msf::Module::PlatformList.win32 (method)">win32</a></span></span><span class='rparen'>)</span>
|
||
|
|
<span class='id identifier rubyid_ext_opt'>ext_opt</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>UserModeStub</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_raw'>raw</span>
|
||
|
|
|
||
|
|
<span class='id identifier rubyid_new_raw'>new_raw</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'><span class='object_link'><a href="../../Rex/Payloads.html" title="Rex::Payloads (module)">Payloads</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Rex/Payloads/Win32.html" title="Rex::Payloads::Win32 (module)">Win32</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Rex/Payloads/Win32/Kernel.html" title="Rex::Payloads::Win32::Kernel (module)">Kernel</a></span></span><span class='period'>.</span><span class='id identifier rubyid_construct'><span class='object_link'><a href="../../Rex/Payloads/Win32/Kernel.html#construct-class_method" title="Rex::Payloads::Win32::Kernel.construct (method)">construct</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_ext_opt'>ext_opt</span><span class='rparen'>)</span>
|
||
|
|
<span class='kw'>end</span>
|
||
|
|
|
||
|
|
<span class='comment'># If we did not generate a new payload, then something broke.
|
||
|
|
</span> <span class='kw'>if</span> <span class='id identifier rubyid_new_raw'>new_raw</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
||
|
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>RuntimeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Could not encapsulate payload in kernel-mode payload</span><span class='tstring_end'>"</span></span>
|
||
|
|
<span class='kw'>else</span>
|
||
|
|
<span class='id identifier rubyid_dlog'><span class='object_link'><a href="../../top-level-namespace.html#dlog-instance_method" title="#dlog (method)">dlog</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Encapsulated user-mode payload size </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_raw'>raw</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='embexpr_end'>}</span><span class='tstring_content'> in kernel-mode payload size </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_new_raw'>new_raw</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>core</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../../Rex/Logging.html#LEV_1-constant" title="Rex::Logging::LEV_1 (constant)">LEV_1</a></span></span><span class='rparen'>)</span>
|
||
|
|
<span class='kw'>end</span>
|
||
|
|
|
||
|
|
<span class='id identifier rubyid_new_raw'>new_raw</span>
|
||
|
|
<span class='kw'>end</span></pre>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="method_details ">
|
||
|
|
<h3 class="signature " id="encode_begin-instance_method">
|
||
|
|
|
||
|
|
#<strong>encode_begin</strong>(real_payload, reqs) ⇒ <tt>Object</tt>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</h3><div class="docstring">
|
||
|
|
<div class="discussion">
|
||
|
|
|
||
|
|
<p>The way that the kernel-mode mixin works is by replacing the payload to be encoded with one that encapsulates the kernel-mode payload as well.</p>
|
||
|
|
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="tags">
|
||
|
|
|
||
|
|
|
||
|
|
</div><table class="source_code">
|
||
|
|
<tr>
|
||
|
|
<td>
|
||
|
|
<pre class="lines">
|
||
|
|
|
||
|
|
|
||
|
|
12
|
||
|
|
13
|
||
|
|
14
|
||
|
|
15
|
||
|
|
16
|
||
|
|
17
|
||
|
|
18</pre>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/kernel_mode.rb', line 12</span>
|
||
|
|
|
||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_encode_begin'>encode_begin</span><span class='lparen'>(</span><span class='id identifier rubyid_real_payload'>real_payload</span><span class='comma'>,</span> <span class='id identifier rubyid_reqs'>reqs</span><span class='rparen'>)</span>
|
||
|
|
<span class='kw'>super</span>
|
||
|
|
|
||
|
|
<span class='id identifier rubyid_reqs'>reqs</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>EncapsulationRoutine</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</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_reqs_'>reqs_</span><span class='comma'>,</span> <span class='id identifier rubyid_raw'>raw</span><span class='op'>|</span>
|
||
|
|
<span class='id identifier rubyid_encapsulate_kernel_payload'>encapsulate_kernel_payload</span><span class='lparen'>(</span><span class='id identifier rubyid_reqs_'>reqs_</span><span class='comma'>,</span> <span class='id identifier rubyid_raw'>raw</span><span class='rparen'>)</span>
|
||
|
|
<span class='rbrace'>}</span>
|
||
|
|
<span class='kw'>end</span></pre>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="method_details ">
|
||
|
|
<h3 class="signature " id="wfs_delay-instance_method">
|
||
|
|
|
||
|
|
#<strong>wfs_delay</strong> ⇒ <tt>Object</tt>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</h3><div class="docstring">
|
||
|
|
<div class="discussion">
|
||
|
|
|
||
|
|
<p>Increase the default delay by five seconds since some kernel-mode payloads may not run immediately.</p>
|
||
|
|
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="tags">
|
||
|
|
|
||
|
|
|
||
|
|
</div><table class="source_code">
|
||
|
|
<tr>
|
||
|
|
<td>
|
||
|
|
<pre class="lines">
|
||
|
|
|
||
|
|
|
||
|
|
24
|
||
|
|
25
|
||
|
|
26</pre>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/kernel_mode.rb', line 24</span>
|
||
|
|
|
||
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_wfs_delay'>wfs_delay</span>
|
||
|
|
<span class='kw'>super</span> <span class='op'>+</span> <span class='int'>5</span>
|
||
|
|
<span class='kw'>end</span></pre>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="footer">
|
||
|
|
Generated on Fri May 8 17:01:28 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>
|