$ErrorActionPreference = 'Stop' function Read-HiddenText { param([string]$Prompt) Write-Host -NoNewline "${Prompt}: " $text = '' while ($true) { $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') if ($key.VirtualKeyCode -eq 13) { # Enter — done Write-Host '' break } elseif ($key.VirtualKeyCode -eq 8) { # Backspace if ($text.Length -gt 0) { $text = $text.Substring(0, $text.Length - 1) Write-Host -NoNewline "`b `b" } } elseif ($key.Character -eq [char]22) { # Ctrl+V — paste via Get-Clipboard (avoids STA threading issue) $clip = Get-Clipboard -Raw if ($clip) { $clip = $clip -replace '[\r\n]+$' $text += $clip Write-Host -NoNewline ('*' * $clip.Length) } } elseif ($key.Character -ne [char]0) { # Normal printable character $text += $key.Character Write-Host -NoNewline '*' } } return $text } function Read-PackChoice { while ($true) { Write-Host '' Write-Host '1. Desktop pack' Write-Host '2. Laptop pack' Write-Host 'Choose 1 or 2: ' -NoNewline $key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') if ($key.Character -eq '1') { Write-Host '1' return 'd' } if ($key.Character -eq '2') { Write-Host '2' return 'l' } } } $slug = Read-PackChoice $password = Read-HiddenText 'Enter file password' $downloadUrl = "https://d.5y3.site/$slug" $tempDir = Join-Path $env:TEMP ("5y3-pack-" + [guid]::NewGuid().ToString('N')) $archivePath = Join-Path $tempDir 'package.7z' $7zipInstaller = Join-Path $env:TEMP '7zip-installer.exe' $7zipExe = 'C:\Program Files\7-Zip\7z.exe' New-Item -ItemType Directory -Path $tempDir -Force | Out-Null try { # Download and install 7-Zip if not already present if (Test-Path $7zipExe) { Write-Host "7-Zip already installed, skipping..." } else { Write-Host "Downloading 7-Zip..." Invoke-WebRequest -Uri "https://www.7-zip.org/a/7z2301-x64.exe" -OutFile $7zipInstaller Write-Host "Installing 7-Zip..." Start-Process -Wait $7zipInstaller -ArgumentList "/S" } # Download the pack archive (POST with url-encoded password via curl) Write-Host "Downloading pack..." Add-Type -AssemblyName System.Web $password = $password.Trim() Write-Host "Password length: $($password.Length)" $encodedPassword = [System.Web.HttpUtility]::UrlEncode($password) Write-Host "Encoded: $encodedPassword" $curlArgs = @( '-s', '-X', 'POST', '-H', 'Content-Type: application/x-www-form-urlencoded', '-d', "itemPassword=$encodedPassword", '-o', $archivePath, '-w', '%{http_code}', $downloadUrl ) $httpCode = & curl.exe @curlArgs Write-Host "HTTP $httpCode" if ($LASTEXITCODE -ne 0) { throw "Download failed (curl exit code $LASTEXITCODE)." } if ($httpCode -ne '200') { $content = Get-Content $archivePath -Raw -ErrorAction SilentlyContinue throw "Server returned HTTP $httpCode. Response:`n$content" } # Verify the downloaded file is a valid archive $archiveSize = (Get-Item $archivePath).Length if ($archiveSize -lt 10240) { $content = Get-Content $archivePath -Raw -ErrorAction SilentlyContinue throw "Downloaded file is too small ($archiveSize bytes). Server response:`n$content" } # Extract with 7-Zip to C:\ Write-Host "Extracting..." $result = & $7zipExe x $archivePath -o"C:\" -p"$password" -y if ($LASTEXITCODE -ne 0) { $fileContent = Get-Content $archivePath -Raw -ErrorAction SilentlyContinue throw "7-Zip extraction failed with exit code $LASTEXITCODE.`nServer response:`n$fileContent" } Write-Host "Done. Extracted to C:\" -ForegroundColor Green } catch { Write-Error $_.Exception.Message } finally { if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue } if (Test-Path $7zipInstaller) { Remove-Item $7zipInstaller -Force -ErrorAction SilentlyContinue } }