Exploit database

GH-945bd5267b0d1b94c3f74faf5cda7e5a

blkph0x/cve-2026-83844_poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-83844

5 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files579
blkph0x/cve-2026-83844_pocRevision 193ed44859da
Next files →

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/trace/guest_clipboard_entry.ps1

PowerShell · 11,916 bytes
param(
    [Parameter(Mandatory = $true)]
    [ValidateSet('old', 'new')]
    [string]$Build,
    [switch]$SkipShutdown
)

# One post-open clipboard API trial per disposable guest. Shutdown is normal
# after the flushed result; timeout cleanup is explicit and disqualifying.
$ErrorActionPreference = 'Stop'
$inputRoot = 'C:\PaintLab\Input'
$outputRoot = 'C:\PaintLab\Output'
if ($env:USERNAME -ne 'WDAGUtilityAccount' -or
    -not (Test-Path -LiteralPath $inputRoot -PathType Container) -or
    -not (Test-Path -LiteralPath $outputRoot -PathType Container)) {
    throw 'Guest guard failed: clipboard entry runs only inside the Paint lab guest.'
}
$bootstrapPath = Join-Path $inputRoot 'guest-bootstrap.ps1'
$probePath = Join-Path $inputRoot 'trace\guest_clipboard_probe.ps1'
$bootstrapResultPath = Join-Path $outputRoot 'bootstrap-result.json'
$versions = @{ old='11.2605.81.0'; new='11.2609.401.0' }
$runId = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
$summaryPath = Join-Path $outputRoot "clipboard-batch-$Build-$runId.json"
$summary = [ordered]@{
    schema = 'paint-ab-clipboard-batch-v1'
    build = $Build
    run_id = $runId
    started_utc = (Get-Date).ToUniversalTime().ToString('o')
    status = 'preflight'
    bootstrap = $null
    probe = $null
    failure_cleanup = $null
    error = $null
}

function Invoke-BoundedGuestScript([string]$Script, [string[]]$Arguments,
                                   [int]$TimeoutSeconds, [string]$Label) {
    $stdoutPath = Join-Path $outputRoot "$Label.stdout.txt"
    $stderrPath = Join-Path $outputRoot "$Label.stderr.txt"
    $process = Start-Process -FilePath (Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe') `
        -ArgumentList (@('-NoProfile','-ExecutionPolicy','Bypass','-File',$Script) + $Arguments) `
        -RedirectStandardOutput $stdoutPath -RedirectStandardError $stderrPath `
        -WindowStyle Hidden -PassThru -ErrorAction Stop
    $finished = $process.WaitForExit($TimeoutSeconds * 1000)
    if (-not $finished) {
        Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
        return [ordered]@{ pid=$process.Id; timed_out=$true; has_exited=$false; exit_code=$null
            stdout_path=$stdoutPath; stderr_path=$stderrPath }
    }
    $process.Refresh()
    $exitCode = $null
    if ($process.HasExited) { try { $exitCode = $process.ExitCode } catch { } }
    [ordered]@{ pid=$process.Id; timed_out=$false; has_exited=[bool]$process.HasExited; exit_code=$exitCode
        stdout_path=$stdoutPath; stderr_path=$stderrPath }
}

function Invoke-FailureCleanup {
    $cleanup = [ordered]@{
        cdb_forced_pids = @()
        paint_close_requested_pids = @()
        paint_forced_pids = @()
        paint_remaining_pids = @()
    }
    $cdb = @(Get-Process -Name cdb -ErrorAction SilentlyContinue)
    $cleanup.cdb_forced_pids = @($cdb | ForEach-Object { $_.Id })
    foreach ($process in $cdb) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue }
    $paint = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
    foreach ($process in $paint) {
        try {
            if ($process.MainWindowHandle -ne [IntPtr]::Zero -and $process.CloseMainWindow()) {
                $cleanup.paint_close_requested_pids += $process.Id
            }
        } catch { }
    }
    $deadline = (Get-Date).AddSeconds(5)
    do {
        $left = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
        if ($left.Count -eq 0) { break }
        Start-Sleep -Milliseconds 250
    } while ((Get-Date) -lt $deadline)
    $cleanup.paint_forced_pids = @($left | ForEach-Object { $_.Id })
    foreach ($process in $left) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue }
    $cleanup.paint_remaining_pids = @(
        Get-Process -Name mspaint -ErrorAction SilentlyContinue | ForEach-Object { $_.Id }
    )
    return $cleanup
}

try {
    foreach ($path in @($bootstrapPath, $probePath)) {
        if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "Guest script missing: $path" }
    }
    $bootstrapStarted = (Get-Date).ToUniversalTime()
    $bootstrapCall = Invoke-BoundedGuestScript $bootstrapPath @('-Build',$Build) 150 'bootstrap-child'
    if ($bootstrapCall.timed_out) { throw 'Guest bootstrap timed out.' }
    $bootstrapFile = Get-Item -LiteralPath $bootstrapResultPath -ErrorAction Stop
    if ($bootstrapFile.LastWriteTimeUtc -lt $bootstrapStarted.AddSeconds(-2)) {
        throw 'Guest bootstrap result predates this invocation.'
    }
    $bootstrap = Get-Content -LiteralPath $bootstrapResultPath -Raw | ConvertFrom-Json
    $summary.bootstrap = [ordered]@{
        script_exit_code = $bootstrapCall.exit_code
        child_exited_verified = $bootstrapCall.has_exited
        result_sha256 = (Get-FileHash -LiteralPath $bootstrapResultPath -Algorithm SHA256).Hash.ToLowerInvariant()
        stage = $bootstrap.stage
        installed_version = $bootstrap.installed_paint.version
        error = $bootstrap.error
        stdout_path = $bootstrapCall.stdout_path
        stderr_path = $bootstrapCall.stderr_path
    }
    if (-not $bootstrapCall.has_exited -or $bootstrap.stage -ne 'complete' -or
        [string]$bootstrap.installed_paint.version -ne $versions[$Build] -or
        ($null -ne $bootstrapCall.exit_code -and $bootstrapCall.exit_code -ne 0) -or
        (Get-Item -LiteralPath $bootstrapCall.stderr_path).Length -ne 0) {
        throw 'Signed-package bootstrap or activation did not complete.'
    }
    $summary.status = 'running'
    $probeStarted = (Get-Date).ToUniversalTime()
    $call = Invoke-BoundedGuestScript $probePath @('-Build',$Build) 120 'clipboard-probe-child'
    $summary.probe = [ordered]@{
        timed_out = $call.timed_out
        child_exited_verified = $call.has_exited
        script_exit_code = $call.exit_code
        stdout_path = $call.stdout_path
        stderr_path = $call.stderr_path
        result_path = $null
        result_sha256 = $null
        capture_sha256 = $null
        close_sha256 = $null
        status = 'missing_result'
        error = $null
    }
    $caseRoot = Join-Path $outputRoot "clipboard-api\$Build"
    $resultFile = if (Test-Path -LiteralPath $caseRoot -PathType Container) {
        Get-ChildItem -LiteralPath $caseRoot -Recurse -Filter 'result.json' -File |
            Where-Object { $_.LastWriteTimeUtc -ge $probeStarted.AddSeconds(-2) } |
            Sort-Object LastWriteTimeUtc -Descending | Select-Object -First 1
    } else { $null }
    if (-not $resultFile) { throw 'Clipboard probe did not write a fresh result.' }
    $result = Get-Content -LiteralPath $resultFile.FullName -Raw | ConvertFrom-Json
    $summary.probe.result_path = $resultFile.FullName
    $summary.probe.result_sha256 = (Get-FileHash -LiteralPath $resultFile.FullName -Algorithm SHA256).Hash.ToLowerInvariant()
    $summary.probe.status = $result.status
    $summary.probe.error = $result.error
    if ($result.status -eq 'complete') {
        $caseDir = Split-Path -Parent $resultFile.FullName
        $capturePath = Join-Path $caseDir 'capture.json'
        $closePath = Join-Path $caseDir 'close.json'
        foreach ($path in @($capturePath, $closePath)) {
            if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
                throw "Complete clipboard probe is missing linked evidence: $path"
            }
        }
        if ($resultFile.Length -gt 65536 -or
            (Get-Item -LiteralPath $capturePath).Length -gt 65536 -or
            (Get-Item -LiteralPath $closePath).Length -gt 16384) {
            throw 'Clipboard evidence exceeds its bounded JSON size.'
        }
        $summary.probe.capture_sha256 = (Get-FileHash -LiteralPath $capturePath -Algorithm SHA256).Hash.ToLowerInvariant()
        $summary.probe.close_sha256 = (Get-FileHash -LiteralPath $closePath -Algorithm SHA256).Hash.ToLowerInvariant()
        if ($summary.probe.capture_sha256 -ne [string]$result.capture_sha256 -or
            $summary.probe.close_sha256 -ne [string]$result.close_sha256) {
            throw 'Final clipboard result does not hash-link capture and close evidence.'
        }
        $capture = Get-Content -LiteralPath $capturePath -Raw | ConvertFrom-Json
        $close = Get-Content -LiteralPath $closePath -Raw | ConvertFrom-Json
        if ($capture.clipboard_readback -isnot [string] -or
            $result.clipboard_readback -isnot [string] -or
            $capture.clipboard_readback.Length -gt 512 -or
            $result.clipboard_readback.Length -gt 512) {
            throw 'Clipboard readback was not serialized as a bounded string.'
        }
        if ($capture.schema -ne 'paint-ab-clipboard-api-v1' -or
            $capture.status -ne 'partial_capture' -or
            $close.schema -ne 'paint-ab-clipboard-close-v1' -or
            $capture.build -ne $Build -or $close.build -ne $Build -or
            $capture.run_id -ne $result.run_id -or $close.run_id -ne $result.run_id -or
            $capture.clipboard_readback -ne $result.clipboard_readback -or
            $capture.base_fixture_sha256 -ne $result.base_fixture_sha256 -or
            $capture.dib_fixture_sha256 -ne $result.dib_fixture_sha256) {
            throw 'Capture, close, and result identities differ.'
        }
        foreach ($name in @('before-paste','paste-before-esc','paste-after-enter','paste-after-esc')) {
            $key = $name.Replace('-', '_')
            $imagePath = Join-Path $caseDir "$name.png"
            if (-not (Test-Path -LiteralPath $imagePath -PathType Leaf) -or
                (Get-FileHash -LiteralPath $imagePath -Algorithm SHA256).Hash.ToLowerInvariant() -ne
                [string]$capture.screenshot_sha256.$key) {
                throw "Capture screenshot hash mismatch: $name"
            }
        }
        $recorded = @($result.markers_before_paste) + @($result.markers_after_paste)
        if ($result.cdb_initial_pid -ne $result.paint_pid -or
            @($result.marker_pid_records).Count -ne $recorded.Count -or
            (@($result.marker_pid_records | ForEach-Object { $_.marker }) -join ',') -cne ($recorded -join ',') -or
            @($result.marker_pid_records | Where-Object { $_.pid -ne $result.paint_pid }).Count -gt 0 -or
            @($close.forced_pids).Count -ne 0 -or @($close.remaining_pids).Count -ne 0 -or
            $close.close_requested_pids -notcontains $result.paint_pid -or
            $close.debugger_forced_close -or $result.debugger_forced_close) {
            throw 'Debugger PID binding or normal close evidence is incomplete.'
        }
    }
    $summary.status = if (-not $call.timed_out -and $call.has_exited -and
        ($null -eq $call.exit_code -or $call.exit_code -eq 0) -and
        $result.status -eq 'complete' -and $result.build -eq $Build -and -not $result.error -and
        (Get-Item -LiteralPath $call.stderr_path).Length -eq 0) {
        'complete'
    } else { 'review_required' }
} catch {
    $summary.status = 'failed'
    $summary.error = $_.Exception.Message
} finally {
    if ($summary.status -ne 'complete') { $summary.failure_cleanup = Invoke-FailureCleanup }
    $summary.completed_utc = (Get-Date).ToUniversalTime().ToString('o')
    $summary | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $summaryPath -Encoding UTF8
    $null = Get-FileHash -LiteralPath $summaryPath -Algorithm SHA256
    Write-Output "Clipboard API batch $($summary.status): $summaryPath"
    if (-not $SkipShutdown) {
        & (Join-Path $env:WINDIR 'System32\shutdown.exe') /s /t 20 /c 'Paint clipboard API trial complete'
        [ordered]@{
            requested_utc = (Get-Date).ToUniversalTime().ToString('o')
            method = 'normal shutdown /s /t 20; no /f'
            exit_code = $LASTEXITCODE
        } | ConvertTo-Json -Depth 3 |
            Set-Content -LiteralPath (Join-Path $outputRoot "clipboard-shutdown-$Build-$runId.json") -Encoding UTF8
    }
}