2026-05-15 23:47:10 +02:00
[ CmdletBinding ( ) ]
param ( )
$ErrorActionPreference = " Stop "
Add-Type -AssemblyName System . Windows . Forms
Add-Type -AssemblyName System . Drawing
$script:RootPath = Split-Path -Parent ( Split-Path -Parent $MyInvocation . MyCommand . Path )
$script:RootCertificatePath = Join-Path $script:RootPath " assets\certificates\MrSphay-LocalTrust-Root.cer "
$script:PublisherCertificatePath = Join-Path $script:RootPath " assets\certificates\MrSphay-CodeSigning.cer "
2026-05-16 00:14:46 +02:00
$script:IconPath = Join-Path $script:RootPath " assets\MrTrust.ico "
2026-05-16 13:05:12 +02:00
$script:SelectedFilePath = $null
$script:CurrentAccent = 0
$colors = @ {
2026-05-16 13:43:52 +02:00
Background = [ Drawing.Color ] :: FromArgb ( 15 , 20 , 20 )
Shell = [ Drawing.Color ] :: FromArgb ( 20 , 27 , 27 )
Panel = [ Drawing.Color ] :: FromArgb ( 27 , 36 , 35 )
PanelAlt = [ Drawing.Color ] :: FromArgb ( 34 , 45 , 43 )
PanelSelected = [ Drawing.Color ] :: FromArgb ( 31 , 64 , 49 )
Border = [ Drawing.Color ] :: FromArgb ( 53 , 66 , 64 )
Text = [ Drawing.Color ] :: FromArgb ( 239 , 244 , 241 )
Muted = [ Drawing.Color ] :: FromArgb ( 157 , 172 , 166 )
Green = [ Drawing.Color ] :: FromArgb ( 0 , 175 , 91 )
GreenHover = [ Drawing.Color ] :: FromArgb ( 0 , 199 , 104 )
GreenSoft = [ Drawing.Color ] :: FromArgb ( 34 , 76 , 52 )
2026-05-16 13:05:12 +02:00
Orange = [ Drawing.Color ] :: FromArgb ( 242 , 153 , 74 )
Red = [ Drawing.Color ] :: FromArgb ( 235 , 87 , 87 )
2026-05-16 13:43:52 +02:00
Blue = [ Drawing.Color ] :: FromArgb ( 82 , 166 , 255 )
2026-05-16 13:05:12 +02:00
}
2026-05-15 23:47:10 +02:00
function Test-IsAdministrator {
$identity = [ Security.Principal.WindowsIdentity ] :: GetCurrent ( )
$principal = [ Security.Principal.WindowsPrincipal ] :: new ( $identity )
$principal . IsInRole ( [ Security.Principal.WindowsBuiltInRole ] :: Administrator )
}
function Get-MrTrustCertificate {
param ( [ Parameter ( Mandatory ) ] [ string ] $Path )
if ( -not ( Test-Path -LiteralPath $Path ) ) {
throw " Certificate file not found: $Path "
}
[ System.Security.Cryptography.X509Certificates.X509Certificate2 ] :: new ( $Path )
}
function Get-TrustScope {
2026-05-16 13:05:12 +02:00
if ( $script:AllUsersCheckBox . Checked ) { " LocalMachine " } else { " CurrentUser " }
2026-05-15 23:47:10 +02:00
}
function Get-StorePath {
param (
[ Parameter ( Mandatory ) ] [ string ] $Scope ,
[ Parameter ( Mandatory ) ] [ string ] $Store
)
" Cert:\ $Scope \ $Store "
}
function Test-CertificateInstalled {
param (
[ Parameter ( Mandatory ) ] $Certificate ,
[ Parameter ( Mandatory ) ] [ string ] $Scope ,
[ Parameter ( Mandatory ) ] [ string ] $Store
)
$storePath = Get-StorePath -Scope $Scope -Store $Store
@ ( Get-ChildItem -Path $storePath | Where-Object Thumbprint -eq $Certificate . Thumbprint ) . Count -gt 0
}
2026-05-16 13:05:12 +02:00
function Set-Busy {
param ( [ bool ] $Busy )
$script:ProgressBar . Visible = $Busy
if ( $Busy ) {
$script:ProgressBar . Style = " Marquee "
}
}
2026-05-15 23:47:10 +02:00
function Set-StatusText {
2026-05-16 13:05:12 +02:00
param (
[ Parameter ( Mandatory ) ] [ string ] $Text ,
[ Parameter ( Mandatory ) ] [ Drawing.Color ] $Color
)
2026-05-15 23:47:10 +02:00
$script:StatusLabel . Text = $Text
2026-05-16 13:05:12 +02:00
$script:StatusPill . BackColor = $Color
2026-05-15 23:47:10 +02:00
}
2026-05-16 13:05:12 +02:00
function Add-AnimatedButton {
param (
[ Parameter ( Mandatory ) ] [ Windows.Forms.Button ] $Button ,
[ Parameter ( Mandatory ) ] [ Drawing.Color ] $Normal ,
[ Parameter ( Mandatory ) ] [ Drawing.Color ] $Hover
)
2026-05-16 13:16:32 +02:00
$normalColor = $Normal
$hoverColor = $Hover
$textColor = $colors . Text
$borderColor = $colors . Border
2026-05-16 13:05:12 +02:00
$Button . FlatStyle = " Flat "
2026-05-16 13:16:32 +02:00
$Button . FlatAppearance . BorderColor = $borderColor
2026-05-16 13:05:12 +02:00
$Button . FlatAppearance . BorderSize = 1
2026-05-16 13:16:32 +02:00
$Button . BackColor = $normalColor
$Button . ForeColor = $textColor
2026-05-16 13:05:12 +02:00
$Button . Cursor = [ Windows.Forms.Cursors ] :: Hand
2026-05-16 13:16:32 +02:00
$Button . Add_MouseEnter ( { param ( $sender , $eventArgs ) $sender . BackColor = $hoverColor } . GetNewClosure ( ) )
$Button . Add_MouseLeave ( { param ( $sender , $eventArgs ) $sender . BackColor = $normalColor } . GetNewClosure ( ) )
2026-05-16 13:05:12 +02:00
}
function New-Label {
param (
[ string ] $Text ,
[ int ] $X ,
[ int ] $Y ,
[ int ] $Width = 220 ,
[ int ] $Height = 24 ,
[ Drawing.Color ] $Color = $colors . Muted ,
[ Drawing.Font ] $Font = $null
)
$label = [ Windows.Forms.Label ] :: new ( )
$label . Text = $Text
$label . Location = [ Drawing.Point ] :: new ( $X , $Y )
$label . Size = [ Drawing.Size ] :: new ( $Width , $Height )
$label . ForeColor = $Color
if ( $Font ) { $label . Font = $Font }
$label
}
2026-05-16 13:43:52 +02:00
function New-Card {
param (
[ int ] $X ,
[ int ] $Y ,
[ int ] $Width ,
[ int ] $Height ,
[ Drawing.Color ] $BackColor = $colors . Panel
)
$panel = [ Windows.Forms.Panel ] :: new ( )
$panel . Location = [ Drawing.Point ] :: new ( $X , $Y )
$panel . Size = [ Drawing.Size ] :: new ( $Width , $Height )
$panel . BackColor = $BackColor
$panel . BorderStyle = " FixedSingle "
$panel . Anchor = " Top,Left,Right "
$panel
}
function New-PageTitle {
param (
[ string ] $Title ,
[ string ] $Description
)
$titleLabel = New-Label -Text $Title -X 0 -Y 0 -Width 760 -Height 34 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 15 , [ Drawing.FontStyle ] :: Bold ) )
$descriptionLabel = New-Label -Text $Description -X 1 -Y 38 -Width 850 -Height 24 -Color $colors . Muted
[ pscustomobject ] @ {
Title = $titleLabel
Description = $descriptionLabel
}
}
function New-NavButton {
param (
[ Parameter ( Mandatory ) ] [ string ] $Key ,
[ Parameter ( Mandatory ) ] [ string ] $Text ,
[ Parameter ( Mandatory ) ] [ int ] $Y
)
$button = [ Windows.Forms.Button ] :: new ( )
$button . Text = $Text
$button . Tag = $Key
$button . Size = [ Drawing.Size ] :: new ( 174 , 44 )
$button . Location = [ Drawing.Point ] :: new ( 22 , $Y )
$button . TextAlign = " MiddleLeft "
$button . Padding = [ Windows.Forms.Padding ] :: new ( 14 , 0 , 0 , 0 )
$button . Font = [ Drawing.Font ] :: new ( " Segoe UI " , 10 , [ Drawing.FontStyle ] :: Bold )
$button . FlatStyle = " Flat "
$button . FlatAppearance . BorderSize = 1
$button . FlatAppearance . BorderColor = $colors . Shell
$button . BackColor = $colors . Shell
$button . ForeColor = $colors . Muted
$button . Cursor = [ Windows.Forms.Cursors ] :: Hand
$button . Add_MouseEnter ( { param ( $sender , $eventArgs ) if ( $script:ActivePage -ne $sender . Tag ) { $sender . BackColor = $colors . PanelAlt } } . GetNewClosure ( ) )
$button . Add_MouseLeave ( { param ( $sender , $eventArgs ) if ( $script:ActivePage -ne $sender . Tag ) { $sender . BackColor = $colors . Shell } } . GetNewClosure ( ) )
$button . Add_Click ( { param ( $sender , $eventArgs ) Show-MrTrustPage -Key $sender . Tag } )
$button
}
function Show-MrTrustPage {
param ( [ Parameter ( Mandatory ) ] [ string ] $Key )
$script:ActivePage = $Key
foreach ( $pageKey in $script:Pages . Keys ) {
$script:Pages [ $pageKey ] . Visible = $pageKey -eq $Key
}
foreach ( $buttonKey in $script:NavButtons . Keys ) {
$button = $script:NavButtons [ $buttonKey ]
if ( $buttonKey -eq $Key ) {
$button . BackColor = $colors . PanelSelected
$button . FlatAppearance . BorderColor = $colors . Green
$button . ForeColor = $colors . Text
}
else {
$button . BackColor = $colors . Shell
$button . FlatAppearance . BorderColor = $colors . Shell
$button . ForeColor = $colors . Muted
}
}
}
2026-05-16 13:05:12 +02:00
function Update-TrustStatus {
2026-05-15 23:47:10 +02:00
try {
2026-05-16 13:05:12 +02:00
Set-Busy $true
2026-05-15 23:47:10 +02:00
$rootCertificate = Get-MrTrustCertificate -Path $script:RootCertificatePath
$publisherCertificate = Get-MrTrustCertificate -Path $script:PublisherCertificatePath
$scope = Get-TrustScope
$rootInstalled = Test-CertificateInstalled -Certificate $rootCertificate -Scope $scope -Store " Root "
$publisherInstalled = Test-CertificateInstalled -Certificate $publisherCertificate -Scope $scope -Store " TrustedPublisher "
$script:RootThumbprintLabel . Text = $rootCertificate . Thumbprint
$script:PublisherThumbprintLabel . Text = $publisherCertificate . Thumbprint
$script:ExpiryLabel . Text = $rootCertificate . NotAfter . ToString ( " yyyy-MM-dd " )
2026-05-16 13:05:12 +02:00
$script:ScopeValueLabel . Text = $scope
2026-05-15 23:47:10 +02:00
if ( $rootInstalled -and $publisherInstalled ) {
2026-05-16 13:05:12 +02:00
Set-StatusText -Text " Trusted " -Color $colors . Green
$script:TrustSummaryLabel . Text = " MrSphay public trust is installed for $scope . "
2026-05-15 23:47:10 +02:00
}
else {
2026-05-16 13:05:12 +02:00
Set-StatusText -Text " Not installed " -Color $colors . Orange
$script:TrustSummaryLabel . Text = " Trust is not fully installed for $scope . "
2026-05-15 23:47:10 +02:00
}
}
catch {
2026-05-16 13:05:12 +02:00
Set-StatusText -Text " Error " -Color $colors . Red
$script:TrustSummaryLabel . Text = $_ . Exception . Message
}
finally {
Set-Busy $false
2026-05-15 23:47:10 +02:00
}
}
function Install-MrTrustCertificates {
$scope = Get-TrustScope
if ( $scope -eq " LocalMachine " -and -not ( Test-IsAdministrator ) ) {
2026-05-16 13:05:12 +02:00
[ Windows.Forms.MessageBox ] :: Show ( " All-users trust requires running MrTrust as Administrator. " , " MrTrust " , " OK " , " Warning " ) | Out-Null
2026-05-15 23:47:10 +02:00
return
}
$rootCertificate = Get-MrTrustCertificate -Path $script:RootCertificatePath
$publisherCertificate = Get-MrTrustCertificate -Path $script:PublisherCertificatePath
2026-05-16 13:05:12 +02:00
$message = " Install MrSphay trust for $scope ? `r `n `r `n Root: `r `n $( $rootCertificate . Thumbprint ) `r `n `r `n Publisher: `r `n $( $publisherCertificate . Thumbprint ) `r `n `r `n This does not disable Defender or SmartScreen. "
$result = [ Windows.Forms.MessageBox ] :: Show ( $message , " Install MrTrust " , " YesNo " , " Warning " )
if ( $result -ne [ Windows.Forms.DialogResult ] :: Yes ) { return }
2026-05-15 23:47:10 +02:00
2026-05-16 13:05:12 +02:00
Set-Busy $true
2026-05-15 23:47:10 +02:00
Import-Certificate -FilePath $script:RootCertificatePath -CertStoreLocation ( Get-StorePath -Scope $scope -Store " Root " ) | Out-Null
Import-Certificate -FilePath $script:PublisherCertificatePath -CertStoreLocation ( Get-StorePath -Scope $scope -Store " TrustedPublisher " ) | Out-Null
2026-05-16 13:05:12 +02:00
Update-TrustStatus
2026-05-15 23:47:10 +02:00
}
function Remove-MrTrustCertificates {
$scope = Get-TrustScope
if ( $scope -eq " LocalMachine " -and -not ( Test-IsAdministrator ) ) {
2026-05-16 13:05:12 +02:00
[ Windows.Forms.MessageBox ] :: Show ( " All-users removal requires running MrTrust as Administrator. " , " MrTrust " , " OK " , " Warning " ) | Out-Null
2026-05-15 23:47:10 +02:00
return
}
2026-05-16 13:05:12 +02:00
$result = [ Windows.Forms.MessageBox ] :: Show ( " Remove MrSphay trust for $scope ? " , " Remove MrTrust " , " YesNo " , " Question " )
if ( $result -ne [ Windows.Forms.DialogResult ] :: Yes ) { return }
Set-Busy $true
2026-05-15 23:47:10 +02:00
$rootCertificate = Get-MrTrustCertificate -Path $script:RootCertificatePath
$publisherCertificate = Get-MrTrustCertificate -Path $script:PublisherCertificatePath
$targets = @ (
[ pscustomobject ] @ { Store = " Root " ; Thumbprint = $rootCertificate . Thumbprint } ,
[ pscustomobject ] @ { Store = " TrustedPublisher " ; Thumbprint = $publisherCertificate . Thumbprint }
)
foreach ( $target in $targets ) {
$storePath = Get-StorePath -Scope $scope -Store $target . Store
Get-ChildItem -Path $storePath |
Where-Object Thumbprint -eq $target . Thumbprint |
Remove-Item
}
2026-05-16 13:05:12 +02:00
Update-TrustStatus
}
function Test-MarkOfTheWeb {
param ( [ Parameter ( Mandatory ) ] [ string ] $Path )
try {
$stream = Get-Content -LiteralPath $Path -Stream Zone . Identifier -ErrorAction Stop
( $stream -join " `n " ) -match " ZoneId\s*=\s*[3-4] "
}
catch {
$false
}
}
function Get-SmartScreenExplanation {
param (
[ bool ] $SignedByMrSphay ,
[ bool ] $HasMotw
)
if ( $SignedByMrSphay -and $HasMotw ) {
" Publisher trust can be valid while SmartScreen still warns because the downloaded file has Internet origin and low Microsoft reputation. "
}
elseif ( $SignedByMrSphay ) {
" The publisher matches MrSphay. SmartScreen may still warn until Microsoft reputation builds for this exact app and publisher. "
}
elseif ( $HasMotw ) {
" This file came from the Internet and is not signed by MrSphay. SmartScreen warnings are expected. "
}
else {
" MrTrust can only help with MrSphay-signed files. SmartScreen reputation is separate from local certificate trust. "
}
}
function Test-SelectedFile {
param ( [ Parameter ( Mandatory ) ] [ string ] $Path )
Set-Busy $true
try {
if ( -not ( Test-Path -LiteralPath $Path -PathType Leaf ) ) {
throw " File not found: $Path "
}
$signature = Get-AuthenticodeSignature -LiteralPath $Path
$hasMotw = Test-MarkOfTheWeb -Path $Path
$signer = $signature . SignerCertificate
$signedByMrSphay = $false
if ( $signer ) {
$signedByMrSphay = $signer . Thumbprint -eq " A024A89200469F099EC4A172B4F96F6428AFD41B " -or $signer . Subject -like " *MrSphay* "
}
$script:FileNameLabel . Text = [ IO.Path ] :: GetFileName ( $Path )
$script:FilePathLabel . Text = $Path
$script:SignatureStatusLabel . Text = " $( $signature . Status ) "
$script:SignerLabel . Text = if ( $signer ) { $signer . Subject } else { " No signer certificate " }
$script:MrSphayMatchLabel . Text = if ( $signedByMrSphay ) { " Yes " } else { " No " }
$script:MotwLabel . Text = if ( $hasMotw ) { " Yes " } else { " No " }
$script:SmartScreenLabel . Text = Get-SmartScreenExplanation -SignedByMrSphay $signedByMrSphay -HasMotw $hasMotw
if ( $signedByMrSphay -and $signature . Status -eq " Valid " ) {
$script:FileVerdictLabel . Text = " Looks good: signed by MrSphay and locally valid. "
$script:FileVerdictLabel . ForeColor = $colors . Green
}
elseif ( $signedByMrSphay ) {
$script:FileVerdictLabel . Text = " Signed by MrSphay, but local validation is not fully valid: $( $signature . Status ) "
$script:FileVerdictLabel . ForeColor = $colors . Orange
}
else {
$script:FileVerdictLabel . Text = " Not a MrSphay-signed file. "
$script:FileVerdictLabel . ForeColor = $colors . Red
}
}
catch {
$script:FileVerdictLabel . Text = $_ . Exception . Message
$script:FileVerdictLabel . ForeColor = $colors . Red
}
finally {
Set-Busy $false
}
2026-05-15 23:47:10 +02:00
}
[ Windows.Forms.Application ] :: EnableVisualStyles ( )
$form = [ Windows.Forms.Form ] :: new ( )
$form . Text = " MrTrust "
$form . StartPosition = " CenterScreen "
2026-05-16 13:43:52 +02:00
$form . ClientSize = [ Drawing.Size ] :: new ( 1120 , 720 )
$form . MinimumSize = [ Drawing.Size ] :: new ( 1040 , 680 )
2026-05-16 13:05:12 +02:00
$form . BackColor = $colors . Background
2026-05-15 23:47:10 +02:00
$form . Font = [ Drawing.Font ] :: new ( " Segoe UI " , 10 )
2026-05-16 00:14:46 +02:00
if ( Test-Path -LiteralPath $script:IconPath ) {
$form . Icon = [ Drawing.Icon ] :: new ( $script:IconPath )
}
2026-05-15 23:47:10 +02:00
$header = [ Windows.Forms.Panel ] :: new ( )
$header . Dock = " Top "
2026-05-16 13:43:52 +02:00
$header . Height = 96
$header . BackColor = $colors . Background
2026-05-15 23:47:10 +02:00
$form . Controls . Add ( $header )
2026-05-16 13:43:52 +02:00
$brandLine = [ Windows.Forms.Panel ] :: new ( )
$brandLine . Dock = " Bottom "
$brandLine . Height = 1
$brandLine . BackColor = $colors . Border
$header . Controls . Add ( $brandLine )
2026-05-15 23:47:10 +02:00
2026-05-16 00:14:46 +02:00
$logoBox = [ Windows.Forms.PictureBox ] :: new ( )
2026-05-16 13:43:52 +02:00
$logoBox . Size = [ Drawing.Size ] :: new ( 42 , 42 )
$logoBox . Location = [ Drawing.Point ] :: new ( 28 , 26 )
2026-05-16 00:14:46 +02:00
$logoBox . SizeMode = " StretchImage "
if ( Test-Path -LiteralPath $script:IconPath ) {
$logoBox . Image = [ Drawing.Icon ] :: new ( $script:IconPath ) . ToBitmap ( )
}
$header . Controls . Add ( $logoBox )
2026-05-16 13:43:52 +02:00
$title = New-Label -Text " MrTrust " -X 86 -Y 20 -Width 260 -Height 36 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 18 , [ Drawing.FontStyle ] :: Bold ) )
2026-05-15 23:47:10 +02:00
$header . Controls . Add ( $title )
2026-05-16 13:43:52 +02:00
$subtitle = New-Label -Text " Local certificate trust for MrSphay signed Windows apps " -X 88 -Y 56 -Width 520 -Height 24 -Color $colors . Muted
2026-05-15 23:47:10 +02:00
$header . Controls . Add ( $subtitle )
2026-05-16 13:43:52 +02:00
$statusCard = [ Windows.Forms.Panel ] :: new ( )
$statusCard . Anchor = " Top,Right "
$statusCard . Location = [ Drawing.Point ] :: new ( 780 , 20 )
$statusCard . Size = [ Drawing.Size ] :: new ( 300 , 56 )
$statusCard . BackColor = $colors . Panel
$statusCard . BorderStyle = " FixedSingle "
$header . Controls . Add ( $statusCard )
$statusText = New-Label -Text " Trust status " -X 18 -Y 7 -Width 130 -Height 20 -Color $colors . Muted -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 8.5 ) )
$statusCard . Controls . Add ( $statusText )
2026-05-16 00:14:46 +02:00
2026-05-15 23:47:10 +02:00
$script:StatusPill = [ Windows.Forms.Panel ] :: new ( )
2026-05-16 13:43:52 +02:00
$script:StatusPill . Size = [ Drawing.Size ] :: new ( 14 , 14 )
$script:StatusPill . Location = [ Drawing.Point ] :: new ( 18 , 31 )
2026-05-16 13:05:12 +02:00
$script:StatusPill . BackColor = $colors . Orange
2026-05-16 13:43:52 +02:00
$statusCard . Controls . Add ( $script:StatusPill )
2026-05-15 23:47:10 +02:00
2026-05-16 13:43:52 +02:00
$script:StatusLabel = New-Label -Text " Checking... " -X 40 -Y 26 -Width 210 -Height 24 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 10 , [ Drawing.FontStyle ] :: Bold ) )
2026-05-16 00:14:46 +02:00
$script:StatusLabel . AutoEllipsis = $true
2026-05-16 13:43:52 +02:00
$statusCard . Controls . Add ( $script:StatusLabel )
2026-05-15 23:47:10 +02:00
2026-05-16 13:05:12 +02:00
$script:ProgressBar = [ Windows.Forms.ProgressBar ] :: new ( )
2026-05-16 13:43:52 +02:00
$script:ProgressBar . Anchor = " Top,Left,Right "
$script:ProgressBar . Location = [ Drawing.Point ] :: new ( 28 , 86 )
$script:ProgressBar . Size = [ Drawing.Size ] :: new ( 1052 , 4 )
2026-05-16 13:05:12 +02:00
$script:ProgressBar . Visible = $false
$header . Controls . Add ( $script:ProgressBar )
2026-05-16 13:43:52 +02:00
$shell = [ Windows.Forms.Panel ] :: new ( )
$shell . Dock = " Fill "
$shell . BackColor = $colors . Background
$form . Controls . Add ( $shell )
$sidebar = [ Windows.Forms.Panel ] :: new ( )
$sidebar . Dock = " Left "
$sidebar . Width = 220
$sidebar . BackColor = $colors . Shell
$shell . Controls . Add ( $sidebar )
$sideAccent = [ Windows.Forms.Panel ] :: new ( )
$sideAccent . Dock = " Left "
$sideAccent . Width = 4
$sideAccent . BackColor = $colors . Green
$sidebar . Controls . Add ( $sideAccent )
$navTitle = New-Label -Text " Navigation " -X 24 -Y 26 -Width 160 -Height 22 -Color $colors . Muted -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 8.5 , [ Drawing.FontStyle ] :: Bold ) )
$sidebar . Controls . Add ( $navTitle )
$script:NavButtons = @ { }
$script:NavButtons . Trust = New-NavButton -Key " Trust " -Text " Trust " -Y 58
$script:NavButtons . Diagnostics = New-NavButton -Key " Diagnostics " -Text " File scan " -Y 110
$script:NavButtons . SmartScreen = New-NavButton -Key " SmartScreen " -Text " SmartScreen " -Y 162
foreach ( $navButton in $script:NavButtons . Values ) {
$sidebar . Controls . Add ( $navButton )
}
$sideNote = New-Label -Text " Installs public certificates only. No Defender, SmartScreen, UAC, firewall, or policy bypasses. " -X 24 -Y 510 -Width 164 -Height 96 -Color $colors . Muted -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 8.5 ) )
$sideNote . Anchor = " Left,Bottom "
$sidebar . Controls . Add ( $sideNote )
$contentHost = [ Windows.Forms.Panel ] :: new ( )
$contentHost . Dock = " Fill "
$contentHost . BackColor = $colors . Background
$contentHost . Padding = [ Windows.Forms.Padding ] :: new ( 34 , 30 , 34 , 30 )
$shell . Controls . Add ( $contentHost )
$script:Pages = @ { }
$trustPage = [ Windows.Forms.Panel ] :: new ( )
$trustPage . Dock = " Fill "
$trustPage . BackColor = $colors . Background
$contentHost . Controls . Add ( $trustPage )
$script:Pages . Trust = $trustPage
$trustTitle = New-PageTitle -Title " Trust " -Description " Install, remove, and verify the MrSphay public trust certificates. "
$trustPage . Controls . Add ( $trustTitle . Title )
$trustPage . Controls . Add ( $trustTitle . Description )
$trustPanel = New-Card -X 0 -Y 82 -Width 820 -Height 236
$trustPage . Controls . Add ( $trustPanel )
$scopeLabel = New-Label -Text " Scope " -X 24 -Y 22 -Width 160 -Height 22 -Color $colors . Muted -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 8.5 , [ Drawing.FontStyle ] :: Bold ) )
2026-05-16 13:05:12 +02:00
$trustPanel . Controls . Add ( $scopeLabel )
2026-05-15 23:47:10 +02:00
$script:AllUsersCheckBox = [ Windows.Forms.CheckBox ] :: new ( )
2026-05-16 13:43:52 +02:00
$script:AllUsersCheckBox . Text = " All users (LocalMachine, requires Administrator) "
2026-05-16 13:05:12 +02:00
$script:AllUsersCheckBox . ForeColor = $colors . Text
2026-05-16 13:43:52 +02:00
$script:AllUsersCheckBox . Location = [ Drawing.Point ] :: new ( 24 , 46 )
2026-05-15 23:47:10 +02:00
$script:AllUsersCheckBox . AutoSize = $true
$script:AllUsersCheckBox . FlatStyle = " Flat "
2026-05-16 13:05:12 +02:00
$script:AllUsersCheckBox . Add_CheckedChanged ( { Update-TrustStatus } )
$trustPanel . Controls . Add ( $script:AllUsersCheckBox )
2026-05-16 13:43:52 +02:00
$trustPanel . Controls . Add ( ( New-Label -Text " Root thumbprint " -X 24 -Y 90 -Width 170 -Height 24 ) )
$script:RootThumbprintLabel = New-Label -Text " - " -X 210 -Y 90 -Width 560 -Height 24 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Consolas " , 9 ) )
$script:RootThumbprintLabel . AutoEllipsis = $true
2026-05-16 13:05:12 +02:00
$trustPanel . Controls . Add ( $script:RootThumbprintLabel )
2026-05-16 13:43:52 +02:00
$trustPanel . Controls . Add ( ( New-Label -Text " Publisher thumbprint " -X 24 -Y 124 -Width 170 -Height 24 ) )
$script:PublisherThumbprintLabel = New-Label -Text " - " -X 210 -Y 124 -Width 560 -Height 24 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Consolas " , 9 ) )
$script:PublisherThumbprintLabel . AutoEllipsis = $true
2026-05-16 13:05:12 +02:00
$trustPanel . Controls . Add ( $script:PublisherThumbprintLabel )
2026-05-16 13:43:52 +02:00
$trustPanel . Controls . Add ( ( New-Label -Text " Expires " -X 24 -Y 158 -Width 170 -Height 24 ) )
$script:ExpiryLabel = New-Label -Text " - " -X 210 -Y 158 -Width 180 -Height 24 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$trustPanel . Controls . Add ( $script:ExpiryLabel )
2026-05-16 13:43:52 +02:00
$trustPanel . Controls . Add ( ( New-Label -Text " Active scope " -X 24 -Y 192 -Width 170 -Height 24 ) )
$script:ScopeValueLabel = New-Label -Text " - " -X 210 -Y 192 -Width 200 -Height 24 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$trustPanel . Controls . Add ( $script:ScopeValueLabel )
2026-05-16 13:43:52 +02:00
$summaryPanel = New-Card -X 0 -Y 338 -Width 820 -Height 76 -BackColor $colors . PanelAlt
$trustPage . Controls . Add ( $summaryPanel )
$script:TrustSummaryLabel = New-Label -Text " Checking trust state... " -X 22 -Y 18 -Width 760 -Height 34 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 10 , [ Drawing.FontStyle ] :: Bold ) )
$summaryPanel . Controls . Add ( $script:TrustSummaryLabel )
2026-05-15 23:47:10 +02:00
$installButton = [ Windows.Forms.Button ] :: new ( )
$installButton . Text = " Install trust "
2026-05-16 13:43:52 +02:00
$installButton . Size = [ Drawing.Size ] :: new ( 160 , 44 )
$installButton . Location = [ Drawing.Point ] :: new ( 0 , 438 )
2026-05-16 13:05:12 +02:00
Add-AnimatedButton -Button $installButton -Normal $colors . Green -Hover $colors . GreenHover
2026-05-15 23:47:10 +02:00
$installButton . Add_Click ( { Install-MrTrustCertificates } )
2026-05-16 13:43:52 +02:00
$trustPage . Controls . Add ( $installButton )
2026-05-15 23:47:10 +02:00
$removeButton = [ Windows.Forms.Button ] :: new ( )
$removeButton . Text = " Remove trust "
2026-05-16 13:43:52 +02:00
$removeButton . Size = [ Drawing.Size ] :: new ( 160 , 44 )
$removeButton . Location = [ Drawing.Point ] :: new ( 176 , 438 )
2026-05-16 13:05:12 +02:00
Add-AnimatedButton -Button $removeButton -Normal $colors . PanelAlt -Hover $colors . Border
2026-05-15 23:47:10 +02:00
$removeButton . Add_Click ( { Remove-MrTrustCertificates } )
2026-05-16 13:43:52 +02:00
$trustPage . Controls . Add ( $removeButton )
2026-05-15 23:47:10 +02:00
$refreshButton = [ Windows.Forms.Button ] :: new ( )
$refreshButton . Text = " Refresh "
2026-05-16 13:43:52 +02:00
$refreshButton . Size = [ Drawing.Size ] :: new ( 124 , 44 )
$refreshButton . Location = [ Drawing.Point ] :: new ( 352 , 438 )
2026-05-16 13:05:12 +02:00
Add-AnimatedButton -Button $refreshButton -Normal $colors . PanelAlt -Hover $colors . Border
$refreshButton . Add_Click ( { Update-TrustStatus } )
2026-05-16 13:43:52 +02:00
$trustPage . Controls . Add ( $refreshButton )
$note = New-Label -Text " Trust actions are reversible and scoped to the selected Windows certificate store. " -X 0 -Y 508 -Width 820 -Height 26 -Color $colors . Muted
$trustPage . Controls . Add ( $note )
$diagnosticsPage = [ Windows.Forms.Panel ] :: new ( )
$diagnosticsPage . Dock = " Fill "
$diagnosticsPage . BackColor = $colors . Background
$diagnosticsPage . Visible = $false
$contentHost . Controls . Add ( $diagnosticsPage )
$script:Pages . Diagnostics = $diagnosticsPage
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$diagnosticsTitle = New-PageTitle -Title " File scan " -Description " Inspect a Windows executable, installer, catalog, or DLL for signature and origin signals. "
$diagnosticsPage . Controls . Add ( $diagnosticsTitle . Title )
$diagnosticsPage . Controls . Add ( $diagnosticsTitle . Description )
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$filePanel = New-Card -X 0 -Y 82 -Width 820 -Height 420
$diagnosticsPage . Controls . Add ( $filePanel )
2026-05-16 13:05:12 +02:00
$chooseButton = [ Windows.Forms.Button ] :: new ( )
2026-05-16 13:43:52 +02:00
$chooseButton . Text = " Choose file "
$chooseButton . Size = [ Drawing.Size ] :: new ( 150 , 42 )
2026-05-16 13:05:12 +02:00
$chooseButton . Location = [ Drawing.Point ] :: new ( 24 , 24 )
Add-AnimatedButton -Button $chooseButton -Normal $colors . Green -Hover $colors . GreenHover
$filePanel . Controls . Add ( $chooseButton )
$scanButton = [ Windows.Forms.Button ] :: new ( )
2026-05-16 13:43:52 +02:00
$scanButton . Text = " Scan again "
$scanButton . Size = [ Drawing.Size ] :: new ( 130 , 42 )
$scanButton . Location = [ Drawing.Point ] :: new ( 190 , 24 )
2026-05-16 13:05:12 +02:00
Add-AnimatedButton -Button $scanButton -Normal $colors . PanelAlt -Hover $colors . Border
$filePanel . Controls . Add ( $scanButton )
2026-05-16 13:43:52 +02:00
$script:FileVerdictLabel = New-Label -Text " Choose a Windows app or installer to inspect. " -X 24 -Y 88 -Width 760 -Height 30 -Color $colors . Muted -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 11 , [ Drawing.FontStyle ] :: Bold ) )
2026-05-16 13:05:12 +02:00
$filePanel . Controls . Add ( $script:FileVerdictLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " File " -X 24 -Y 136 -Width 170 -Height 24 ) )
$script:FileNameLabel = New-Label -Text " - " -X 210 -Y 136 -Width 560 -Height 24 -Color $colors . Text
$script:FileNameLabel . AutoEllipsis = $true
2026-05-16 13:05:12 +02:00
$filePanel . Controls . Add ( $script:FileNameLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " Path " -X 24 -Y 170 -Width 170 -Height 24 ) )
$script:FilePathLabel = New-Label -Text " - " -X 210 -Y 170 -Width 560 -Height 40 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$script:FilePathLabel . AutoEllipsis = $true
$filePanel . Controls . Add ( $script:FilePathLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " Signature status " -X 24 -Y 222 -Width 170 -Height 24 ) )
$script:SignatureStatusLabel = New-Label -Text " - " -X 210 -Y 222 -Width 560 -Height 24 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$filePanel . Controls . Add ( $script:SignatureStatusLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " Signer " -X 24 -Y 256 -Width 170 -Height 24 ) )
$script:SignerLabel = New-Label -Text " - " -X 210 -Y 256 -Width 560 -Height 36 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$script:SignerLabel . AutoEllipsis = $true
$filePanel . Controls . Add ( $script:SignerLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " MrSphay match " -X 24 -Y 306 -Width 170 -Height 24 ) )
$script:MrSphayMatchLabel = New-Label -Text " - " -X 210 -Y 306 -Width 160 -Height 24 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$filePanel . Controls . Add ( $script:MrSphayMatchLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " Mark-of-the-Web " -X 390 -Y 306 -Width 160 -Height 24 ) )
$script:MotwLabel = New-Label -Text " - " -X 560 -Y 306 -Width 160 -Height 24 -Color $colors . Text
2026-05-16 13:05:12 +02:00
$filePanel . Controls . Add ( $script:MotwLabel )
2026-05-16 13:43:52 +02:00
$filePanel . Controls . Add ( ( New-Label -Text " SmartScreen note " -X 24 -Y 352 -Width 170 -Height 24 ) )
$script:SmartScreenLabel = New-Label -Text " - " -X 210 -Y 352 -Width 560 -Height 48 -Color $colors . Muted
2026-05-16 13:05:12 +02:00
$filePanel . Controls . Add ( $script:SmartScreenLabel )
$chooseButton . Add_Click ( {
$dialog = [ Windows.Forms.OpenFileDialog ] :: new ( )
$dialog . Filter = " Windows apps and installers (*.exe;*.msi;*.dll;*.cat)|*.exe;*.msi;*.dll;*.cat|All files (*.*)|*.* "
if ( $dialog . ShowDialog ( ) -eq [ Windows.Forms.DialogResult ] :: OK ) {
$script:SelectedFilePath = $dialog . FileName
Test-SelectedFile -Path $script:SelectedFilePath
}
} )
$scanButton . Add_Click ( {
if ( $script:SelectedFilePath ) {
Test-SelectedFile -Path $script:SelectedFilePath
}
} )
2026-05-16 13:43:52 +02:00
$helpPage = [ Windows.Forms.Panel ] :: new ( )
$helpPage . Dock = " Fill "
$helpPage . BackColor = $colors . Background
$helpPage . Visible = $false
$contentHost . Controls . Add ( $helpPage )
$script:Pages . SmartScreen = $helpPage
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$helpTitle = New-PageTitle -Title " SmartScreen " -Description " Understand what MrTrust can verify and what Windows reputation still controls. "
$helpPage . Controls . Add ( $helpTitle . Title )
$helpPage . Controls . Add ( $helpTitle . Description )
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$helpPanel = New-Card -X 0 -Y 82 -Width 820 -Height 330
$helpPage . Controls . Add ( $helpPanel )
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$helpPanel . Controls . Add ( ( New-Label -Text " Local trust " -X 24 -Y 24 -Width 180 -Height 24 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 11 , [ Drawing.FontStyle ] :: Bold ) ) ) )
$helpPanel . Controls . Add ( ( New-Label -Text " MrTrust installs the public MrSphay root and publisher certificates into the selected Windows certificate stores. " -X 24 -Y 54 -Width 740 -Height 42 -Color $colors . Muted ) )
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$helpPanel . Controls . Add ( ( New-Label -Text " Windows reputation " -X 24 -Y 118 -Width 220 -Height 24 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 11 , [ Drawing.FontStyle ] :: Bold ) ) ) )
$helpPanel . Controls . Add ( ( New-Label -Text " SmartScreen can still warn for a new or rarely downloaded file, even when the signature is valid and the publisher is recognized. " -X 24 -Y 148 -Width 740 -Height 42 -Color $colors . Muted ) )
2026-05-16 13:05:12 +02:00
2026-05-16 13:43:52 +02:00
$helpPanel . Controls . Add ( ( New-Label -Text " What to check " -X 24 -Y 212 -Width 180 -Height 24 -Color $colors . Text -Font ( [ Drawing.Font ] :: new ( " Segoe UI " , 11 , [ Drawing.FontStyle ] :: Bold ) ) ) )
$helpPanel . Controls . Add ( ( New-Label -Text " Use File scan to verify signature status, MrSphay signer matching, and Mark-of-the-Web. MrTrust never disables SmartScreen. " -X 24 -Y 242 -Width 740 -Height 46 -Color $colors . Muted ) )
2026-05-16 13:05:12 +02:00
$pulseTimer = [ Windows.Forms.Timer ] :: new ( )
2026-05-16 13:43:52 +02:00
$pulseTimer . Interval = 100
2026-05-16 13:05:12 +02:00
$pulseTimer . Add_Tick ( {
$script:CurrentAccent = ( $script:CurrentAccent + 1 ) % 40
2026-05-16 13:43:52 +02:00
$value = 130 + [ Math ] :: Abs ( 20 - $script:CurrentAccent ) * 4
$sideAccent . BackColor = [ Drawing.Color ] :: FromArgb ( 0 , [ Math ] :: Min ( 205 , $value ) , 91 )
2026-05-16 13:05:12 +02:00
} )
$pulseTimer . Start ( )
2026-05-16 13:43:52 +02:00
$form . Add_Shown ( {
Show-MrTrustPage -Key " Trust "
Update-TrustStatus
} )
2026-05-15 23:47:10 +02:00
[ Windows.Forms.Application ] :: Run ( $form )