Skip to content

Instantly share code, notes, and snippets.

@wesleyit
Created November 19, 2019 18:03
Show Gist options
  • Save wesleyit/4aa2bf0a79d11866142bfa4477282c2a to your computer and use it in GitHub Desktop.
Save wesleyit/4aa2bf0a79d11866142bfa4477282c2a to your computer and use it in GitHub Desktop.
Type your password if an authorized UID is read by NFC reader
import re
import time
import serial
import pykeyboard
k = pykeyboard.PyKeyboard()
ENTER = k.enter_key
password = 'My_Super_P4SSWoRD'
print('Starting serial device...')
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600)
def main():
time.sleep(1)
print('Waiting for a card...')
card = ser.readline().decode()
print('Got a card. Decoding...')
card = re.findall(r'[0-9]+', card)[0]
print('UID: ', card)
valid_uids = ['8112916219', '8410315760', '4649650']
if card in valid_uids:
print('Access granted.')
k.type_string(password)
k.tap_key(ENTER)
else:
print('Access denied.')
if __name__ == '__main__':
while True:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment