Repository navigation
Expand file tree
/
Copy pathverify.ps1
More file actions
162 lines (140 loc) · 6.51 KB
/
Copy pathverify.ps1
File metadata and controls
162 lines (140 loc) · 6.51 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# WireFox SHA-256 Integrity Auditor
# https://github.com/TalviFox/WireFox
# This script runs independently of WireFox.exe to audit its binary integrity directly against GitHub.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = "Stop"
$foxEmoji = [char]::ConvertFromUtf32(0x1F98A)
$bullet = [char]0x2022
Write-Host @"
=============================================================
$foxEmoji WireFox Binary Integrity Auditor
Independent External Audit Anchor (GitHub TLS)
=============================================================
"@ -ForegroundColor DarkCyan
# 1. Locate the target binary
$targetExe = $null
# Priority 1: Currently running WireFox process
$runningProc = Get-Process -Name "WireFox" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($runningProc) {
try {
$targetExe = $runningProc.MainModule.FileName
}
catch {
$targetExe = (Get-Process -Id $runningProc.Id).Path
}
}
# Priority 2: Standard installation in Program Files
if (-not $targetExe -or -not (Test-Path $targetExe)) {
$standardPath = "$env:ProgramFiles\WireFox\WireFox.exe"
if (Test-Path $standardPath) {
$targetExe = $standardPath
}
}
# Priority 3: Current directory / script directory
if (-not $targetExe -or -not (Test-Path $targetExe)) {
$localPath = Join-Path $PSScriptRoot "WireFox.exe"
$publishPath = Join-Path $PSScriptRoot "publish\WireFox.exe"
if (Test-Path $localPath) {
$targetExe = $localPath
}
elseif (Test-Path $publishPath) {
$targetExe = $publishPath
}
}
if (-not $targetExe -or -not (Test-Path $targetExe)) {
Write-Host "[X] WireFox.exe was not found running or installed at $env:ProgramFiles\WireFox\WireFox.exe." -ForegroundColor Red
Write-Host " If installed in a custom location, please navigate to that directory and run verify.ps1." -ForegroundColor Yellow
return
}
# 2. Compute local file hash and metadata
Write-Host "[*] Auditing target binary: $targetExe" -ForegroundColor Cyan
$fileItem = Get-Item $targetExe
$localVersion = $fileItem.VersionInfo.ProductVersion
if (-not $localVersion) { $localVersion = $fileItem.VersionInfo.FileVersion }
if (-not $localVersion) { $localVersion = "1.0.0" }
$localVersion = $localVersion.Trim()
$localHash = (Get-FileHash -Path $targetExe -Algorithm SHA256).Hash.ToLowerInvariant()
Write-Host " Version Reported: $localVersion" -ForegroundColor White
Write-Host " Local SHA-256: $localHash" -ForegroundColor White
Write-Host ""
# 3. Query official releases on GitHub
$repo = "TalviFox/WireFox"
$apiUrl = "https://api.github.com/repos/$repo/releases"
Write-Host "[*] Querying official releases from GitHub over TLS ($apiUrl)..." -ForegroundColor Cyan
try {
$headers = @{ "User-Agent" = "WireFox-Integrity-Auditor" }
$releases = Invoke-RestMethod -Uri $apiUrl -Headers $headers -UseBasicParsing
}
catch {
Write-Host "[!] Could not query GitHub Releases API: $_" -ForegroundColor Yellow
Write-Host " Please ensure you have an active internet connection." -ForegroundColor DarkYellow
return
}
if (-not $releases -or $releases.Count -eq 0) {
Write-Host "[!] No published GitHub releases found for repository $repo." -ForegroundColor Yellow
return
}
$latestRelease = $releases[0]
$matchedRelease = $null
function Get-ReleaseHash($release) {
# Check assets for SHA256SUMS.txt, checksums.txt, or WireFox.exe.sha256
$sumsAsset = $release.assets | Where-Object { $_.name -match "^(SHA256SUMS|checksums|WireFox.*)\.(txt|sha256)$" -or $_.name -eq "WireFox.exe.sha256" } | Select-Object -First 1
if ($sumsAsset) {
try {
$content = Invoke-RestMethod -Uri $sumsAsset.browser_download_url -Headers $headers -UseBasicParsing
if ($content -match "([a-fA-F0-9]{64})\s+.*WireFox\.exe") {
return $matches[1].ToLowerInvariant()
}
if ($content -match "\b([a-fA-F0-9]{64})\b") {
return $matches[1].ToLowerInvariant()
}
}
catch { }
}
# Check release body for 64-character hex string
if ($release.body -and $release.body -match "\b([a-fA-F0-9]{64})\b") {
return $matches[1].ToLowerInvariant()
}
return $null
}
foreach ($rel in $releases) {
$expectedHash = Get-ReleaseHash $rel
if ($expectedHash -and $expectedHash -eq $localHash) {
$matchedRelease = $rel
break
}
}
Write-Host " -------------------------------------------------------------" -ForegroundColor DarkGray
Write-Host " AUDIT VERDICT:" -ForegroundColor White
if ($matchedRelease) {
if ($matchedRelease.tag_name -eq $latestRelease.tag_name) {
Write-Host " [+] VERIFIED: Binary matches the latest official GitHub release ($($matchedRelease.tag_name))." -ForegroundColor Green
Write-Host " Integrity: 100% Match $bullet Untampered $bullet Up to date" -ForegroundColor Green
}
else {
Write-Host " [i] VERIFIED (HISTORICAL): Binary matches official release ($($matchedRelease.tag_name))." -ForegroundColor Cyan
Write-Host " Integrity: 100% Match $bullet Untampered" -ForegroundColor Cyan
Write-Host " Notice: A newer official release ($($latestRelease.tag_name)) is available on GitHub." -ForegroundColor Yellow
}
}
else {
# Check if reported version matches any release tag
$verMatch = $releases | Where-Object { $_.tag_name.TrimStart('v', 'V') -eq $localVersion } | Select-Object -First 1
if ($verMatch) {
$expected = Get-ReleaseHash $verMatch
Write-Host " [!] CHECKSUM MISMATCH DETECTED!" -ForegroundColor Red
Write-Host " File claims to be: $($verMatch.tag_name)" -ForegroundColor Red
Write-Host " Expected SHA-256: $expected" -ForegroundColor Yellow
Write-Host " Actual Local Hash: $localHash" -ForegroundColor Yellow
Write-Host " WARNING: This binary does not match the official release artifact!" -ForegroundColor Red
}
else {
Write-Host " [*] LOCAL / DEVELOPMENT BUILD" -ForegroundColor Yellow
Write-Host " The running binary does not match any public GitHub release hash." -ForegroundColor DarkYellow
Write-Host " This is expected for self-compiled, test, or pre-release developer builds." -ForegroundColor DarkYellow
}
}
Write-Host " =============================================================" -ForegroundColor DarkCyan
Write-Host ""