Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import base64
- import sys
- #================================================
- ### INPUT AREA ###
- # UID of NFC card to write to
- uid = '04512c7aca6680'
- ## Token ID
- tid = 2
- # 1 = Figurine, 2 = Flat
- ## Figurine ID
- fid = 0
- # Figurines:
- # 0 = Dragon, 1 = Fox, 2 = Ghost, 3 = Knight, 4 = ThankYou, 5 = Whale,
- # 6 = Black.Dragon, 7 = Black.Fox, 8 = Black.Knight, 9 = Black.Whale,
- # 10 = White.Dragon, 11 = White.Fox, 12 = White.Knight, 13 = White.Whale
- # Flats:
- # 0 = Generic Flat
- #================================================
- ### PROGRAM CODE ###
- # Set fixed requirements
- figurines = [
- 'Dragon', 'Fox', 'Ghost', 'Knight', 'ThankYou', 'Whale', 'Black.Dragon',
- 'Black.Fox', 'Black.Knight', 'Black.Whale', 'White.Dragon', 'White.Fox',
- 'White.Knight', 'White.Whale',
- ]
- iv = bytes([0x80, 0x77, 0x51]) # always the same?
- nfc_secret = bytes([0x03, 0x9c, 0x25, 0x6f, 0xb9, 0x2e, 0xe8,
- 0x08, 0x09, 0x83, 0xd9, 0x33, 0x56])
- # Print input parameters to screen
- print('UID to encode: ', uid)
- if tid == 1:
- print('Token: Figurine')
- if fid < len(figurines):
- print('Figurine: ' + figurines[fid])
- else:
- sys.exit('Wrong Figurine ID! Aborting...')
- elif tid == 2:
- print('Token: Flat')
- if fid == 0:
- print('Figurine: Generic Flat')
- else:
- sys.exit('Wrong Figurine ID! Aborting...')
- else:
- sys.exit('Wrong Token ID! Aborting...')
- # Convert uid to byte representation
- uid_b = []
- for i in range(0,len(uid),2):
- uid_b.append(
- int('0x'+uid[i:i+2], 16)
- )
- # Combine all input into d
- d = iv + tid.to_bytes(1, 'little') + fid.to_bytes(1, 'little') + bytes(uid_b)
- # Use nfc_secret to encrypt d
- enc = []
- for i in range(0,12):
- if i<3:
- enc.append(d[i] ^ nfc_secret[i])
- else:
- enc.append(d[i] ^ nfc_secret[i] ^ d[i % 3])
- # Encode encrypted string in base64
- result = base64.b64encode(bytes(enc))
- # Print results to screen
- print('URL: https://s.jooki.rocks/s/?s=' + result.decode('utf-8'))
Add Comment
Please, Sign In to add comment