mirror of
https://gitlab.com/dabruh/weird-corner.git
synced 2024-12-25 09:25:56 +01:00
First POC.
This commit is contained in:
parent
69aef52b9a
commit
5aca4bf06e
1 changed files with 39 additions and 0 deletions
39
powershell/BankIDClipboardWatcher.ps1
Normal file
39
powershell/BankIDClipboardWatcher.ps1
Normal file
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue