Windows Gather Forensic Imaging - Metasploit


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

Module Overview


Name: Windows Gather Forensic Imaging
Module: post/windows/gather/forensics/imager
Source code: modules/post/windows/gather/forensics/imager.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 will perform byte-for-byte imaging of remote disks and volumes

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/forensics/imager

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/forensics/imager
msf post(imager) > show options
    ... show and set options ...
msf post(imager) > set SESSION session-id
msf post(imager) > 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/forensics/imager")
  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.

  • DEVICE: Device to image (use enum_drives for possible names)

Go back to menu.

Msfconsole Usage


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

msf6 > use post/windows/gather/forensics/imager

msf6 post(windows/gather/forensics/imager) > show info

       Name: Windows Gather Forensic Imaging
     Module: post/windows/gather/forensics/imager
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  Wesley McGrew <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  BLOCKSIZE  1048576          no        Block size, in bytes (multiples of 512)
  COUNT      0                no        Image only this many blocks (0 - read till end)
  DEVICE                      yes       Device to image (use enum_drives for possible names)
  OUTFILE    image            no        Output filename without extension
  SESSION                     yes       The session to run this module on.
  SKIP       0                no        Skip this many blocks before beginning
  SPLIT      1610612736       no        Split image size, in bytes

Description:
  This module will perform byte-for-byte imaging of remote disks and 
  volumes

Module Options


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

msf6 post(windows/gather/forensics/imager) > show options

Module options (post/windows/gather/forensics/imager):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   BLOCKSIZE  1048576          no        Block size, in bytes (multiples of 512)
   COUNT      0                no        Image only this many blocks (0 - read till end)
   DEVICE                      yes       Device to image (use enum_drives for possible names)
   OUTFILE    image            no        Output filename without extension
   SESSION                     yes       The session to run this module on.
   SKIP       0                no        Skip this many blocks before beginning
   SPLIT      1610612736       no        Split image size, in bytes

Advanced Options


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

msf6 post(windows/gather/forensics/imager) > show advanced

Module advanced options (post/windows/gather/forensics/imager):

   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/forensics/imager module can do:

msf6 post(windows/gather/forensics/imager) > show actions

Post actions:

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

Evasion Options


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

msf6 post(windows/gather/forensics/imager) > 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.

Could not open <DEVNAME>


Here is a relevant code snippet related to the "Could not open <DEVNAME>" error message:

56:	    r = client.railgun.kernel32.CreateFileA(devname, "GENERIC_READ",
57:	                                            0x3, nil, "OPEN_EXISTING", "FILE_ATTRIBUTE_READONLY", 0)
58:	    handle = r['return']
59:	
60:	    if handle == invalid_handle_value
61:	      print_error("Could not open #{devname}")
62:	      raise Rex::Script::Completed
63:	    end
64:	
65:	    r = client.railgun.kernel32.DeviceIoControl(handle, fsctl_allow_extended_dasd_io, nil, 0, 0, 0, 4, nil)
66:	

GetLastError


Here is a relevant code snippet related to the "GetLastError" error message:

64:	
65:	    r = client.railgun.kernel32.DeviceIoControl(handle, fsctl_allow_extended_dasd_io, nil, 0, 0, 0, 4, nil)
66:	
67:	    ioctl = client.railgun.kernel32.DeviceIoControl(handle, ioctl_disk_get_drive_geometry_ex,
68:	                                                    "", 0, 200, 200, 4, "")
69:	    if ioctl['GetLastError'] == 6
70:	      ioctl = client.railgun.kernel32.DeviceIoControl(handle, ioctl_disk_get_drive_geometry_ex,
71:	                                                      "", 0, 200, 200, 4, "")
72:	    end
73:	    geometry = ioctl['lpOutBuffer']
74:	

GetLastError


Here is a relevant code snippet related to the "GetLastError" error message:

91:	    while finished != true do
92:	      if skip_counter < skip
93:	        print_line("Skipped #{block_size} bytes")
94:	        r = client.railgun.kernel32.SetFilePointer(handle, block_size, 0, 1)
95:	        if r['return'] == invalid_set_file_pointer
96:	          if r['GetLastError'] != 0
97:	            print_error("Skipped past the end of file?")
98:	            raise Rex::Script::Completed
99:	          end
100:	        end
101:	        skip_counter += 1

Skipped past the end of file?


Here is a relevant code snippet related to the "Skipped past the end of file?" error message:

92:	      if skip_counter < skip
93:	        print_line("Skipped #{block_size} bytes")
94:	        r = client.railgun.kernel32.SetFilePointer(handle, block_size, 0, 1)
95:	        if r['return'] == invalid_set_file_pointer
96:	          if r['GetLastError'] != 0
97:	            print_error("Skipped past the end of file?")
98:	            raise Rex::Script::Completed
99:	          end
100:	        end
101:	        skip_counter += 1
102:	        next

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Wesley McGrew <wesley[at]mcgrewsecurity.com>

Version


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

Go back to menu.