Files
metasploit-gs/api/Msf/Post/Windows/FileSystem.html
T

1277 lines
538 KiB
HTML
Raw Normal View History

2026-05-08 17:08:43 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Msf::Post::Windows::FileSystem
&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::Post::Windows::FileSystem";
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> &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="../../Post.html" title="Msf::Post (class)">Post</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Windows.html" title="Msf::Post::Windows (module)">Windows</a></span></span>
&raquo;
<span class="title">FileSystem</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::Post::Windows::FileSystem
</h1>
<div class="box_info">
<dl>
<dt>Includes:</dt>
<dd><span class='object_link'><a href="../../Exploit/Windows_Constants.html" title="Msf::Exploit::Windows_Constants (module)">Exploit::Windows_Constants</a></span>, <span class='object_link'><a href="../Common.html" title="Msf::Post::Common (module)">Common</a></span>, <span class='object_link'><a href="Error.html" title="Msf::Post::Windows::Error (module)">Error</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/post/windows/file_system.rb</dd>
</dl>
</div>
<h2>Defined Under Namespace</h2>
<p class="children">
<strong class="classes">Classes:</strong> <span class='object_link'><a href="FileSystem/WindowsFileSystemGuid.html" title="Msf::Post::Windows::FileSystem::WindowsFileSystemGuid (class)">WindowsFileSystemGuid</a></span>, <span class='object_link'><a href="FileSystem/WindowsFileSystemObjectAttributes.html" title="Msf::Post::Windows::FileSystem::WindowsFileSystemObjectAttributes (class)">WindowsFileSystemObjectAttributes</a></span>, <span class='object_link'><a href="FileSystem/WindowsFileSystemReparseDataBuffer.html" title="Msf::Post::Windows::FileSystem::WindowsFileSystemReparseDataBuffer (class)">WindowsFileSystemReparseDataBuffer</a></span>, <span class='object_link'><a href="FileSystem/WindowsFileSystemReparseGuidDataBuffer.html" title="Msf::Post::Windows::FileSystem::WindowsFileSystemReparseGuidDataBuffer (class)">WindowsFileSystemReparseGuidDataBuffer</a></span>, <span class='object_link'><a href="FileSystem/WindowsFileSystemString16.html" title="Msf::Post::Windows::FileSystem::WindowsFileSystemString16 (class)">WindowsFileSystemString16</a></span>, <span class='object_link'><a href="FileSystem/WindowsFileSystemUnicodeString.html" title="Msf::Post::Windows::FileSystem::WindowsFileSystemUnicodeString (class)">WindowsFileSystemUnicodeString</a></span>
</p>
<h2>
Constant Summary
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
</h2>
<dl class="constants">
<dt id="IO_REPARSE_TAG_MOUNT_POINT-constant" class="">IO_REPARSE_TAG_MOUNT_POINT =
</dt>
<dd><pre class="code"><span class='int'>0xA0000003</span></pre></dd>
<dt id="IO_REPARSE_TAG_HSM-constant" class="">IO_REPARSE_TAG_HSM =
</dt>
<dd><pre class="code"><span class='int'>0xC0000004</span></pre></dd>
<dt id="IO_REPARSE_TAG_DRIVE_EXTENDER-constant" class="">IO_REPARSE_TAG_DRIVE_EXTENDER =
</dt>
<dd><pre class="code"><span class='int'>0x80000005</span></pre></dd>
<dt id="IO_REPARSE_TAG_HSM2-constant" class="">IO_REPARSE_TAG_HSM2 =
</dt>
<dd><pre class="code"><span class='int'>0x80000006</span></pre></dd>
<dt id="IO_REPARSE_TAG_SIS-constant" class="">IO_REPARSE_TAG_SIS =
</dt>
<dd><pre class="code"><span class='int'>0x80000007</span></pre></dd>
<dt id="IO_REPARSE_TAG_WIM-constant" class="">IO_REPARSE_TAG_WIM =
</dt>
<dd><pre class="code"><span class='int'>0x80000008</span></pre></dd>
<dt id="IO_REPARSE_TAG_CSV-constant" class="">IO_REPARSE_TAG_CSV =
</dt>
<dd><pre class="code"><span class='int'>0x80000009</span></pre></dd>
<dt id="IO_REPARSE_TAG_DFS-constant" class="">IO_REPARSE_TAG_DFS =
</dt>
<dd><pre class="code"><span class='int'>0x8000000A</span></pre></dd>
<dt id="IO_REPARSE_TAG_FILTER_MANAGER-constant" class="">IO_REPARSE_TAG_FILTER_MANAGER =
</dt>
<dd><pre class="code"><span class='int'>0x8000000B</span></pre></dd>
<dt id="IO_REPARSE_TAG_SYMLINK-constant" class="">IO_REPARSE_TAG_SYMLINK =
</dt>
<dd><pre class="code"><span class='int'>0xA000000C</span></pre></dd>
<dt id="IO_REPARSE_TAG_IIS_CACHE-constant" class="">IO_REPARSE_TAG_IIS_CACHE =
</dt>
<dd><pre class="code"><span class='int'>0xA0000010</span></pre></dd>
<dt id="IO_REPARSE_TAG_DFSR-constant" class="">IO_REPARSE_TAG_DFSR =
</dt>
<dd><pre class="code"><span class='int'>0x80000012</span></pre></dd>
<dt id="IO_REPARSE_TAG_DEDUP-constant" class="">IO_REPARSE_TAG_DEDUP =
</dt>
<dd><pre class="code"><span class='int'>0x80000013</span></pre></dd>
<dt id="IO_REPARSE_TAG_APPXSTRM-constant" class="">IO_REPARSE_TAG_APPXSTRM =
</dt>
<dd><pre class="code"><span class='int'>0xC0000014</span></pre></dd>
<dt id="IO_REPARSE_TAG_NFS-constant" class="">IO_REPARSE_TAG_NFS =
</dt>
<dd><pre class="code"><span class='int'>0x80000014</span></pre></dd>
<dt id="IO_REPARSE_TAG_FILE_PLACEHOLDER-constant" class="">IO_REPARSE_TAG_FILE_PLACEHOLDER =
</dt>
<dd><pre class="code"><span class='int'>0x80000015</span></pre></dd>
<dt id="IO_REPARSE_TAG_DFM-constant" class="">IO_REPARSE_TAG_DFM =
</dt>
<dd><pre class="code"><span class='int'>0x80000016</span></pre></dd>
<dt id="IO_REPARSE_TAG_WOF-constant" class="">IO_REPARSE_TAG_WOF =
</dt>
<dd><pre class="code"><span class='int'>0x80000017</span></pre></dd>
<dt id="FSCTL_SET_REPARSE_POINT-constant" class="">FSCTL_SET_REPARSE_POINT =
</dt>
<dd><pre class="code"><span class='int'>0x000900a4</span></pre></dd>
<dt id="FSCTL_DELETE_REPARSE_POINT-constant" class="">FSCTL_DELETE_REPARSE_POINT =
</dt>
<dd><pre class="code"><span class='int'>0x000900ac</span></pre></dd>
</dl>
<h3 class="inherited">Constants included
from <span class='object_link'><a href="Error.html" title="Msf::Post::Windows::Error (module)">Error</a></span></h3>
<p class="inherited"><span class='object_link'><a href="Error.html#ABANDONED_WAIT_0-constant" title="Msf::Post::Windows::Error::ABANDONED_WAIT_0 (constant)">Error::ABANDONED_WAIT_0</a></span>, <span class='object_link'><a href="Error.html#ABANDONED_WAIT_63-constant" title="Msf::Post::Windows::Error::ABANDONED_WAIT_63 (constant)">Error::ABANDONED_WAIT_63</a></span>, <span class='object_link'><a href="Error.html#ABANDON_HIBERFILE-constant" title="Msf::Post::Windows::Error::ABANDON_HIBERFILE (constant)">Error::ABANDON_HIBERFILE</a></span>, <span class='object_link'><a href="Error.html#ABIOS_ERROR-constant" title="Msf::Post::Windows::Error::ABIOS_ERROR (constant)">Error::ABIOS_ERROR</a></span>, <span class='object_link'><a href="Error.html#ACCESS_AUDIT_BY_POLICY-constant" title="Msf::Post::Windows::Error::ACCESS_AUDIT_BY_POLICY (constant)">Error::ACCESS_AUDIT_BY_POLICY</a></span>, <span class='object_link'><a href="Error.html#ACCESS_DENIED-constant" title="Msf::Post::Windows::Error::ACCESS_DENIED (constant)">Error::ACCESS_DENIED</a></span>, <span class='object_link'><a href="Error.html#ACCESS_DISABLED_BY_POLICY-constant" title="Msf::Post::Windows::Error::ACCESS_DISABLED_BY_POLICY (constant)">Error::ACCESS_DISABLED_BY_POLICY</a></span>, <span class='object_link'><a href="Error.html#ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY-constant" title="Msf::Post::Windows::Error::ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY (constant)">Error::ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY</a></span>, <span class='object_link'><a href="Error.html#ACCESS_DISABLED_WEBBLADE-constant" title="Msf::Post::Windows::Error::ACCESS_DISABLED_WEBBLADE (constant)">Error::ACCESS_DISABLED_WEBBLADE</a></span>, <span class='object_link'><a href="Error.html#ACCESS_DISABLED_WEBBLADE_TAMPER-constant" title="Msf::Post::Windows::Error::ACCESS_DISABLED_WEBBLADE_TAMPER (constant)">Error::ACCESS_DISABLED_WEBBLADE_TAMPER</a></span>, <span class='object_link'><a href="Error.html#ACCOUNT_DISABLED-constant" title="Msf::Post::Windows::Error::ACCOUNT_DISABLED (constant)">Error::ACCOUNT_DISABLED</a></span>, <span class='object_link'><a href="Error.html#ACCOUNT_EXPIRED-constant" title="Msf::Post::Windows::Error::ACCOUNT_EXPIRED (constant)">Error::ACCOUNT_EXPIRED</a></span>, <span class='object_link'><a href="Error.html#ACCOUNT_LOCKED_OUT-constant" title="Msf::Post::Windows::Error::ACCOUNT_LOCKED_OUT (constant)">Error::ACCOUNT_LOCKED_OUT</a></span>, <span class='object_link'><a href="Error.html#ACCOUNT_RESTRICTION-constant" title="Msf::Post::Windows::Error::ACCOUNT_RESTRICTION (constant)">Error::ACCOUNT_RESTRICTION</a></span>, <span class='object_link'><a href="Error.html#ACPI_ERROR-constant" title="Msf::Post::Windows::Error::ACPI_ERROR (constant)">Error::ACPI_ERROR</a></span>, <span class='object_link'><a href="Error.html#ACTIVATION_COUNT_EXCEEDED-constant" title="Msf::Post::Windows::Error::ACTIVATION_COUNT_EXCEEDED (constant)">Error::ACTIVATION_COUNT_EXCEEDED</a></span>, <span class='object_link'><a href="Error.html#ACTIVE_CONNECTIONS-constant" title="Msf::Post::Windows::Error::ACTIVE_CONNECTIONS (constant)">Error::ACTIVE_CONNECTIONS</a></span>, <span class='object_link'><a href="Error.html#ADAP_HDW_ERR-constant" title="Msf::Post::Windows::Error::ADAP_HDW_ERR (constant)">Error::ADAP_HDW_ERR</a></span>, <span class='object_link'><a href="Error.html#ADDRESS_ALREADY_ASSOCIATED-constant" title="Msf::Post::Windows::Error::ADDRESS_ALREADY_ASSOCIATED (constant)">Error::ADDRESS_ALREADY_ASSOCIATED</a></span>, <span class='object_link'><a href="Error.html#ADDRESS_NOT_ASSOCIATED-constant" title="Msf::Post::Windows::Error::ADDRESS_NOT_ASSOCIATED (constant)">Error::ADDRESS_NOT_ASSOCIATED</a></span>, <span class='object_link'><a href="Error.html#ADVANCED_INSTALLER_FAILED-constant" title="Msf::Post::Windows::Error::ADVANCED_INSTALLER_FAILED (constant)">Error::ADVANCED_INSTALLER_FAILED</a></span>, <span class='object_link'><a href="Error.html#ALERTED-constant" title="Msf::Post::Windows::Error::ALERTED (constant)">Error::ALERTED</a></span>, <span class='object_link'><a href="Error.html#ALIAS_EXISTS-constan
<h3 class="inherited">Constants included
from <span class='object_link'><a href="../../Exploit/Windows_Constants.html" title="Msf::Exploit::Windows_Constants (module)">Exploit::Windows_Constants</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../../Exploit/Windows_Constants.html#CHANGE_SERVICE_CONFIG2_W-constant" title="Msf::Exploit::Windows_Constants::CHANGE_SERVICE_CONFIG2_W (constant)">Exploit::Windows_Constants::CHANGE_SERVICE_CONFIG2_W</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#CHANGE_SERVICE_CONFIG_W-constant" title="Msf::Exploit::Windows_Constants::CHANGE_SERVICE_CONFIG_W (constant)">Exploit::Windows_Constants::CHANGE_SERVICE_CONFIG_W</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#CLOSE_SERVICE_HANDLE-constant" title="Msf::Exploit::Windows_Constants::CLOSE_SERVICE_HANDLE (constant)">Exploit::Windows_Constants::CLOSE_SERVICE_HANDLE</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#CONTROL_SERVICE-constant" title="Msf::Exploit::Windows_Constants::CONTROL_SERVICE (constant)">Exploit::Windows_Constants::CONTROL_SERVICE</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#CREATE_SERVICE_W-constant" title="Msf::Exploit::Windows_Constants::CREATE_SERVICE_W (constant)">Exploit::Windows_Constants::CREATE_SERVICE_W</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#DELETE_SERVICE-constant" title="Msf::Exploit::Windows_Constants::DELETE_SERVICE (constant)">Exploit::Windows_Constants::DELETE_SERVICE</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#OPEN_SC_MANAGER_W-constant" title="Msf::Exploit::Windows_Constants::OPEN_SC_MANAGER_W (constant)">Exploit::Windows_Constants::OPEN_SC_MANAGER_W</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#OPEN_SERVICE_W-constant" title="Msf::Exploit::Windows_Constants::OPEN_SERVICE_W (constant)">Exploit::Windows_Constants::OPEN_SERVICE_W</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#QUERY_SERVICE_STATUS-constant" title="Msf::Exploit::Windows_Constants::QUERY_SERVICE_STATUS (constant)">Exploit::Windows_Constants::QUERY_SERVICE_STATUS</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_ALL_ACCESS-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_ALL_ACCESS (constant)">Exploit::Windows_Constants::SC_MANAGER_ALL_ACCESS</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_CONNECT-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_CONNECT (constant)">Exploit::Windows_Constants::SC_MANAGER_CONNECT</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_CREATE_SERVICE-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_CREATE_SERVICE (constant)">Exploit::Windows_Constants::SC_MANAGER_CREATE_SERVICE</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_ENUMERATE_SERVICE-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_ENUMERATE_SERVICE (constant)">Exploit::Windows_Constants::SC_MANAGER_ENUMERATE_SERVICE</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_LOCK-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_LOCK (constant)">Exploit::Windows_Constants::SC_MANAGER_LOCK</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_MODIFY_BOOT_CONFIG-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_MODIFY_BOOT_CONFIG (constant)">Exploit::Windows_Constants::SC_MANAGER_MODIFY_BOOT_CONFIG</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SC_MANAGER_QUERY_LOCK_STATUS-constant" title="Msf::Exploit::Windows_Constants::SC_MANAGER_QUERY_LOCK_STATUS (constant)">Exploit::Windows_Constants::SC_MANAGER_QUERY_LOCK_STATUS</a></span>, <span class='object_link'><a href="../../Exploit/Windows_Constants.html#SERVICE_ACCEPT_HARDWAREPROFILECHANGE-constant" title="Msf::Exploit::Windows_Constants::SERVICE_ACCEPT_HARDWAREPROFILECHANGE (constant)">Exploit::Windows_Constants::SERVICE_ACCEPT_HARDWARE
<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="#create_mount_point-instance_method" title="#create_mount_point (instance method)">#<strong>create_mount_point</strong>(path, target, print_name = &#39;&#39;) &#x21d2; Integer<sup>?</sup> </a>
(also: #create_junction)
</span>
<span class="summary_desc"><div class='inline'>
<p>Create a “Volume Mount Point” or a “Directory Junction”.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#create_object_symlink-instance_method" title="#create_object_symlink (instance method)">#<strong>create_object_symlink</strong>(_root, link_name, target_name) &#x21d2; Integer<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Create a symbolic link within Object Manager to a resource in a specific Object Manager namespace, which typically tends to be RPC Control`.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#create_symlink-instance_method" title="#create_symlink (instance method)">#<strong>create_symlink</strong>(link_name, target_name, directory: true) &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Create a symbolic link on the file system.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#delete_mount_point-instance_method" title="#delete_mount_point (instance method)">#<strong>delete_mount_point</strong>(path, handle) &#x21d2; nil </a>
(also: #delete_junction)
</span>
<span class="summary_desc"><div class='inline'>
<p>Delete a previously created mount point.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#delete_reparse_point-instance_method" title="#delete_reparse_point (instance method)">#<strong>delete_reparse_point</strong>(handle, reparse_buffer) &#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>(info = {}) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#open_reparse_point-instance_method" title="#open_reparse_point (instance method)">#<strong>open_reparse_point</strong>(path, writable) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#set_reparse_point-instance_method" title="#set_reparse_point (instance method)">#<strong>set_reparse_point</strong>(handle, reparse_buffer) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
</ul>
<h3 class="inherited">Methods included from <span class='object_link'><a href="../Common.html" title="Msf::Post::Common (module)">Common</a></span></h3>
<p class="inherited"><span class='object_link'><a href="../Common.html#clear_screen-instance_method" title="Msf::Post::Common#clear_screen (method)">#clear_screen</a></span>, <span class='object_link'><a href="../Common.html#cmd_exec-instance_method" title="Msf::Post::Common#cmd_exec (method)">#cmd_exec</a></span>, <span class='object_link'><a href="../Common.html#cmd_exec_get_pid-instance_method" title="Msf::Post::Common#cmd_exec_get_pid (method)">#cmd_exec_get_pid</a></span>, <span class='object_link'><a href="../Common.html#cmd_exec_with_result-instance_method" title="Msf::Post::Common#cmd_exec_with_result (method)">#cmd_exec_with_result</a></span>, <span class='object_link'><a href="../Common.html#command_exists%3F-instance_method" title="Msf::Post::Common#command_exists? (method)">#command_exists?</a></span>, <span class='object_link'><a href="../Common.html#create_process-instance_method" title="Msf::Post::Common#create_process (method)">#create_process</a></span>, <span class='object_link'><a href="../Common.html#get_env-instance_method" title="Msf::Post::Common#get_env (method)">#get_env</a></span>, <span class='object_link'><a href="../Common.html#get_envs-instance_method" title="Msf::Post::Common#get_envs (method)">#get_envs</a></span>, <span class='object_link'><a href="../Common.html#peer-instance_method" title="Msf::Post::Common#peer (method)">#peer</a></span>, <span class='object_link'><a href="../Common.html#report_virtualization-instance_method" title="Msf::Post::Common#report_virtualization (method)">#report_virtualization</a></span>, <span class='object_link'><a href="../Common.html#rhost-instance_method" title="Msf::Post::Common#rhost (method)">#rhost</a></span>, <span class='object_link'><a href="../Common.html#rport-instance_method" title="Msf::Post::Common#rport (method)">#rport</a></span></p>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="create_mount_point-instance_method">
#<strong>create_mount_point</strong>(path, target, print_name = &#39;&#39;) &#x21d2; <tt>Integer</tt><sup>?</sup>
<span class="aliases">Also known as:
<span class="names"><span id='create_junction-instance_method'>create_junction</span></span>
</span>
</h3><div class="docstring">
<div class="discussion">
<p>Create a “Volume Mount Point” or a “Directory Junction”. The difference between the two is that a Directory Junction targets a subdirectory of another volume where as a Volume Mount Point targets the root of a volume. This function is a suitable replacement for the mklink /J` shell command.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path of where to place the mount point. This path must be an existing, empty directory.</p>
</div>
</li>
<li>
<span class='name'>target</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The target of what to mount at the specified path.</p>
</div>
</li>
<li>
<span class='name'>print_name</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>The optional print name string. This string provides a way to display a more user friendly path name identifying the target.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>, <tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>The handle to the reparse point which should be kept for use with <span class='object_link'><a href="#delete_mount_point-instance_method" title="Msf::Post::Windows::FileSystem#delete_mount_point (method)">#delete_mount_point</a></span> or nil on failure.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><a href="https://en.wikipedia.org/wiki/NTFS_reparse_point#Volume_mount_points" target="_parent" title="https://en.wikipedia.org/wiki/NTFS_reparse_point#Volume_mount_points">https://en.wikipedia.org/wiki/NTFS_reparse_point#Volume_mount_points</a></li>
<li><a href="https://nixhacker.com/understanding-and-exploiting-symbolic-link-in-windows/" target="_parent" title="https://nixhacker.com/understanding-and-exploiting-symbolic-link-in-windows/">https://nixhacker.com/understanding-and-exploiting-symbolic-link-in-windows/</a></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
334
335
336
337
338
339
340
341
342
343
344
345</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 334</span>
<span class='kw'>def</span> <span class='id identifier rubyid_create_mount_point'>create_mount_point</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_print_name'>print_name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>||</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_fixed_target'>fixed_target</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>\\</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_target'>target</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\??\\</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_target'>target</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
<span class='id identifier rubyid_reparse_data'>reparse_data</span> <span class='op'>=</span> <span class='id identifier rubyid_build_reparse_data_buffer'>build_reparse_data_buffer</span><span class='lparen'>(</span><span class='id identifier rubyid_fixed_target'>fixed_target</span><span class='comma'>,</span> <span class='id identifier rubyid_print_name'>print_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_handle'>handle</span> <span class='op'>=</span> <span class='id identifier rubyid_open_reparse_point'>open_reparse_point</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_handle'>handle</span>
<span class='id identifier rubyid_set_reparse_point'>set_reparse_point</span><span class='lparen'>(</span><span class='id identifier rubyid_handle'>handle</span><span class='comma'>,</span> <span class='id identifier rubyid_reparse_data'>reparse_data</span><span class='period'>.</span><span class='id identifier rubyid_to_binary_s'>to_binary_s</span><span class='rparen'>)</span>
<span class='id identifier rubyid_handle'>handle</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="create_object_symlink-instance_method">
#<strong>create_object_symlink</strong>(_root, link_name, target_name) &#x21d2; <tt>Integer</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Create a symbolic link within Object Manager to a resource in a specific Object Manager namespace, which typically tends to be RPC Control`. The `Driver` and `Global??` namespaces can also be utilized if the current user has the appropriate privileges. The namespace is determined by the prefix of the name parameters.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>_root</span>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>A parameter reserved for future use.</p>
</div>
</li>
<li>
<span class='name'>link_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path at which to create the symbolic link.</p>
</div>
</li>
<li>
<span class='name'>target_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path that the new symbolic link targets.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Integer</tt>, <tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>The handle to the new symbolic link or nil on failure.</p>
</div>
</li>
</ul>
<p class="tag_title">See Also:</p>
<ul class="see">
<li><a href="https://nixhacker.com/understanding-and-exploiting-symbolic-link-in-windows/" target="_parent" title="https://nixhacker.com/understanding-and-exploiting-symbolic-link-in-windows/">https://nixhacker.com/understanding-and-exploiting-symbolic-link-in-windows/</a></li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 264</span>
<span class='kw'>def</span> <span class='id identifier rubyid_create_object_symlink'>create_object_symlink</span><span class='lparen'>(</span><span class='id identifier rubyid__root'>_root</span><span class='comma'>,</span> <span class='id identifier rubyid_link_name'>link_name</span><span class='comma'>,</span> <span class='id identifier rubyid_target_name'>target_name</span><span class='rparen'>)</span>
<span class='id identifier rubyid_process'>process</span> <span class='op'>=</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_sys'>sys</span><span class='period'>.</span><span class='id identifier rubyid_process'>process</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span>
<span class='id identifier rubyid_unicode_str'>unicode_str</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_unicode_str_in_memory'>setup_unicode_str_in_memory</span><span class='lparen'>(</span><span class='id identifier rubyid_process'>process</span><span class='comma'>,</span> <span class='id identifier rubyid_link_name'>link_name</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_unicode_str'>unicode_str</span>
<span class='id identifier rubyid_p_unicode_buf'>p_unicode_buf</span> <span class='op'>=</span> <span class='id identifier rubyid_write_to_memory'>write_to_memory</span><span class='lparen'>(</span><span class='id identifier rubyid_process'>process</span><span class='comma'>,</span> <span class='id identifier rubyid_unicode_str'>unicode_str</span><span class='period'>.</span><span class='id identifier rubyid_to_binary_s'>to_binary_s</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_p_unicode_buf'>p_unicode_buf</span>
<span class='id identifier rubyid_object_attributes'>object_attributes</span> <span class='op'>=</span> <span class='id identifier rubyid_build_object_attributes'>build_object_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_p_unicode_buf'>p_unicode_buf</span><span class='rparen'>)</span>
<span class='id identifier rubyid_unicode_str'>unicode_str</span> <span class='op'>=</span> <span class='id identifier rubyid_setup_unicode_str_in_memory'>setup_unicode_str_in_memory</span><span class='lparen'>(</span><span class='id identifier rubyid_process'>process</span><span class='comma'>,</span> <span class='id identifier rubyid_target_name'>target_name</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_unicode_str'>unicode_str</span>
<span class='id identifier rubyid_symbolic_link_all_access'>symbolic_link_all_access</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../../Exploit/Windows_Constants.html#STANDARD_RIGHTS_REQUIRED-constant" title="Msf::Exploit::Windows_Constants::STANDARD_RIGHTS_REQUIRED (constant)">STANDARD_RIGHTS_REQUIRED</a></span></span> <span class='op'>|</span> <span class='int'>0x1</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_ntdll'>ntdll</span><span class='period'>.</span><span class='const'>NtCreateSymbolicLinkObject</span><span class='lparen'>(</span>
<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_native_arch'>native_arch</span> <span class='op'>==</span> <span class='const'>ARCH_X64</span> <span class='op'>?</span> <span class='int'>8</span> <span class='op'>:</span> <span class='int'>4</span><span class='comma'>,</span>
<span class='id identifier rubyid_symbolic_link_all_access'>symbolic_link_all_access</span><span class='comma'>,</span>
<span class='id identifier rubyid_object_attributes'>object_attributes</span><span class='period'>.</span><span class='id identifier rubyid_to_binary_s'>to_binary_s</span><span class='comma'>,</span>
<span class='id identifier rubyid_unicode_str'>unicode_str</span><span class='period'>.</span><span class='id identifier rubyid_to_binary_s'>to_binary_s</span>
<span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="Error.html#SUCCESS-constant" title="Msf::Post::Windows::Error::SUCCESS (constant)">SUCCESS</a></span></span>
<span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error creating the symlink. Windows Error Code: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> - </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ErrorMessage</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span>
<span class='kw'>end</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='op'>::</span><span class='const'>WindowsError</span><span class='op'>::</span><span class='const'>NTStatus</span><span class='op'>::</span><span class='const'>STATUS_SUCCESS</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
<span class='id identifier rubyid_error'>error</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>WindowsError</span><span class='op'>::</span><span class='const'>NTStatus</span><span class='period'>.</span><span class='id identifier rubyid_find_by_retval'>find_by_retval</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
<span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Something went wrong while creating the symlink. Return value: NTSTATUS </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_error'>error</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'>return</span> <span class='kw'>nil</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>LinkHandle</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='kw'>ensure</span>
<span class='id identifier rubyid_process'>process</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="create_symlink-instance_method">
#<strong>create_symlink</strong>(link_name, target_name, directory: true) &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Create a symbolic link on the file system. This function is a suitable replacement for the mklink /D` shell command when the <strong>directory</strong> parameter is set to true.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>link_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path at which to create the symbolic link.</p>
</div>
</li>
<li>
<span class='name'>target_name</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path that the new symbolic link targets.</p>
</div>
</li>
<li>
<span class='name'>directory</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>true</tt>)</em>
&mdash;
<div class='inline'>
<p>Whether or not the link target is a directory.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
&mdash;
<div class='inline'>
<p>Returns true on success or false on failure.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
309
310
311
312
313
314
315
316
317
318</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 309</span>
<span class='kw'>def</span> <span class='id identifier rubyid_create_symlink'>create_symlink</span><span class='lparen'>(</span><span class='id identifier rubyid_link_name'>link_name</span><span class='comma'>,</span> <span class='id identifier rubyid_target_name'>target_name</span><span class='comma'>,</span> <span class='label'>directory:</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_flags'>flags</span> <span class='op'>=</span> <span class='id identifier rubyid_directory'>directory</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>SYMBOLIC_LINK_FLAG_DIRECTORY</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_kernel32'>kernel32</span><span class='period'>.</span><span class='const'>CreateSymbolicLinkW</span><span class='lparen'>(</span><span class='id identifier rubyid_link_name'>link_name</span><span class='comma'>,</span> <span class='id identifier rubyid_target_name'>target_name</span><span class='comma'>,</span> <span class='id identifier rubyid_flags'>flags</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="Error.html#SUCCESS-constant" title="Msf::Post::Windows::Error::SUCCESS (constant)">SUCCESS</a></span></span>
<span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error creating the symlink. Windows Error Code: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> - </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ErrorMessage</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>false</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="delete_mount_point-instance_method">
#<strong>delete_mount_point</strong>(path, handle) &#x21d2; <tt>nil</tt>
<span class="aliases">Also known as:
<span class="names"><span id='delete_junction-instance_method'>delete_junction</span></span>
</span>
</h3><div class="docstring">
<div class="discussion">
<p>Delete a previously created mount point. The directory at <strong>path</strong> will be deleted and the <strong>handle</strong> will be closed.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>path</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The path that was mounted.</p>
</div>
</li>
<li>
<span class='name'>handle</span>
<span class='type'>(<tt>Integer</tt>)</span>
&mdash;
<div class='inline'>
<p>The handle returned from <span class='object_link'><a href="#create_mount_point-instance_method" title="Msf::Post::Windows::FileSystem#create_mount_point (method)">#create_mount_point</a></span>.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>nil</tt>)</span>
&mdash;
<div class='inline'>
<p>This function does not return anything.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
243
244
245
246
247
248</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 243</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete_mount_point'>delete_mount_point</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_handle'>handle</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='id identifier rubyid_handle'>handle</span>
<span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_fs'>fs</span><span class='period'>.</span><span class='id identifier rubyid_dir'>dir</span><span class='period'>.</span><span class='id identifier rubyid_rmdir'>rmdir</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span> <span class='comment'># Might need some more logic here.
</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_kernel32'>kernel32</span><span class='period'>.</span><span class='const'>CloseHandle</span><span class='lparen'>(</span><span class='id identifier rubyid_handle'>handle</span><span class='rparen'>)</span>
<span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="delete_reparse_point-instance_method">
#<strong>delete_reparse_point</strong>(handle, reparse_buffer) &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 195</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete_reparse_point'>delete_reparse_point</span><span class='lparen'>(</span><span class='id identifier rubyid_handle'>handle</span><span class='comma'>,</span> <span class='id identifier rubyid_reparse_buffer'>reparse_buffer</span><span class='rparen'>)</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_kernel32'>kernel32</span><span class='period'>.</span><span class='const'>DeviceIoControl</span><span class='lparen'>(</span>
<span class='id identifier rubyid_handle'>handle</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="#FSCTL_DELETE_REPARSE_POINT-constant" title="Msf::Post::Windows::FileSystem::FSCTL_DELETE_REPARSE_POINT (constant)">FSCTL_DELETE_REPARSE_POINT</a></span></span><span class='comma'>,</span>
<span class='id identifier rubyid_reparse_buffer'>reparse_buffer</span><span class='comma'>,</span>
<span class='id identifier rubyid_reparse_buffer'>reparse_buffer</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span>
<span class='kw'>nil</span><span class='comma'>,</span>
<span class='int'>0</span><span class='comma'>,</span>
<span class='int'>4</span><span class='comma'>,</span>
<span class='kw'>nil</span>
<span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error deleting the reparse point. Windows Error Code: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> - </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ErrorMessage</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='op'>-</span><span class='int'>1</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_kernel32'>kernel32</span><span class='period'>.</span><span class='const'>CloseHandle</span><span class='lparen'>(</span><span class='id identifier rubyid_handle'>handle</span><span class='rparen'>)</span>
<span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</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 = {}) &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 11</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='lparen'>(</span>
<span class='id identifier rubyid_update_info'>update_info</span><span class='lparen'>(</span>
<span class='id identifier rubyid_info'>info</span><span class='comma'>,</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Compat</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Meterpreter</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Commands</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='qwords_beg'>%w[</span><span class='words_sep'>
</span><span class='tstring_content'>core_native_arch</span><span class='words_sep'>
</span><span class='tstring_content'>stdapi_fs_delete_dir</span><span class='words_sep'>
</span><span class='tstring_content'>stdapi_railgun_api</span><span class='words_sep'>
</span><span class='tstring_content'>stdapi_sys_process_attach</span><span class='words_sep'>
</span><span class='tstring_content'>stdapi_sys_process_memory_allocate</span><span class='words_sep'>
</span><span class='tstring_content'>stdapi_sys_process_memory_write</span><span class='words_sep'>
</span><span class='tstring_end'>]</span></span>
<span class='rbrace'>}</span>
<span class='rbrace'>}</span>
<span class='rparen'>)</span>
<span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="open_reparse_point-instance_method">
#<strong>open_reparse_point</strong>(path, writable) &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 216</span>
<span class='kw'>def</span> <span class='id identifier rubyid_open_reparse_point'>open_reparse_point</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span> <span class='id identifier rubyid_writable'>writable</span><span class='rparen'>)</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_kernel32'>kernel32</span><span class='period'>.</span><span class='const'>CreateFileW</span><span class='lparen'>(</span>
<span class='id identifier rubyid_path'>path</span><span class='comma'>,</span>
<span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>GENERIC_READ | </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_writable'>writable</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GENERIC_WRITE</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0</span><span class='tstring_end'>&#39;</span></span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
<span class='kw'>nil</span><span class='comma'>,</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>OPEN_EXISTING</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
<span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
<span class='int'>0</span>
<span class='rparen'>)</span>
<span class='id identifier rubyid_handle'>handle</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='kw'>if</span> <span class='id identifier rubyid_handle'>handle</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_handle'>handle</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="Error.html#INVALID_HANDLE_VALUE-constant" title="Msf::Post::Windows::Error::INVALID_HANDLE_VALUE (constant)">INVALID_HANDLE_VALUE</a></span></span>
<span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error opening </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_content'>. Windows Error Code: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> - </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ErrorMessage</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>nil</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_vprint_good'>vprint_good</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Successfully opened </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_path'>path</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_handle'>handle</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="set_reparse_point-instance_method">
#<strong>set_reparse_point</strong>(handle, reparse_buffer) &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/post/windows/file_system.rb', line 177</span>
<span class='kw'>def</span> <span class='id identifier rubyid_set_reparse_point'>set_reparse_point</span><span class='lparen'>(</span><span class='id identifier rubyid_handle'>handle</span><span class='comma'>,</span> <span class='id identifier rubyid_reparse_buffer'>reparse_buffer</span><span class='rparen'>)</span>
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_railgun'>railgun</span><span class='period'>.</span><span class='id identifier rubyid_kernel32'>kernel32</span><span class='period'>.</span><span class='const'>DeviceIoControl</span><span class='lparen'>(</span>
<span class='id identifier rubyid_handle'>handle</span><span class='comma'>,</span>
<span class='const'><span class='object_link'><a href="#FSCTL_SET_REPARSE_POINT-constant" title="Msf::Post::Windows::FileSystem::FSCTL_SET_REPARSE_POINT (constant)">FSCTL_SET_REPARSE_POINT</a></span></span><span class='comma'>,</span>
<span class='id identifier rubyid_reparse_buffer'>reparse_buffer</span><span class='comma'>,</span>
<span class='id identifier rubyid_reparse_buffer'>reparse_buffer</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span>
<span class='kw'>nil</span><span class='comma'>,</span>
<span class='int'>0</span><span class='comma'>,</span>
<span class='int'>4</span><span class='comma'>,</span>
<span class='kw'>nil</span>
<span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='id identifier rubyid_print_error'>print_error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error setting the reparse point. Windows Error Code: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>GetLastError</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> - </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ErrorMessage</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>return</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:01:52 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>