Update parse.py to accept JSON dumps

This commit is contained in:
Queen Vinyl Da.i'gyu-Kazotetsu authored and Queen Vinyl Da.i'gyu-Kazotetsu committed 2025-07-07 00:18:30 -07:00
1 parent 81406a66fa
commit 86370592af
1 file changed
+13 -2
+13 -2
View File
@@ -6,6 +6,7 @@
import sys
import re
import json
from pathlib import Path
from .lib import bytes_to_string, bytes_to_hex, bytes_to_int, bytes_to_float, bytes_to_date
@@ -99,10 +100,20 @@ class ColorList(list):
class Tag():
def __init__(self, filename, data):
# Check to make sure the data is 1KB or a known alternative
# Proxmark3 JSON dump
try:
json_data = json.loads(data)
if json_data.get("Created") == "proxmark3":
data = b"".join([bytes.fromhex(json_data["blocks"][key].replace("??", "00")) for key in json_data["blocks"]])
except ValueError:
# We know that the data isn't JSON now
pass
# Flipper NFC dump
if data.startswith(b"Filetype: Flipper NFC"):
# Flipper NFC dump
data = strip_flipper_data(data)
# Check to make sure the data is 1KB or a known alternative
if len(data) not in TOTAL_BYTES:
raise TagLengthMismatchError(len(data))