Created
February 1, 2023 10:30
-
-
Save syxanash/7687425c8baff03a1c849d03edb1fc28 to your computer and use it in GitHub Desktop.
script to generate LEGO Minifigure Factory box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_zero(number) | |
number.size == 1 ? "0#{number}" : number | |
end | |
def byte_check_calculator(byte_string) | |
# execute a xor on the bytes of the string | |
byte_string.split(" ") | |
.map { |item| item.to_i(16) } | |
.reduce { |acc, item| acc ^ item }.to_s(16).upcase | |
end | |
# byte 0, 3, 4 and 5 have been hidden to prevent skiddies :) | |
uid_byte0 = "AA" | |
uid_random_byte1 = add_zero(rand(0..254).to_s(16).upcase) | |
uid_random_byte2 = add_zero(rand(0..254).to_s(16).upcase) | |
uid_byte3 = "BB" | |
uid_byte4 = "CC" | |
uid_byte5 = "DD" | |
uid_byte6 = "9#{rand(0..1)}" | |
random_signature = 32.times.map { add_zero(rand(0..254).to_s(16).upcase) }.join(' ') | |
# CT byte is defined as 88h according to ISO/IEC 14443-3 | |
# the byte check specs can be found here: https://www.nxp.com/docs/en/data-sheet/MF0ULX1.pdf | |
cascade_tag_byte = "88" | |
check_byte0 = add_zero(byte_check_calculator("#{cascade_tag_byte} #{uid_byte0} #{uid_random_byte1} #{uid_random_byte2}")) | |
check_byte1 = add_zero(byte_check_calculator("#{uid_byte3} #{uid_byte4} #{uid_byte5} #{uid_byte6}")) | |
# Page 3 is 8.5.4 OTP bytes set to 0 by default | |
output = <<~PAYLOAD | |
Filetype: Flipper NFC device | |
Version: 3 | |
# Nfc device type can be UID, Mifare Ultralight, Mifare Classic, Bank card | |
Device type: Mifare Ultralight 11 | |
# UID, ATQA and SAK are common for all formats | |
UID: #{uid_byte0} #{uid_random_byte1} #{uid_random_byte2} #{uid_byte3} #{uid_byte4} #{uid_byte5} #{uid_byte6} | |
ATQA: 00 44 | |
SAK: 00 | |
# Mifare Ultralight specific data | |
Data format version: 1 | |
Signature: #{random_signature} | |
Mifare version: 00 04 03 01 01 00 0B 03 | |
Counter 0: 0 | |
Tearing 0: BD | |
Counter 1: 0 | |
Tearing 1: BD | |
Counter 2: 0 | |
Tearing 2: BD | |
Pages total: 20 | |
Pages read: 20 | |
Page 0: #{uid_byte0} #{uid_random_byte1} #{uid_random_byte2} #{check_byte0} | |
Page 1: #{uid_byte3} #{uid_byte4} #{uid_byte5} #{uid_byte6} | |
Page 2: #{check_byte1} 48 30 00 | |
Page 3: 00 00 00 00 | |
Page 4: 31 30 30 30 | |
Page 5: 30 FF FF FF | |
Page 6: 00 00 00 00 | |
Page 7: 00 00 00 00 | |
Page 8: 00 00 00 00 | |
Page 9: 00 00 00 00 | |
Page 10: 00 00 00 00 | |
Page 11: 00 00 00 00 | |
Page 12: 00 00 00 00 | |
Page 13: 00 00 00 00 | |
Page 14: 00 00 00 00 | |
Page 15: 00 00 00 00 | |
Page 16: 00 00 00 FF | |
Page 17: 00 05 00 00 | |
Page 18: FF FF FF FF | |
Page 19: 00 00 00 00 | |
Failed authentication attempts: 0 | |
PAYLOAD | |
puts output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment