-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdepends_win.ps1
91 lines (74 loc) · 2.6 KB
/
depends_win.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<#
This was made because I refuse to continue taking part in the unwritten
PowerShell/Batch obfuscation contest.
#>
param (
[Parameter()]
[Switch]$ForDownload
)
<#
There are myths that some Windows versions do not work without this.
Since I can't be arsed to verify this, I'm just adding this to lower the number
of reports to which I would normally respond with "works on my machine".
#>
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
} catch {
Write-Error "Abandonware operating systems are not supported."
Exit 1
}
$filesDownload = @('aria2c.exe')
$filesConvert = @('aria2c.exe', '7zr.exe', 'uup-converter-wimlib.7z')
$urls = @{
'aria2c.exe' = 'https://github.com/uup-dump/containment-zone/raw/b13fc64447c15ae0c69537ea84277251cc0d9101/aria2c.exe';
'7zr.exe' = 'https://github.com/uup-dump/containment-zone/raw/b13fc64447c15ae0c69537ea84277251cc0d9101/7zr.exe';
'uup-converter-wimlib.7z' = 'https://github.com/uup-dump/containment-zone/raw/b13fc64447c15ae0c69537ea84277251cc0d9101/uup-converter-wimlib.7z';
}
$hashes = @{
'aria2c.exe' = '0ae98794b3523634b0af362d6f8c04a9bbd32aeda959b72ca0e7fc24e84d2a66';
'7zr.exe' = '108ab5f1e36f2068e368fe97cd763c639e403cac8f511c6681eaf19fc585d814';
'uup-converter-wimlib.7z' = '23617e5346de463681b6112025dcd094585bead1ce9f7a265e76d1042b38c964';
}
function Retrieve-File {
param (
[String]$File,
[String]$Url
)
Write-Host -BackgroundColor Black -ForegroundColor Yellow "Downloading ${File}..."
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile "files\$File" -ErrorAction Stop
}
function Test-Hash {
param (
[String]$File,
[String]$Hash
)
Write-Host -BackgroundColor Black -ForegroundColor Cyan "Verifying ${File}..."
$fileHash = (Get-FileHash -Path "files\$File" -Algorithm SHA256 -ErrorAction Stop).Hash
return ($fileHash.ToLower() -eq $Hash)
}
if($ForDownload.IsPresent) {
$files = $filesDownload
} else {
$files = $filesConvert
}
if(-not (Test-Path -PathType Container -Path "files")) {
$null = New-Item -Path "files" -ItemType Directory
}
foreach($file in $files) {
try {
Retrieve-File -File $file -Url $urls[$file]
} catch {
Write-Host "Failed to download $file"
Write-Host $_
Exit 1
}
}
Write-Host ""
<#foreach($file in $files) {
if(-not (Test-Hash -File $file -Hash $hashes[$file])) {
Write-Error "$file appears to be tampered with"
Exit 1
}
}#>
Write-Host ""
Write-Host -BackgroundColor Black -ForegroundColor Green "It appears all the dependencies are ready."