Advertisement
Infernite0069

infer

Aug 23rd, 2024
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ErrorActionPreference = "Stop"
  2.  
  3. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  4.  
  5. $DownloadURL1 = 'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/35e044ddc85eed60b27b37c48371bd19cdc678b7/MAS/All-In-One-Version/MAS_AIO-CRC32_8C3AA7E0.cmd'
  6. $DownloadURL2 = 'https://bitbucket.org/WindowsAddict/microsoft-activation-scripts/raw/35e044ddc85eed60b27b37c48371bd19cdc678b7/MAS/All-In-One-Version/MAS_AIO-CRC32_8C3AA7E0.cmd'
  7.  
  8. $URLs = @($DownloadURL1, $DownloadURL2)
  9. $RandomURL1 = Get-Random -InputObject $URLs
  10. $RandomURL2 = ($URLs -ne $RandomURL1)[0]
  11.  
  12. try {
  13.     $response = Invoke-WebRequest -Uri $RandomURL1 -UseBasicParsing
  14. }
  15. catch {
  16.     $response = Invoke-WebRequest -Uri $RandomURL2 -UseBasicParsing
  17. }
  18.  
  19. # Verify script integrity
  20. $releaseHash = 'D666A4C7810B9D3FE9749F2D4E15C5A65D4AC0D7F0B14A144D6631CE61CC5DF3'
  21. $stream = New-Object IO.MemoryStream
  22. $writer = New-Object IO.StreamWriter $stream
  23. $writer.Write($response)
  24. $writer.Flush()
  25. $stream.Position = 0
  26. $hash = [BitConverter]::ToString([Security.Cryptography.SHA256]::Create().ComputeHash($stream)) -replace '-'
  27. if ($hash -ne $releaseHash) {
  28.     Write-Warning "Hash ($hash) mismatch, aborting!`nReport this issue at https://massgrave.dev/troubleshoot"
  29.     $response = $null
  30.     return
  31. }
  32.  
  33. $rand = [Guid]::NewGuid().Guid
  34. $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544')
  35. $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MAS_$rand.cmd" } else { "$env:TEMP\MAS_$rand.cmd" }
  36.  
  37. $ScriptArgs = "$args "
  38. $prefix = "@::: $rand `r`n"
  39. $content = $prefix + $response
  40. Set-Content -Path $FilePath -Value $content
  41.  
  42. $env:ComSpec = "$env:SystemRoot\system32\cmd.exe"
  43. Start-Process cmd.exe "/c """"$FilePath"" $ScriptArgs""" -Wait
  44.  
  45. $FilePaths = @("$env:TEMP\MAS*.cmd", "$env:SystemRoot\Temp\MAS*.cmd")
  46. foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement