From 5aca4bf06e48eaa0b3ec3366d9125f4f0f86af1d Mon Sep 17 00:00:00 2001 From: dabruh <11458706-dabruh@users.noreply.gitlab.com> Date: Sun, 5 Jun 2022 00:10:25 +0200 Subject: [PATCH] First POC. --- powershell/BankIDClipboardWatcher.ps1 | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 powershell/BankIDClipboardWatcher.ps1 diff --git a/powershell/BankIDClipboardWatcher.ps1 b/powershell/BankIDClipboardWatcher.ps1 new file mode 100644 index 0000000..4be48e8 --- /dev/null +++ b/powershell/BankIDClipboardWatcher.ps1 @@ -0,0 +1,39 @@ +function Get-Hash([string]$textToHash) { + $hasher = new-object System.Security.Cryptography.MD5CryptoServiceProvider + $toHash = [System.Text.Encoding]::UTF8.GetBytes($textToHash) + $hashByteArray = $hasher.ComputeHash($toHash) + + foreach($byte in $hashByteArray){ + $result += "{0:X2}" -f $byte + } + + return $result; +} + +$ClearClipboard = $true +$PreviousHash = Get-Hash(Get-Clipboard) + +while ($true) { + $Clipboard = Get-Clipboard + $ClipboardHash = Get-Hash($Clipboard) + + if ($ClipboardHash -eq $PreviousHash) { + Write-Host "NOCHG" + Start-Sleep -Milliseconds 250 + Continue + } + elseif ($Clipboard -match '^bankid:\/\/\/') { + Write-Host $Clipboard + start "$Clipboard" + } + else { + Write-Host "CHG" + } + + if ($ClearClipboard) { + Set-Clipboard -Value $null + } + + $PreviousHash = Get-Hash($Clipboard) + Start-Sleep -Milliseconds 250 +}