Skip to content

Commit 461649e

Browse files
committed
Land rapid7#8378, Add check in archmigrate to prevent privdesc
2 parents b7b1995 + c73e767 commit 461649e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

modules/post/windows/manage/archmigrate.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class MetasploitModule < Msf::Post
22
include Msf::Post::Windows::Registry
33
include Msf::Post::File
44
include Msf::Post::Common
5+
include Msf::Post::Windows::Priv
56

67
def initialize(info = {})
78
super(update_info(
@@ -21,7 +22,8 @@ def initialize(info = {})
2122
register_options(
2223
[
2324
OptString.new('EXE', [true, 'The executable to start and migrate into', 'C:\windows\sysnative\svchost.exe']),
24-
OptBool.new('FALLBACK', [ true, 'If the selected migration executable does not exist fallback to a sysnative file', true ])
25+
OptBool.new('FALLBACK', [ true, 'If the selected migration executable does not exist fallback to a sysnative file', true ]),
26+
OptBool.new('IGNORE_SYSTEM', [true, 'Migrate even if you have SYSTEM privileges', false])
2527
],
2628
self.class
2729
)
@@ -48,7 +50,7 @@ def get_windows_loc
4850
return windir
4951
end
5052

51-
def run
53+
def do_migrate
5254
if check_32_on_64
5355
print_status('The meterpreter is not the same architecture as the OS! Upgrading!')
5456
newproc = datastore['EXE']
@@ -86,4 +88,18 @@ def run
8688
print_good('The meterpreter is the same architecture as the OS!')
8789
end
8890
end
91+
92+
def run
93+
if datastore['IGNORE_SYSTEM']
94+
do_migrate
95+
elsif !datastore['IGNORE_SYSTEM'] && is_system?
96+
print_error('You are running as SYSTEM! Aborting migration.')
97+
elsif datastore['IGNORE_SYSTEM'] && is_system?
98+
print_error('You are running as SYSTEM! You will lose your privileges!')
99+
do_migrate
100+
elsif !datastore['IGNORE_SYSTEM'] && !is_system?
101+
print_status('You\'re not running as SYSTEM. Moving on...')
102+
do_migrate
103+
end
104+
end
89105
end

0 commit comments

Comments
 (0)