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
5aca4bf06e
commit
10e6415b72
2 changed files with 37 additions and 39 deletions
|
@ -1,39 +0,0 @@
|
|||
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
|
||||
}
|
37
powershell/BankIDTokenFileWatcher.ps1
Normal file
37
powershell/BankIDTokenFileWatcher.ps1
Normal file
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# BankIDTokenFileWatcher
|
||||
#
|
||||
# Starts BankID when a token is written to $TokenFile.
|
||||
#
|
||||
# Run this script on logon together with BankID. This script is intended to be
|
||||
# used with an SSH server installed on the host so that a client can write this
|
||||
# token to disk.
|
||||
#
|
||||
|
||||
$Token = $null
|
||||
$LastToken = $null
|
||||
$TokenFile = "C:\bid_autostarttoken"
|
||||
|
||||
Write-Host "Starting file watcher for '$TokenFile'"
|
||||
|
||||
while ($true) {
|
||||
if (Test-Path $TokenFile) {
|
||||
$TokenFileData = Get-Item "$TokenFile"
|
||||
|
||||
if (((Get-Date) - $TokenFileData.LastWriteTime).totalseconds -le 1){
|
||||
Write-Host "File modified: $TokenFile"
|
||||
$Token = Get-Content "$TokenFile"
|
||||
|
||||
if ($Token -ne $LastToken) {
|
||||
Write-Host "New token: $Token"
|
||||
Start-Process "bankid:///?autostarttoken=$Token&redirect=null"
|
||||
Start-Sleep -Milliseconds 500
|
||||
$LastToken = $Token
|
||||
}
|
||||
else {
|
||||
Write-Host "Token unchanged: $Token"
|
||||
}
|
||||
}
|
||||
}
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
Loading…
Reference in a new issue