-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyubicheck.py
More file actions
29 lines (27 loc) · 775 Bytes
/
yubicheck.py
File metadata and controls
29 lines (27 loc) · 775 Bytes
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
import re
import subprocess
import sys
import ctypes
from subprocess import check_output
from time import sleep
#yubiSerial="XXXXXXX"
first=True
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
while(1):
p = subprocess.Popen("yubico-piv-tool.exe -a list-readers", stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)
yubiRead, _ = p.communicate()
if "Failed" in str(yubiRead):
yubiRead="ERROR"
else:
yubiRead = str(yubiRead)
print (yubiRead)
if "Yubico Yubikey NEO" in yubiRead:
print ("Yubikey found")
else:
if(first):
sys.exit(0)
print ("locking")
ctypes.windll.user32.LockWorkStation()
first=False
sleep(10)