From 197d5fbf1888fdb6b982d2d985e1e8418ae0cf91 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 17:36:56 -0700 Subject: [PATCH 01/21] Add a tip to disassemble the Proxmark3 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b7bb685..9e38514 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,9 @@ The more data we have, the easier it is to compare differences to learn what eac A Proxmark3 Easy is sufficient for all the tasks that need to be done. You can buy a clone from Alixepress, Amazon or Dangerous Things. +> [!TIP] +> For this particular process, you will only need the bottom-most part of the Proxmark3 Easy assembly. For convenience, it may be helpful to disassemble the device and remove the top and middle layers. + ## Hacking a Bambulab Tag and readout of its data The easiest way to obtain the We document here the most simple approach to get all required A-Keys and the data of the tag. From 9b57dbe413d0c9c9cd88f5b8495c7d78598c6304 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 25 Jun 2024 12:31:05 -0700 Subject: [PATCH 02/21] Update tip and wording surrounding it --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9e38514..40db2b0 100644 --- a/README.md +++ b/README.md @@ -108,9 +108,6 @@ The more data we have, the easier it is to compare differences to learn what eac A Proxmark3 Easy is sufficient for all the tasks that need to be done. You can buy a clone from Alixepress, Amazon or Dangerous Things. -> [!TIP] -> For this particular process, you will only need the bottom-most part of the Proxmark3 Easy assembly. For convenience, it may be helpful to disassemble the device and remove the top and middle layers. - ## Hacking a Bambulab Tag and readout of its data The easiest way to obtain the We document here the most simple approach to get all required A-Keys and the data of the tag. @@ -128,9 +125,10 @@ For sniffing, you will need to place the Proxmark in between the RFID tag and th ### Proxmark3 placement for sniffing -For sniffing, you will need to place the Proxmark3 against the reader. On the AMS, you may place it on the other side (for example, load the spool into slot one and place the Proxmark3 against the reader in slot 2). On the AMS lite, you will need to place it in between the reader and the spool. +For sniffing, you will need to place the Proxmark3 against the reader. On the AMS lite, you must place it in between the reader and the spool. On the AMS, it is recommended to place it between the reader and the spool, but you may place it on the other side (for example, load the spool into slot 1 and place the Proxmark3 against the reader in slot 2). -As there is not much clearance, it is recommended to temporarily remove the low frequency radio (the topmost piece) if you can, as it will not be used in this process. +> [!TIP] +> As there is not much clearance, it may be helpful to disassemble the Proxmark3 Easy and remove the top and middle layers. For this particular process, you will only need the bottom-most layer. If you place the Proxmark in between the AMS reader and the spool, make sure that spool rotates so that the RFID tag moves away from the reader, otherwise the AMS will assume that it is reading the tag from its neighboring slot and attempt to rewind it until it cannot see the RFID tag. From 4e241ff712410efaee6fd6ac9adaa9e461a091dd Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:18:15 -0700 Subject: [PATCH 03/21] Update known detailed filament types --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 40db2b0..fa11d00 100644 --- a/README.md +++ b/README.md @@ -396,9 +396,12 @@ Example Data: Known Values: - PLA Basic -- PLA Tough -- Support for PLA -- PLA-CF +- PLA Matte +- PLA Silk +- PLA Galaxy +- PLA Sparkle +- Support for PLA (prev. Support W) +- PLA-CF (prev. PLA Tough) - PETG Basic ### Block 5 From 3e905b97ba3ce4aac2a7839e1af3e5a3ade40f08 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 15:24:39 -0700 Subject: [PATCH 04/21] Parse script: check for unexpected data in known blank areas --- parse.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/parse.py b/parse.py index 9ffbc9f..7aa3c95 100644 --- a/parse.py +++ b/parse.py @@ -87,10 +87,12 @@ class Tag(): self.filename = filename self.blocks = list(data[0+i:BYTES_PER_BLOCK+i] for i in range(0, len(data), BYTES_PER_BLOCK)) + self.warnings = [] + # Check for blank blocks for bi in IMPORTANT_BLOCKS: if self.blocks[bi] == b'\x00' * BYTES_PER_BLOCK: - print(f"Warning! Block {bi} is blank!") + self.warnings.append(f"Block {bi} is blank!") # Parse the data self.data = { @@ -118,9 +120,26 @@ class Tag(): "production_date": bytes_to_date(self.blocks[12]), "unknown": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always - } + # Check for any data in bits that are expected to be blank + expected_to_be_blank = { + 5: [*range(6,8),*range(12,16)], + 6: range(12,16), + 10: [*range(0,4), *range(6,16)], + 14: [*range(0,4), *range(6,16)] + } + for block in range(16,39): + if block % 4 == 3: + continue # Skip MIFARE encryption key blocks + expected_to_be_blank[block] = list(range(0,16)) + + for block in expected_to_be_blank: + for pos in expected_to_be_blank[block]: + byte = self.blocks[block][pos] + if byte != 0: + self.warnings.append(f"Data found in block {block}, position {pos} that was expected to be blank (received {byte})") + def __str__(self, blocks_to_output = IMPORTANT_BLOCKS): result = "" @@ -132,6 +151,11 @@ class Tag(): else: result += f"- {key}: {bytes_to_hex(self.data[key]) if type(self.data[key]) == bytes else self.data[key]}\n" + if len(self.warnings): + result += "- Warnings:\n" + for warning in self.warnings: + result += f" - {warning}\n" + return result[:-1] def print_blocks(self, blocks_to_output = IMPORTANT_BLOCKS): From 47fb7ee8323c39b0302e8b0e7c52b3d37f3ec682 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:00:51 -0700 Subject: [PATCH 05/21] Fix bytes_to_hex --- parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse.py b/parse.py index 7aa3c95..9d306ae 100644 --- a/parse.py +++ b/parse.py @@ -21,7 +21,7 @@ def bytes_to_string(data): def bytes_to_hex(data, chunkify = False): output = data.hex().upper() - return " ".join((string[0+i:2+i] for i in range(0, len(string), 2))) if chunkify else output + return " ".join((output[0+i:2+i] for i in range(0, len(output), 2))) if chunkify else output def bytes_to_int(data): return int.from_bytes(data, 'little') From 580d98c7c2a25253d83a5d92bffeda8036a0908b Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:01:58 -0700 Subject: [PATCH 06/21] Block 16 has data now --- parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse.py b/parse.py index 9d306ae..1750fd7 100644 --- a/parse.py +++ b/parse.py @@ -129,7 +129,7 @@ class Tag(): 10: [*range(0,4), *range(6,16)], 14: [*range(0,4), *range(6,16)] } - for block in range(16,39): + for block in range(17,39): if block % 4 == 3: continue # Skip MIFARE encryption key blocks expected_to_be_blank[block] = list(range(0,16)) From fc4b139aa5fef05ab298e3f6088773c3c5258bc4 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:13:38 -0700 Subject: [PATCH 07/21] Block 17 has some data --- parse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parse.py b/parse.py index 1750fd7..09393c9 100644 --- a/parse.py +++ b/parse.py @@ -127,9 +127,10 @@ class Tag(): 5: [*range(6,8),*range(12,16)], 6: range(12,16), 10: [*range(0,4), *range(6,16)], - 14: [*range(0,4), *range(6,16)] + 14: [*range(0,4), *range(6,16)], + 17: range(2,16) } - for block in range(17,39): + for block in range(18,39): if block % 4 == 3: continue # Skip MIFARE encryption key blocks expected_to_be_blank[block] = list(range(0,16)) From 4d8dc1e116e5664397fe2f4b29922147cd446958 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 20:54:09 -0700 Subject: [PATCH 08/21] Add data about block 16 --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa11d00..a463d16 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ We are currently working on a way to submit the tag data in a secure way so anal * [Block 12](#block-12) * [Block 13](#block-13) * [Block 14](#block-14) + * [Block 16](#block-16) * [Compatible RFID tags - By generation](#compatible-rfid-tags----by-generation) @@ -307,7 +308,7 @@ Summary of what kind of data is stored in each block. Detailed info for each blo | 3 | 1 | [Block 13](#block-13) **Unknown** | | 3 | 2 | [Block 14](#block-14) **Unknown** | | 3 | 3 | [Block 15](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | -| 4 | 0 | **Empty** | +| 4 | 0 | [Block 16](#block-16) Second Color Code, **Unknown** | | 4 | 1 | **Empty** | | 4 | 2 | **Empty** | | 4 | 3 | [Block 19](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | @@ -411,7 +412,7 @@ Example Data: | position | length | type | Description | | -------- | ------ | ----------- | -------------------------------------------- | -| 0 (AA) | 4 | RGBA | Color in hex RBGA | +| 0 (AA) | 4 | RGBA | Color in hex RGBA | | 4 (BB) | 2 | uint16 (LE) | Spool Weight in grams (`E8 03` --> 1000 g) | | 8 (CC) | 8 | float (LE) | Filament Diameter in milimeters | @@ -484,6 +485,16 @@ Example Data: | -------- | ------ | ----------- | --------------------------------- | | 4 (AA) | 2 | uint16 (LE) | **Filament length in meters...?** | +### Block 16 + +Example Data: +`AA AA AA AA BB BB BB BB __ __ __ __ __ __ __ __` + +| position | length | type | Description | +| -------- | ------ | ----------- | ---------------------------------- | +| 0 (AA) | 4 | **Unknown** | **Unknown** | +| 4 (BB) | 4 | RGBA | Second color in _reverse_ hex ABGR | + ## Compatible RFID tags - By generation Gen 1 --> **Not compatible**(due to AMS checking if tag is unlockable with command 0x40) From 33f5b92a7ae4a7a14ce045087faa228d2f47a542 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:03:56 -0700 Subject: [PATCH 09/21] Update parsing script to handle a second color --- parse.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parse.py b/parse.py index 09393c9..053f46e 100644 --- a/parse.py +++ b/parse.py @@ -141,6 +141,10 @@ class Tag(): if byte != 0: self.warnings.append(f"Data found in block {block}, position {pos} that was expected to be blank (received {byte})") + # Check for a second color + if self.blocks[16][4]: + self.data["filament_color"] += " / #" + bytes_to_hex(self.blocks[16][4:8][::-1]) + def __str__(self, blocks_to_output = IMPORTANT_BLOCKS): result = "" From c1b1b9a4ed9125c172c42e9471d85492a255a2a7 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:11:52 -0700 Subject: [PATCH 10/21] Add Color Count --- README.md | 7 ++++--- parse.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a463d16..bfa6524 100644 --- a/README.md +++ b/README.md @@ -488,12 +488,13 @@ Example Data: ### Block 16 Example Data: -`AA AA AA AA BB BB BB BB __ __ __ __ __ __ __ __` +`AA AA BB BB CC CC CC CC __ __ __ __ __ __ __ __` | position | length | type | Description | | -------- | ------ | ----------- | ---------------------------------- | -| 0 (AA) | 4 | **Unknown** | **Unknown** | -| 4 (BB) | 4 | RGBA | Second color in _reverse_ hex ABGR | +| 0 (AA) | 2 | **Unknown** | **Unknown** | +| 2 (BB) | 2 | uint16 (LE) | **Color Count...?** | +| 4 (CC) | 4 | RGBA | Second color in _reverse_ hex ABGR | ## Compatible RFID tags - By generation diff --git a/parse.py b/parse.py index 053f46e..2d3684c 100644 --- a/parse.py +++ b/parse.py @@ -99,6 +99,7 @@ class Tag(): "uid": bytes_to_hex(self.blocks[0][0:4]), "filament_type": bytes_to_string(self.blocks[2]), "detailed_filament_type": bytes_to_string(self.blocks[4]), + "filament_color_count": bytes_to_int(self.blocks[16][2:4]), "filament_color": "#" + bytes_to_hex(self.blocks[5][0:4]), "spool_weight": Unit(bytes_to_int(self.blocks[5][4:6]), "g"), "filament_length": Unit(bytes_to_int(self.blocks[14][4:6]), "m"), @@ -142,7 +143,7 @@ class Tag(): self.warnings.append(f"Data found in block {block}, position {pos} that was expected to be blank (received {byte})") # Check for a second color - if self.blocks[16][4]: + if self.data["filament_color_count"] == 2: self.data["filament_color"] += " / #" + bytes_to_hex(self.blocks[16][4:8][::-1]) def __str__(self, blocks_to_output = IMPORTANT_BLOCKS): From f23a2194a51254010104aa19c68632deb218530a Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:12:13 -0700 Subject: [PATCH 11/21] Add additional unknown values to parse script --- parse.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parse.py b/parse.py index 2d3684c..05ca75a 100644 --- a/parse.py +++ b/parse.py @@ -120,7 +120,9 @@ class Tag(): "tray_uid": self.blocks[9], "production_date": bytes_to_date(self.blocks[12]), - "unknown": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always + "unknown_1": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always + "unknown_2": self.blocks[16][0:2], # So far, always "0200" + "unknown_3": self.blocks[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise } # Check for any data in bits that are expected to be blank From 7a593bc1cc09817ad9d2bdd4988365240fb818e3 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 21:12:55 -0700 Subject: [PATCH 12/21] Add data about block 17 --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bfa6524..dde4ef1 100644 --- a/README.md +++ b/README.md @@ -308,8 +308,8 @@ Summary of what kind of data is stored in each block. Detailed info for each blo | 3 | 1 | [Block 13](#block-13) **Unknown** | | 3 | 2 | [Block 14](#block-14) **Unknown** | | 3 | 3 | [Block 15](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | -| 4 | 0 | [Block 16](#block-16) Second Color Code, **Unknown** | -| 4 | 1 | **Empty** | +| 4 | 0 | [Block 16](#block-16) Color Count, Second Color Code, **Unknown** | +| 4 | 1 | [Block 17](#block-17) **Unknown** | | 4 | 2 | **Empty** | | 4 | 3 | [Block 19](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | | 5 | 0 | **Empty** | @@ -496,6 +496,15 @@ Example Data: | 2 (BB) | 2 | uint16 (LE) | **Color Count...?** | | 4 (CC) | 4 | RGBA | Second color in _reverse_ hex ABGR | +### Block 17 + +Example Data: +`AA AA __ __ __ __ __ __ __ __ __ __ __ __ __ __` + +| position | length | type | Description | +| -------- | ------ | ----------- | ---------------------------------- | +| 0 (AA) | 2 | **Unknown** | **Unknown** | + ## Compatible RFID tags - By generation Gen 1 --> **Not compatible**(due to AMS checking if tag is unlockable with command 0x40) From df2661b45bbe859b6cd8b7bc61008ed2faaf7679 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 14 Jun 2024 15:37:07 -0700 Subject: [PATCH 13/21] Update block overview list --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dde4ef1..8cfe888 100644 --- a/README.md +++ b/README.md @@ -297,16 +297,16 @@ Summary of what kind of data is stored in each block. Detailed info for each blo | 0 | 2 | [Block 2](#block-2) Filament Type | | 0 | 3 | [Block 3](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | | 1 | 0 | [Block 4](#block-4) Detailed Filament Type | -| 1 | 1 | [Block 5](#block-5) Spool Weight, Color Code | -| 1 | 2 | [Block 6](#block-6) Min/Max Hotend, Bed Temp, Bed Temp Type, Drying Time, Drying Temp | +| 1 | 1 | [Block 5](#block-5) Spool Weight, Color Code, Filament Diameter | +| 1 | 2 | [Block 6](#block-6) Temperatures and Drying Info | | 1 | 3 | [Block 7](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | -| 2 | 0 | [Block 8](#block-8) X Cam Info | +| 2 | 0 | [Block 8](#block-8) X Cam Info, Nozzle Diameter | | 2 | 1 | [Block 9](#block-9) Tray UID | -| 2 | 2 | [Block 10](#block-10) **Unknown** | +| 2 | 2 | [Block 10](#block-10) Spool Width | | 2 | 3 | [Block 11](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | | 3 | 0 | [Block 12](#block-12) Production Date/Time | -| 3 | 1 | [Block 13](#block-13) **Unknown** | -| 3 | 2 | [Block 14](#block-14) **Unknown** | +| 3 | 1 | [Block 13](#block-13) Short Production Date/Time | +| 3 | 2 | [Block 14](#block-14) Filament Length | | 3 | 3 | [Block 15](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | | 4 | 0 | [Block 16](#block-16) Color Count, Second Color Code, **Unknown** | | 4 | 1 | [Block 17](#block-17) **Unknown** | From 4119aa608ceebda21f4be6b4795deefc84f7ff75 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 28 May 2024 22:03:15 -0700 Subject: [PATCH 14/21] Parse script: use pathlib to handle file paths --- parse.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/parse.py b/parse.py index 05ca75a..8bc0d35 100644 --- a/parse.py +++ b/parse.py @@ -7,6 +7,11 @@ import sys import struct from datetime import datetime +from pathlib import Path + +if not sys.version_info >= (3, 6): + print("Python 3.6 or higher is required!") + exit(-1) COMPARISON_BLOCKS = [1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14] IMPORTANT_BLOCKS = [0] + COMPARISON_BLOCKS @@ -189,11 +194,12 @@ def load_data(files_to_load, silent = False): data = [] for filename in files_to_load: try: - with open(filename, "rb") as f: - newdata = Tag(filename, f.read()) + filepath = Path(filename) + with open(filepath, "rb") as f: + newdata = Tag(filepath, f.read()) data.append(newdata) except TagLengthMismatchError: - if not silent: print(f"{filename} not a valid tag, skipping") + if not silent: print(f"{filepath} not a valid tag, skipping") return data From 3d72176f4d2bdd18283db150d7320f09bafc265f Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 22 Aug 2024 01:40:10 -0700 Subject: [PATCH 15/21] Fix a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cfe888..467bebd 100644 --- a/README.md +++ b/README.md @@ -425,7 +425,7 @@ Example Data: | -------- | ------ | ----------- | --------------------------------------- | | 0 (AA) | 2 | uint16 (LE) | Drying Temperature in °C | | 2 (BB) | 2 | uint16 (LE) | Drying time in hours | -| 4 (CC) | 4 | uint16 (LE) | Bed Temerature Type **(types unknown)** | +| 4 (CC) | 2 | uint16 (LE) | Bed Temerature Type **(types unknown)** | | 6 (DD) | 2 | uint16 (LE) | Bed Temperature in °C | | 8 (EE) | 2 | uint16 (LE) | Min Temperature for Hotend in °C | | 10 (FF) | 2 | uint16 (LE) | Max Temperature for Hotend in °C | From 4840f7aef7a5d75cf54351f2bbf1ba6577a42f79 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Sat, 28 Sep 2024 17:30:27 -0700 Subject: [PATCH 16/21] Python 3.11 and lower require alternating quote types in f-strings --- traceKeyExtractor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/traceKeyExtractor.py b/traceKeyExtractor.py index a73447a..d60b42a 100644 --- a/traceKeyExtractor.py +++ b/traceKeyExtractor.py @@ -85,7 +85,7 @@ def discoverKeys(): # -c specifies commands within proxmark 3 software cmd_list = [pm3Location / pm3Command,"-o","-c", f"trace load -f {trace}; trace list -1 -t mf -f {dictionaryFilepath}; exit"]; print(f"Viewing tracelog with {len(keyList)} discovered keys") - print(f"pm3 {" ".join(cmd_list[1:])}") + print(f"pm3 {' '.join(cmd_list[1:])}") result = subprocess.run(cmd_list, shell=os.name == 'nt',stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = result.stdout; @@ -192,7 +192,7 @@ def bruteForce(args): cmd_list = [pm3Location / mfNonceBruteCommand] + args print(" Running bruteforce command:") print(" ",end = "") - print(f"tools/mf_nonce_brute {" ".join(cmd_list[1:])}") + print(f"tools/mf_nonce_brute {' '.join(cmd_list[1:])}") result = subprocess.run(cmd_list, shell=os.name == 'nt', stdout=subprocess.PIPE, stderr=subprocess.PIPE) #Parse out the key From dd344fb44e3d20bcea4d331b3db73f2ba5738e41 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 1 Nov 2024 09:38:46 -0700 Subject: [PATCH 17/21] Update info for block 16 --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 467bebd..43e44d5 100644 --- a/README.md +++ b/README.md @@ -308,7 +308,7 @@ Summary of what kind of data is stored in each block. Detailed info for each blo | 3 | 1 | [Block 13](#block-13) Short Production Date/Time | | 3 | 2 | [Block 14](#block-14) Filament Length | | 3 | 3 | [Block 15](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | -| 4 | 0 | [Block 16](#block-16) Color Count, Second Color Code, **Unknown** | +| 4 | 0 | [Block 16](#block-16) Extra Color Info | | 4 | 1 | [Block 17](#block-17) **Unknown** | | 4 | 2 | **Empty** | | 4 | 3 | [Block 19](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab | @@ -492,10 +492,14 @@ Example Data: | position | length | type | Description | | -------- | ------ | ----------- | ---------------------------------- | -| 0 (AA) | 2 | **Unknown** | **Unknown** | -| 2 (BB) | 2 | uint16 (LE) | **Color Count...?** | +| 0 (AA) | 2 | uint16 (LE) | Format Identifier | +| 2 (BB) | 2 | uint16 (LE) | Color Count | | 4 (CC) | 4 | RGBA | Second color in _reverse_ hex ABGR | +Known Format Identifiers: +- 00 00 = Empty +- 02 00 = Color Info + ### Block 17 Example Data: From 6b08e5cdc7c5e2f2fd1f8c6c2c1933e48a281da1 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 1 Nov 2024 09:42:04 -0700 Subject: [PATCH 18/21] Update parse script to handle block 16 better --- parse.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parse.py b/parse.py index 8bc0d35..5fa3017 100644 --- a/parse.py +++ b/parse.py @@ -100,11 +100,13 @@ class Tag(): self.warnings.append(f"Block {bi} is blank!") # Parse the data + has_extra_color_info = self.blocks[16][0:2] == b'\x02\x00' + self.data = { "uid": bytes_to_hex(self.blocks[0][0:4]), "filament_type": bytes_to_string(self.blocks[2]), "detailed_filament_type": bytes_to_string(self.blocks[4]), - "filament_color_count": bytes_to_int(self.blocks[16][2:4]), + "filament_color_count": bytes_to_int(self.blocks[16][2:4]) if has_extra_color_info else 1, "filament_color": "#" + bytes_to_hex(self.blocks[5][0:4]), "spool_weight": Unit(bytes_to_int(self.blocks[5][4:6]), "g"), "filament_length": Unit(bytes_to_int(self.blocks[14][4:6]), "m"), @@ -126,8 +128,7 @@ class Tag(): "production_date": bytes_to_date(self.blocks[12]), "unknown_1": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always - "unknown_2": self.blocks[16][0:2], # So far, always "0200" - "unknown_3": self.blocks[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise + "unknown_2": self.blocks[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise } # Check for any data in bits that are expected to be blank From e99f490ff5382d522441fea1cc5f32a8a72eaf94 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 1 Nov 2024 09:44:42 -0700 Subject: [PATCH 19/21] Specify source blocks in "unknown" values --- parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parse.py b/parse.py index 5fa3017..f3326a7 100644 --- a/parse.py +++ b/parse.py @@ -127,8 +127,8 @@ class Tag(): "tray_uid": self.blocks[9], "production_date": bytes_to_date(self.blocks[12]), - "unknown_1": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always - "unknown_2": self.blocks[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise + "unknown_13": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always + "unknown_17": self.blocks[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise } # Check for any data in bits that are expected to be blank From ea98a9d7530dc2bfb57f04ec607a155e89cd2fa1 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 1 Nov 2024 09:45:52 -0700 Subject: [PATCH 20/21] We know what block 13 is supposed to be --- parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parse.py b/parse.py index f3326a7..24bb1bf 100644 --- a/parse.py +++ b/parse.py @@ -126,8 +126,8 @@ class Tag(): "x_cam_info": self.blocks[8][0:12], "tray_uid": self.blocks[9], "production_date": bytes_to_date(self.blocks[12]), - - "unknown_13": bytes_to_string(self.blocks[13]), # Appears to be some sort of date -- on some tags, this is identical to the production date, but not always + "production_date_short": bytes_to_string(self.blocks[13]), + "unknown_17": self.blocks[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise } From 8d9612f75830e42c077ba3afabd4b82224863164 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 1 Nov 2024 09:59:16 -0700 Subject: [PATCH 21/21] Simplify filament color data (use list instead of strings) --- parse.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/parse.py b/parse.py index 24bb1bf..874669b 100644 --- a/parse.py +++ b/parse.py @@ -82,6 +82,31 @@ class Unit(): values = self.__get_comparison_values(self, other) return values[0] > values[1] +class ColorList(list): + def __init__(self, value): + if type(value) in [list, tuple]: + super().__init__(value) + else: + super().__init__([value]) + + def __str__(self): + return " / ".join("#" + c for c in self) + + def __setitem__(self, index, item): + super().__setitem__(index, str(item)) + + def insert(self, index, item): + super().insert(index, str(item)) + + def append(self, item): + super().append(str(item)) + + def extend(self, other): + if isinstance(other, type(self)): + super().extend(other) + else: + super().extend(str(item) for item in other) + class Tag(): def __init__(self, filename, data): # Check to make sure the data is 1KB @@ -101,13 +126,13 @@ class Tag(): # Parse the data has_extra_color_info = self.blocks[16][0:2] == b'\x02\x00' + filament_color_count = bytes_to_int(self.blocks[16][2:4]) if has_extra_color_info else 1 self.data = { "uid": bytes_to_hex(self.blocks[0][0:4]), "filament_type": bytes_to_string(self.blocks[2]), - "detailed_filament_type": bytes_to_string(self.blocks[4]), - "filament_color_count": bytes_to_int(self.blocks[16][2:4]) if has_extra_color_info else 1, - "filament_color": "#" + bytes_to_hex(self.blocks[5][0:4]), + "filament_type_detailed": bytes_to_string(self.blocks[4]), + "filament_color": ColorList(bytes_to_hex(self.blocks[5][0:4])), "spool_weight": Unit(bytes_to_int(self.blocks[5][4:6]), "g"), "filament_length": Unit(bytes_to_int(self.blocks[14][4:6]), "m"), "filament_diameter": Unit(bytes_to_float(self.blocks[5][8:12]), "mm"), @@ -151,8 +176,8 @@ class Tag(): self.warnings.append(f"Data found in block {block}, position {pos} that was expected to be blank (received {byte})") # Check for a second color - if self.data["filament_color_count"] == 2: - self.data["filament_color"] += " / #" + bytes_to_hex(self.blocks[16][4:8][::-1]) + if filament_color_count == 2: + self.data["filament_color"].append(bytes_to_hex(self.blocks[16][4:8][::-1])) def __str__(self, blocks_to_output = IMPORTANT_BLOCKS): result = ""