Merge branch 'main' into queengooborg-patch-1

This commit is contained in:
Queen Vinyl Da.i'gyu-Kazotetsu committed 2025-06-14 18:54:04 -07:00
commit b1e4f44845
9 files changed
+824 -716

No files matched your search

+228
View File
@@ -0,0 +1,228 @@
# Bambu Lab RFID Tag Documentation
This contains documentation for the known and unknown data that is contained in each block on the RFID tags for Bambu Lab spools.
## Block Overview
Summary of what kind of data is stored in each block. Detailed info for each block is documented below.
| sec | blk | Data |
|-----|-----|----------------------------------------------------------------------------------------|
| 0 | 0 | [Block 0](#block-0) UID and Tag Manufacturer Data |
| 0 | 1 | [Block 1](#block-1) Tray Info Index |
| 0 | 2 | [Block 2](#block-2) Filament Type |
| 0 | 3 | [Block 3](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 1 | 0 | [Block 4](#block-4) Detailed Filament Type |
| 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 Bambu Lab |
| 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) Spool Width |
| 2 | 3 | [Block 11](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 3 | 0 | [Block 12](#block-12) Production Date/Time |
| 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 Bambu Lab |
| 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 Bambu Lab |
| 5 | 0 | **Empty** |
| 5 | 1 | **Empty** |
| 5 | 2 | **Empty** |
| 5 | 3 | [Block 23](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 6 | 0 | **Empty** |
| 6 | 1 | **Empty** |
| 6 | 2 | **Empty** |
| 6 | 3 | [Block 27](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 7 | 0 | **Empty** |
| 7 | 1 | **Empty** |
| 7 | 2 | **Empty** |
| 7 | 3 | [Block 31](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 8 | 0 | **Empty** |
| 8 | 1 | **Empty** |
| 8 | 2 | **Empty** |
| 8 | 3 | [Block 35](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 9 | 0 | **Empty** |
| 9 | 1 | **Empty** |
| 9 | 2 | **Empty** |
| 9 | 3 | [Block 39](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to Bambu Lab |
| 10-15 | \* | **RSA-2048 Signature** |
The first part of the filament serial number seems to be the Tag UID.
> [!NOTE]
> All numbers are encoded as Little Endian (LE).
## MIFARE Encryption Keys
Every 4th block (eg Sector X, Block 3) contains encryption keys that are part of the MIFARE RFID standard.
This has nothing to do with Bambu Lab's memory format.
All Bambu Lab tags use the same Permission Bits (Access Control)
Example Data:
`AA AA AA AA AA AA PP PP PP PP BB BB BB BB BB BB`
| position | length | type | Description |
| -------- | ------ | ------- | ---------------------------------------------------------------------- |
| 0 (AA) | 6 | RAW Bin | A-Key |
| 6 (PP) | 4 | RAW Bin | Permission Bits (Access Control) (always `87 87 87 69` for Bambu Tags) |
| 10 (BB) | 6 | RAW Bin | B-Key (always `00 00 00 00 00 00` for Bambu tags) |
## Block 0
Note: Block 0 is Read-only. The contents are set by the tag manufacturer.
Example Data:
`AA AA AA AA BB BB BB BB BB BB BB BB BB BB BB BB`
| position | length | type | Description |
| -------- | ------ | ------- | --------------------- |
| 0 (AA) | 4 | string | Tag UID |
| 4 (BB) | 12 | RAW Bin | Tag Manufacturer Data |
## Block 1
Example Data:
`AA AA AA AA AA AA AA AA BB BB BB BB BB BB BB BB`
| position | length | type | Description |
| -------- | ------ | ------ | ------------------------------------- |
| 0 (AA) | 8 | string | Tray Info Index - Material Variant ID |
| 8 (BB) | 8 | string | Tray Info Index - Material ID |
The material IDs all start with the letters "GF" (so far), and the material variant IDs start with the last three letters of the material ID. For example, a variant ID of `A50-K0` is associated with a material ID of `GFA50`.
## Block 2
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | ------------- |
| 0 (AA) | 16 | string | Filament Type |
## Block 4
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | description |
| -------- | ------ | ------ | ---------------------- |
| 0 (AA) | 16 | string | Detailed Filament Type |
Known Values:
- PLA Basic
- PLA Matte
- PLA Silk
- PLA Galaxy
- PLA Sparkle
- Support for PLA (prev. Support W)
- PLA-CF (prev. PLA Tough)
- PETG Basic
## Block 5
Example Data:
`AA AA AA AA BB BB __ __ CC CC CC CC __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | ------------------------------------------ |
| 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 |
## Block 6
Example Data:
`AA AA BB BB CC CC DD DD EE EE FF FF __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | --------------------------------------- |
| 0 (AA) | 2 | uint16 (LE) | Drying Temperature in °C |
| 2 (BB) | 2 | uint16 (LE) | Drying time in hours |
| 4 (CC) | 2 | uint16 (LE) | Bed Temerature Type **(types unknown)** |
| 6 (DD) | 2 | uint16 (LE) | Bed Temperature in °C |
| 8 (EE) | 2 | uint16 (LE) | Max Temperature for Hotend in °C |
| 10 (FF) | 2 | uint16 (LE) | Min Temperature for Hotend in °C |
## Block 8
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA BB BB BB BB`
| position | length | type | description |
| -------- | ------ | ---------- | ----------------------- |
| 0 (AA) | 12 | RAW Bin | X Cam info |
| 12 (BB) | 4 | float (LE) | **Nozzle Diameter...?** |
## Block 9
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | ----------- |
| 0 (AA) | 16 | string | Tray UID |
## Block 10
Example Data:
`__ __ __ __ AA AA __ __ __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | ----------------------------------------------------- |
| 4 (AA) | 2 | uint16 (LE) | Spool Width in mm*100 (`E1 19` --> 6625 --> 66.25mm ) |
## Block 12
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | -------------------------------------------------------------------------- |
| 0 (AA) | 16 | string | Production Date and Time in ASCII (`<year>_<month>_<day>_<hour>_<minute>`) |
## Block 13
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | ---------------------------------- |
| 0 (AA) | 16 | string | **Short Production Date/Time...?** |
## Block 14
Example Data:
`__ __ __ __ AA AA __ __ __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | --------------------------------- |
| 4 (AA) | 2 | uint16 (LE) | **Filament length in meters...?** |
## Block 16
Example Data:
`AA AA BB BB CC CC CC CC __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | ---------------------------------- |
| 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:
`AA AA __ __ __ __ __ __ __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | ----------- |
| 0 (AA) | 2 | **Unknown** | **Unknown** |
+25
View File
@@ -0,0 +1,25 @@
# Creality RFID Tag Documentation
This contains documentation for the data that is contained in the RFID tags for Creality RFID spools.
The data format has been primarily researched in the following Reddit thread: https://www.reddit.com/r/Creality_k2/comments/1h5egkv/introducing_rfid_for_cfs_an_android_app_for/?share_id=Vu3JVyAm0wjQzBbbYK9Yp&utm_name=androidcss
## Overview
The data in the tags for Creality RFID spools is stored in blocks 4 through 6. The data is ASCII-encoded and stored in a byte-like format.
## Data
Example Data: 7A3 24120 0A21 01001 #000000 016500 000100000000000000
`AAA BBBBB CCCC DDDDD #EEEEEE FFFFFF GGGGGGGGGGGGGGGGGG`
| position | length | type | Description |
| -------- | ------ | ------- | --------------------------- |
| 0 (A) | 3 | hex | Batch number |
| 3 (B) | 5 | date | Manufacturing date as YYMDD |
| 8 (C) | 4 | hex | Supplier ID |
| 12 (D) | 5 | hex | Material ID |
| 17 (E) | 6 | RGB | Material Color |
| 23 (F) | 5 | hex | Spool ID...? |
| 28 (G) | 18 | unknown | Unknown |
+2 -165
View File
@@ -1,166 +1,3 @@
# OpenTag: Open Source RFID Standard
RFID is becoming more prevalent, with each company launching their own RFID system that is incompatible with the rest.
OpenTag strives to be a standard that allows RFID tags to work across 3D Printer Brands, Filament Brands, and Accessory Brands.
File Moved
OpenTag aims to standardize the following:
* **Hardware** - The specific underlying RFID technology
* **Mechanical Requirements** - Positioning of tag on the spool
* **Data Structure** - What data should be stored on the RFID tag, and how that data should be formatted
* **Web API** - How extended data should be formatted when an optional online spool lookup is requested
<img src="images/SpoolTag.jpg" height=300>
# Table of Contents
* [Backers](#backers)
* [Why RFID](#why-rfid)
* [OpenTag Standards](#opentag-standards)
* [Hardware Standard](#hardware-standard)
* [Mechanical Standard](#mechanical-standard)
* [Data Structure Standard](#data-structure-standard)
* [Web API Standard](#web-api-standard)
* [Add RFID support to your printer](#add-rfid-support-to-your-printer)
* [OpenTag Consortium](#opentag-consortium)
* [Voting Members](#voting-members)
* [Non-Voting Members](#non-voting-members)
* [Previous Considerations](#previous-considerations)
# Backers
These are companies that are implementing Open 3D-RFID into their printers, filament, add-ons, etc. If you would like to join this list, please open an Issue on GitHub.
* Filament Manufacturers (Sorted by date backed):
* [Polar Filament](https://polarfilament.com)
* [3D Fuel](https://www.3dfuel.com/)
* [Ecogenesis Biopolymers](https://ecogenesisbiopolymers.com)
* [Numakers](https://numakers.com/)
* [American Filament](https://americanfilament.us)
* Printers + Hardware:
* [OpenSpool](https://www.youtube.com/watch?v=ah7dm-dtQ5w) ([GitHub Source](https://github.com/spuder/OpenSpool))
* [Cosmyx](https://www.cosmyx3d.com/)
* [Distrifab](https://distrifab.fr/)
# Why RFID?
What is the benefit of adding RFID chips to filament?
* AMS / Multi-Material Printers
* **Color + Material ID:** Simplifying the painting process! AMS units can automatically detect what filament is loaded up in each slot. This also adds a sanity check before you start printing to make sure you don't end up with a print in the wrong color.
* High-Speed Printing
* **Advanced Filament Data:** Tags can store advanced per-spool printing data, such as printing/bed temps, melt-flow index, retration, and even filament diameter graphs. This would make the transition simpler when using filaments from different brands.
* HueForge
* **Transmission distance + Hex**: Each spool can have a unique TD and color. Saving this data on the spool allows for more accurate tuning, and less math for the consumer
* Every Printer
* **Filament Remaining Estimation:** Using the RFID tag as an encoder, printers can measure how long it takes for one rotation of a spool of filament, and use this to estimate how much filament is remaining.
* **Print Profiles**: Each spool can contain print/bed temps, as well as other settings like retraction settings. This makes it much easier to use different brands/colors/materials without worrying about creating a bunch of different slicer profiles.
# Add RFID support to your printer
This standard was designed to be simple to implement in firmware. You will need to add custom firmware and potentially an RFID reader (if your printer doesn't already have one).
RFID support can theoretically be added to any printer using off-the-shelf RFID Modules such as the PN532 (as low as $3). This module communicates over SPI.
<img src="images/PN532-Reader-Blue.png" width=200>
<img src="images/PN532-Reader-Red.png" width=200>
Did you make a design to add RFID to your printer? Let us know so we can link to it here! Designs can be 3D models, or firmware.
# OpenTag Standards
## Hardware Standard
NFC NTAG216: 13.56 MHz 888-byte tags
<img src="images/mifareclassicsticker.jpg" width="200">
NTAG216 tags are cheap and common. They allow 888 bytes of data, which is plenty of space to store required information. NFC tags such as NTAG216 can be read/written with smartphones. 13.56 MHz RFID modules are plentiful, low-cost and Arduino-compatible, allowing for easy integration.
NFC NTAG216 was chosen over MIFARE 1K Classic tags, which is what the Bambu AMS uses, for the following reasons:
* More memory (NTAG216: 888-bytes usable, MF1K: 768-bytes usable)
* Smartphone Support: NTAG216 can be read from smartphones, while MF1K requires a dedicated reader
## Mechanical Standard
* Tag placement: The center should be 56.0mm away from the center of the spool (see pic)
* The tag should never be more than 4.0mm away from the external surface of the spool
* For spool sides thicker than 4mm, there must be a cutout to embed the tag, or the tag should be fixed to the outside of the spool
* Two tags should be used, one on each end of the spool, directly across from each other
<img src="images/TagLocation.png" width="400">
## Data Structure Standard
This is a list of data that will live on the RFID chip, separated into required and optional data. All REQUIRED data must be populated to be compliant with this open source RFID protocol.
NTAG216 tags have 888 bytes of usable memory.
### Required Data
All chips MUST contain this information, otherwise they are considered non-compliant
| Field | Data Type | Size (bytes) | Example | Description
|-------------|---------------|------------|----|-----|
| Tag Version | Int | 2 | `1234` | RFID tag data format version to allow future compatibility in the event that the data format changes dramatically. Stored as an int with 3 implied decimal points. Eg `1000` -> `version 1.000`|
| Filament Manufacturer | String | 16 | `"Polar Filament"` | String representation of filament manufacturer. 16 bytes is the max data length per-block. Longer names will be abbreviated or truncated |
| Material Name | String | 16 | `"PLA"` or `"Glass-Filled PC"` | Material name in plain text |
| Color Name | String | 32 | `"Blue"` or `"Electric Watermellon"` | Color in plain text. Color spans 2-blocks |
| Diameter (Target) | Int | 2 | `1750` or `2850` | Filament diameter (target) in µm (micrometers) Eg "1750" -> "1.750mm"
| Weight (Nominal, grams) | Int | 2 | `1000` (1kg), `5000` (5kg), `750` (750g) | Filament weight in grams, excluding spool weight. This is the TARGET weight, eg "1kg". Actual measured weight is stored in a different field.
| Print Temp (C)| Int | 2 | `210` (C), `240` (C) | The recommended print temp in degrees-C
| Bed Temp (C) | Int | 2 | `60` (C), `80` (C) | The recommended bed temp in degrees-C |
| Density | Int | 2 | `1240` (1.240g/cm<sup>3</sup>), `3900` (3.900g/cm<sup>3</sup>) | Filament density, measured in µg (micrograms) per cubic centimeter.
### Optional Data
This is additional data that not all manufacturers will implement, typically due to technological restrictions. These fields are populated if available. All unused fields must be populated with "-1" (all 1's in binary, eg 0xFFFFFFFFFFFFFFFF)
| Field | Data Type | Size (bytes) | Example | Description
|-------------|---------------|------------|----|-----|
| Serial Number / Batch ID | String | 16 | `"1234-ABCD"`, `"2024-01-23-1234"` | An identifier to represent a serial number or batch number from manufacturing. Stored as a string, and this format will vary from manufacturer to manufacturer |
| Manufacture Date | Int | 4 | `20240123` (Jan 23rd, 2024) | Date code in YYYYMMDD format, stored as a 32-bit integer |
| Manufacture Time | Int | 3 | `103000` (10:30am), `152301` (3:23:01pm) | 24-hour time code in HHMMSS format (Hour, Minumte, Second), specifying UTC.
| Spool Core Diameter (mm) | Int | 1 | `100` (mm), `80` (mm) | The diameter of the spool core, which is the part that the filament is wound around. This diameter is to estimate remaining filament by treating the tag as an encoder, and measuring how long it takes for one rotation of a spool.
| MFI (Melt-flow index) | TBD | TBD | TBD | Format TBD. The melt-flow index describes how "melty" plastic is. Meltier plastics can usually print faster. Formula is somewhat complex, and often measured at different temperatures. For example Corbion LX175 melt flow index is `MFI(210°C/2.16kg) = 6g/10min`, and `MFI(190°C/2.16kg) = 3g/10min`
| Tolerance (Measured) | Int | 1 | `20` (±0.020mm), `55` (±0.055mm) | Actual tolerance, measured in µm (micrometers). This field is unique to each spool, and should only be populated if per-spool tolerances are measured and recorded during manufacturing. This is not a TARGET tolerance, this is ACTUAL. If not recorded, leave undefined (0xFF)
| Additional Data URL | String | 32 | `pfil.us?i=8078-RQSR` | URL to access additional data in JSON format. This data may be unique to this spool, or just general info about this material. All urls must be https, and the "https" at the beginning is implied. Eg `pfil.us?i=8078-RQSR` becomes `https:pfil.us?i=8078-RQSR`, formatted this way to save memory.
| Empty Spool Weight (g) | Int | 2 | `105` (105 grams) | Weight of the empty spool in grams. This can be used to calculate how much filament is remaining on each spool
| Filament Weight (Measured) | Int | 2 | `1002` (1002 grams) | ACTUAL weight of the filament, excluding empty-spool weight. Measured after filament manufacturing. This is not the target weight (eg 1kg) but rather the actual weighed result (eg 1.002kg).
| Filament Length (Measured) | Int | 2 | `336` (336 meters) | ACTUAL length of filament measured in meters. This is unique to each spool.
| TD (Transmission Distance) | Int | 2 | `2540` (2.540mm) | Transmission Distance in µm (micrometers). Transmission distance is the distance at which no light can pass through the filament. See the HueForge project for more details |
| Color Hex | Int | 3 | `0xffa64d` (Light orange color) | Color hexcode. Hex is a 3-byte number in the format 0xRRGGBB (Red, Green, Blue, one byte each) |
| Max Dry Temp (C) | Int | 1 | `55` (55C), `50` (50C) Maximum drying temperature in Degrees-C. Drying above this temperature can damage the filament
### Web API Standard
Some tags can contain extended data that doesn't fit or doesn't belong on the RFID tag itself. One example is a diameter graph, which is too much data to be stored within only 888 bytes of memory.
These complex variables can be looked up using the "web API" URL that is stored on the RFID tag.
The format of this data should be JSON.
The exact contents of this data are still open to discussion, and it is not required to launch the OpenTag standard. The web API can be implemented in the future without affecting the launch of OpenTag.
## OpenTag Consortium
The OpenTag Consortium is a collaborative group of 3D printing companies, hobbyists, RFID experts, and other stakeholders committed to maintaining and evolving the OpenTag RFID standard specification. The consortium operates under a structured membership model, ensuring a balance of inclusivity and effective decision-making.
### Voting Members
Voting members play a critical role in the governance of the OpenTag standard. They have the authority to vote on proposals related to modifying the specification. Their decisions shape the future direction of OpenTag, ensuring it meets the needs of the community and industry.
To maintain fairness and inclusivity, the voting seats are divided equally between:
* Industry Representatives: Voting members representing companies and organizations involved in 3D printing, RFID, and related fields.
* Community Representatives: Voting members from the broader community, including hobbyists, independent developers, and RFID experts.
This balanced structure ensures that no single group dominates decision-making, fostering a standard that reflects the interests of both professional and grassroots contributors.
### Non-Voting Members
Non-voting members are integral to the consortium's ecosystem, contributing ideas and fostering collaboration. While they cannot directly vote on proposals, they can:
* **Propose Changes**: Submit new ideas or modifications to the specification, which voting members will evaluate and vote on.
* **Elect Voting Members**: Participate in elections to select voting members through a popular vote, ensuring representation aligns with the community’s vision.
This dual-tier structure enables broad participation while maintaining an efficient and organized decision-making process.
## Previous Considerations
These are topics that are commonly brought up when learning about OpenTag. Below is a quick summary of each topic, and why we decided to settle on the standards we defined.
* NTAG216 vs MIFARE:
* NTAG216 is compatible with smartphones and has slightly more usable memory than MIFARE tags
* MIFARE uses about 25% of memory to encrypt data, preventing read/write operations, which is not applicable for OpenTag because of the open-source nature
* JSON vs Memory Map:
* Formats such as JSON (human-readable text) takes up considerably more more memory than memory mapped. For example, defining something like Printing Temperature would be `PrintTemp:225` which is 13 bytes, instead of storing a memory mapped 2-byte number. Tokens could be reduced, but that also defeats the purpose of using JSON in the first place, which is often for readability.
* NTAG216 tags only have 888 bytes of usable memory, which would be eaten up quickly
* Lookup Tables
* OpenTag does NOT use lookup tables, which would be too difficult to maintain due to the decentralized nature of this standard.
* Lookup tables can quickly become outdated, which would require regular updates to tag readers to make sure they've downloaded the most recent table.
* Storing lookup tables consumes more memory on the device that reads tags
* On-demand lookup (via the internet) would require someone to host a database. Hosting this data would have costs associated with it, and would also put the control of the entire OpenTag format in the hands of a single person/company
* Rather than representing data as a number (such as "company #123 = Example Company), the plain-text company name should be used instead
See [OpenTag.md](./OpenTag.md)
+166
View File
@@ -0,0 +1,166 @@
# OpenTag: Open Source RFID Standard
RFID is becoming more prevalent, with each company launching their own RFID system that is incompatible with the rest.
OpenTag strives to be a standard that allows RFID tags to work across 3D Printer Brands, Filament Brands, and Accessory Brands.
OpenTag aims to standardize the following:
* **Hardware** - The specific underlying RFID technology
* **Mechanical Requirements** - Positioning of tag on the spool
* **Data Structure** - What data should be stored on the RFID tag, and how that data should be formatted
* **Web API** - How extended data should be formatted when an optional online spool lookup is requested
<img src="images/SpoolTag.jpg" height=300>
# Table of Contents
* [Backers](#backers)
* [Why RFID](#why-rfid)
* [OpenTag Standards](#opentag-standards)
* [Hardware Standard](#hardware-standard)
* [Mechanical Standard](#mechanical-standard)
* [Data Structure Standard](#data-structure-standard)
* [Web API Standard](#web-api-standard)
* [Add RFID support to your printer](#add-rfid-support-to-your-printer)
* [OpenTag Consortium](#opentag-consortium)
* [Voting Members](#voting-members)
* [Non-Voting Members](#non-voting-members)
* [Previous Considerations](#previous-considerations)
# Backers
These are companies that are implementing OpenTag into their printers, filament, add-ons, etc. If you would like to join this list, please open an Issue on GitHub.
* Filament Manufacturers (Sorted by date backed):
* [Polar Filament](https://polarfilament.com)
* [3D Fuel](https://www.3dfuel.com/)
* [Ecogenesis Biopolymers](https://ecogenesisbiopolymers.com)
* [Numakers](https://numakers.com/)
* [American Filament](https://americanfilament.us)
* Printers + Hardware:
* [OpenSpool](https://www.youtube.com/watch?v=ah7dm-dtQ5w) ([GitHub Source](https://github.com/spuder/OpenSpool))
* [Cosmyx](https://www.cosmyx3d.com/)
* [Distrifab](https://distrifab.fr/)
# Why RFID?
What is the benefit of adding RFID chips to filament?
* AMS / Multi-Material Printers
* **Color + Material ID:** Simplifying the painting process! AMS units can automatically detect what filament is loaded up in each slot. This also adds a sanity check before you start printing to make sure you don't end up with a print in the wrong color.
* High-Speed Printing
* **Advanced Filament Data:** Tags can store advanced per-spool printing data, such as printing/bed temps, melt-flow index, retration, and even filament diameter graphs. This would make the transition simpler when using filaments from different brands.
* HueForge
* **Transmission distance + Hex**: Each spool can have a unique TD and color. Saving this data on the spool allows for more accurate tuning, and less math for the consumer
* Every Printer
* **Filament Remaining Estimation:** Using the RFID tag as an encoder, printers can measure how long it takes for one rotation of a spool of filament, and use this to estimate how much filament is remaining.
* **Print Profiles**: Each spool can contain print/bed temps, as well as other settings like retraction settings. This makes it much easier to use different brands/colors/materials without worrying about creating a bunch of different slicer profiles.
# Add RFID support to your printer
This standard was designed to be simple to implement in firmware. You will need to add custom firmware and potentially an RFID reader (if your printer doesn't already have one).
RFID support can theoretically be added to any printer using off-the-shelf RFID Modules such as the PN532 (as low as $3). This module communicates over SPI.
<img src="images/PN532-Reader-Blue.png" width=200>
<img src="images/PN532-Reader-Red.png" width=200>
Did you make a design to add RFID to your printer? Let us know so we can link to it here! Designs can be 3D models, or firmware.
# OpenTag Standards
## Hardware Standard
NFC NTAG216: 13.56 MHz 888-byte tags
<img src="images/mifareclassicsticker.jpg" width="200">
NTAG216 tags are cheap and common. They allow 888 bytes of data, which is plenty of space to store required information. NFC tags such as NTAG216 can be read/written with smartphones. 13.56 MHz RFID modules are plentiful, low-cost and Arduino-compatible, allowing for easy integration.
NFC NTAG216 was chosen over MIFARE 1K Classic tags, which is what the Bambu AMS uses, for the following reasons:
* More memory (NTAG216: 888-bytes usable, MF1K: 768-bytes usable)
* Smartphone Support: NTAG216 can be read from smartphones, while MF1K requires a dedicated reader
## Mechanical Standard
* Tag placement: The center should be 56.0mm away from the center of the spool (see pic)
* The tag should never be more than 4.0mm away from the external surface of the spool
* For spool sides thicker than 4mm, there must be a cutout to embed the tag, or the tag should be fixed to the outside of the spool
* Two tags should be used, one on each end of the spool, directly across from each other
<img src="images/TagLocation.png" width="400">
## Data Structure Standard
This is a list of data that will live on the RFID chip, separated into required and optional data. All REQUIRED data must be populated to be compliant with this open source RFID protocol.
NTAG216 tags have 888 bytes of usable memory.
### Required Data
All chips MUST contain this information, otherwise they are considered non-compliant
| Field | Data Type | Size (bytes) | Example | Description
|-------------|---------------|------------|----|-----|
| Tag Version | Int | 2 | `1234` | RFID tag data format version to allow future compatibility in the event that the data format changes dramatically. Stored as an int with 3 implied decimal points. Eg `1000` -> `version 1.000`|
| Filament Manufacturer | String | 16 | `"Polar Filament"` | String representation of filament manufacturer. 16 bytes is the max data length per-block. Longer names will be abbreviated or truncated |
| Material Name | String | 16 | `"PLA"` or `"Glass-Filled PC"` | Material name in plain text |
| Color Name | String | 32 | `"Blue"` or `"Electric Watermellon"` | Color in plain text. Color spans 2-blocks |
| Diameter (Target) | Int | 2 | `1750` or `2850` | Filament diameter (target) in µm (micrometers) Eg "1750" -> "1.750mm"
| Weight (Nominal, grams) | Int | 2 | `1000` (1kg), `5000` (5kg), `750` (750g) | Filament weight in grams, excluding spool weight. This is the TARGET weight, eg "1kg". Actual measured weight is stored in a different field.
| Print Temp (C)| Int | 2 | `210` (C), `240` (C) | The recommended print temp in degrees-C
| Bed Temp (C) | Int | 2 | `60` (C), `80` (C) | The recommended bed temp in degrees-C |
| Density | Int | 2 | `1240` (1.240g/cm<sup>3</sup>), `3900` (3.900g/cm<sup>3</sup>) | Filament density, measured in µg (micrograms) per cubic centimeter.
### Optional Data
This is additional data that not all manufacturers will implement, typically due to technological restrictions. These fields are populated if available. All unused fields must be populated with "-1" (all 1's in binary, eg 0xFFFFFFFFFFFFFFFF)
| Field | Data Type | Size (bytes) | Example | Description
|-------------|---------------|------------|----|-----|
| Serial Number / Batch ID | String | 16 | `"1234-ABCD"`, `"2024-01-23-1234"` | An identifier to represent a serial number or batch number from manufacturing. Stored as a string, and this format will vary from manufacturer to manufacturer |
| Manufacture Date | Int | 4 | `20240123` (Jan 23rd, 2024) | Date code in YYYYMMDD format, stored as a 32-bit integer |
| Manufacture Time | Int | 3 | `103000` (10:30am), `152301` (3:23:01pm) | 24-hour time code in HHMMSS format (Hour, Minumte, Second), specifying UTC.
| Spool Core Diameter (mm) | Int | 1 | `100` (mm), `80` (mm) | The diameter of the spool core, which is the part that the filament is wound around. This diameter is to estimate remaining filament by treating the tag as an encoder, and measuring how long it takes for one rotation of a spool.
| MFI (Melt-flow index) | TBD | TBD | TBD | Format TBD. The melt-flow index describes how "melty" plastic is. Meltier plastics can usually print faster. Formula is somewhat complex, and often measured at different temperatures. For example Corbion LX175 melt flow index is `MFI(210°C/2.16kg) = 6g/10min`, and `MFI(190°C/2.16kg) = 3g/10min`
| Tolerance (Measured) | Int | 1 | `20` (±0.020mm), `55` (±0.055mm) | Actual tolerance, measured in µm (micrometers). This field is unique to each spool, and should only be populated if per-spool tolerances are measured and recorded during manufacturing. This is not a TARGET tolerance, this is ACTUAL. If not recorded, leave undefined (0xFF)
| Additional Data URL | String | 32 | `pfil.us?i=8078-RQSR` | URL to access additional data in JSON format. This data may be unique to this spool, or just general info about this material. All urls must be https, and the "https" at the beginning is implied. Eg `pfil.us?i=8078-RQSR` becomes `https:pfil.us?i=8078-RQSR`, formatted this way to save memory.
| Empty Spool Weight (g) | Int | 2 | `105` (105 grams) | Weight of the empty spool in grams. This can be used to calculate how much filament is remaining on each spool
| Filament Weight (Measured) | Int | 2 | `1002` (1002 grams) | ACTUAL weight of the filament, excluding empty-spool weight. Measured after filament manufacturing. This is not the target weight (eg 1kg) but rather the actual weighed result (eg 1.002kg).
| Filament Length (Measured) | Int | 2 | `336` (336 meters) | ACTUAL length of filament measured in meters. This is unique to each spool.
| TD (Transmission Distance) | Int | 2 | `2540` (2.540mm) | Transmission Distance in µm (micrometers). Transmission distance is the distance at which no light can pass through the filament. See the HueForge project for more details |
| Color Hex | Int | 3 | `0xffa64d` (Light orange color) | Color hexcode. Hex is a 3-byte number in the format 0xRRGGBB (Red, Green, Blue, one byte each) |
| Max Dry Temp (C) | Int | 1 | `55` (55C), `50` (50C) Maximum drying temperature in Degrees-C. Drying above this temperature can damage the filament
### Web API Standard
Some tags can contain extended data that doesn't fit or doesn't belong on the RFID tag itself. One example is a diameter graph, which is too much data to be stored within only 888 bytes of memory.
These complex variables can be looked up using the "web API" URL that is stored on the RFID tag.
The format of this data should be JSON.
The exact contents of this data are still open to discussion, and it is not required to launch the OpenTag standard. The web API can be implemented in the future without affecting the launch of OpenTag.
## OpenTag Consortium
The OpenTag Consortium is a collaborative group of 3D printing companies, hobbyists, RFID experts, and other stakeholders committed to maintaining and evolving the OpenTag RFID standard specification. The consortium operates under a structured membership model, ensuring a balance of inclusivity and effective decision-making.
### Voting Members
Voting members play a critical role in the governance of the OpenTag standard. They have the authority to vote on proposals related to modifying the specification. Their decisions shape the future direction of OpenTag, ensuring it meets the needs of the community and industry.
To maintain fairness and inclusivity, the voting seats are divided equally between:
* Industry Representatives: Voting members representing companies and organizations involved in 3D printing, RFID, and related fields.
* Community Representatives: Voting members from the broader community, including hobbyists, independent developers, and RFID experts.
This balanced structure ensures that no single group dominates decision-making, fostering a standard that reflects the interests of both professional and grassroots contributors.
### Non-Voting Members
Non-voting members are integral to the consortium's ecosystem, contributing ideas and fostering collaboration. While they cannot directly vote on proposals, they can:
* **Propose Changes**: Submit new ideas or modifications to the specification, which voting members will evaluate and vote on.
* **Elect Voting Members**: Participate in elections to select voting members through a popular vote, ensuring representation aligns with the community’s vision.
This dual-tier structure enables broad participation while maintaining an efficient and organized decision-making process.
## Previous Considerations
These are topics that are commonly brought up when learning about OpenTag. Below is a quick summary of each topic, and why we decided to settle on the standards we defined.
* NTAG216 vs MIFARE:
* NTAG216 is compatible with smartphones and has slightly more usable memory than MIFARE tags
* MIFARE uses about 25% of memory to encrypt data, preventing read/write operations, which is not applicable for OpenTag because of the open-source nature
* JSON vs Memory Map:
* Formats such as JSON (human-readable text) takes up considerably more more memory than memory mapped. For example, defining something like Printing Temperature would be `PrintTemp:225` which is 13 bytes, instead of storing a memory mapped 2-byte number. Tokens could be reduced, but that also defeats the purpose of using JSON in the first place, which is often for readability.
* NTAG216 tags only have 888 bytes of usable memory, which would be eaten up quickly
* Lookup Tables
* OpenTag does NOT use lookup tables, which would be too difficult to maintain due to the decentralized nature of this standard.
* Lookup tables can quickly become outdated, which would require regular updates to tag readers to make sure they've downloaded the most recent table.
* Storing lookup tables consumes more memory on the device that reads tags
* On-demand lookup (via the internet) would require someone to host a database. Hosting this data would have costs associated with it, and would also put the control of the entire OpenTag format in the hands of a single person/company
* Rather than representing data as a number (such as "company #123 = Example Company), the plain-text company name should be used instead
+122 -494
View File
@@ -1,553 +1,182 @@
# Bambulab RFID Tag Guide
# Bambu Lab RFID Tag Guide
This guide gives you a basic overview how you can decrypt and read your tags. Since we don't know how Bambulab will react on this guide and the general reverse engineering of the tags: **Please don't share you tag's UID and the related keys for now.**
This guide gives you a basic overview how you can decrypt and read your tags.
We are currently working on a way to submit the tag data in a secure way so analysis on the data could be done.
[View Collection of Tags](https://github.com/queengooborg/Bambu-Lab-RFID-Library)
[![Link to Discord](https://img.shields.io/badge/Discord-join_now-blue?style=flat-square&logo=discord&logoColor=white&label=Discord&color=blue)](https://discord.gg/zVfCVubwr7)
# Table of contents
# Table of contents
<!--ts-->
* [Project Summary](#project-summary)
* [FAQs](#faqs)
* [How do RFID tags work?](#how-do-rfid-tags-work)
* [How to contribute](#how-to-contribute)
* [Todos/Timeline/Next steps](#todostimelinenext-steps)
* [Required Equipment](#required-equipment)
* [Todos/Timeline/Next steps](#todostimelinenext-steps)
* [Requirements](#requirements)
* [Proxmark3 compatible readers](#proxmark3-compatible-readers)
* [Proxmark3 Easy](#proxmark3-easy)
* [Hacking a Bambulab Tag and readout of its data](#hacking-a-bambulab-tag-and-readout-of-its-data)
* [Hacking a Bambu Lab Tag and readout of its data](#hacking-a-bambu-lab-tag-and-readout-of-its-data)
* [Deriving the keys](#deriving-the-keys)
* [Proxmark3 fm11rf08s recovery script](#proxmark3-fm11rf08s-recovery-script)
* [Bambulab AMS RFID reader location](#bambulab-ams-rfid-reader-location)
* [Bambulab AMS Lite RFID reader location (legacy)](#bambulab-ams-lite-rfid-reader-location-legacy)
* [Proxmark3 placement for sniffing (legacy)](#proxmark3-placement-for-sniffing-legacy)
* [Key Derivation](#key-derivation)
* [Dump RFID Contents (.bin) (legacy)](#dump-rfid-contents-bin-legacy)
* [Sniffing the tag data with a Proxmark3 (legacy method)](#sniffing-the-tag-data-with-a-proxmark3-legacy-method)
* [Tag Documentation](#tag-documentation)
* [Block Overview](#block-overview)
* [MIFARE Encryption Keys](#mifare-encryption-keys)
* [Block 0](#block-0)
* [Block 1](#block-1)
* [Block 2](#block-2)
* [Block 4](#block-4)
* [Block 5](#block-5)
* [Block 6](#block-6)
* [Block 8](#block-8)
* [Block 9](#block-9)
* [Block 10](#block-10)
* [Block 12](#block-12)
* [Block 13](#block-13)
* [Block 14](#block-14)
* [Block 16](#block-16)
* [Block 17](#block-17)
* [Compatible RFID tags - By generation](#compatible-rfid-tags----by-generation)
* [How do RFID tags work?](#how-do-rfid-tags-work)
* [Compatible RFID tags - By generation](#compatible-rfid-tags---by-generation)
* [Reverse engineering RFID Board](#reverse-engineering-rfid-board)
<!--te-->
## Project Summary
This is a research group dedicated to documenting the data structures used by Bambulab 3D printers to identify filament data.
This is a research group dedicated to documenting the data structures used by Bambu Lab 3D printers to identify filament data.
### FAQs
* **Can I clone tags?**
* Yes, you can read and clone tags using a tool such as a Proxmark3
* **Can I create custom tags?**
* No, tags are digitally signed. Even if you modify the contents, the printer will reject any tags without a valid RSA signature
* An [Open Source RFID Tag](OpenSourceRfid.md) has been proposed to allow anyone to create / modify their own tags. This must be adopted by printer manufacturers, or you can mod your own printer for support
* **What are the next steps for this project?**
* Decyphering the rest of the unknown tag content
* Custom AMS firmware that allows custom tags to be read while ignoring the signature
* See [Todos/Timeline/Next steps](#todostimelinenext-steps) for more info
### How do RFID tags work?
Here's a high-level summary of how everything works:
* BambuLab printers use MiFare 13.56MHZ RFID tags
* These tags contain a unique ID that is not encrypted (called the UID)
* In most cases UID is fixed (not-changable). Some "hackable" rfid tags allow you to set the UID to anything you want
* Blocks (Encrypted)
* MiFare tags also contain "Blocks" of data. Each block contains info about the spool, such as Material, Color, Manufacturing Date, etc. See [Tag stucture](#tag-stucture) section for details
* The blocks are encrypted, meaning that you need to have a KEY to decipher them
* Each block is encrypted with a different key
* Encryption Keys
* Keys are unique to each RFID tag. Even if you discover the key for one tag, that doesn't mean you can use that same key to unlock a different tag.
* As of 11/19/24, keys can be derived from the UID. After reading the UID from the tag, the KDF (key derivation function) can be used to derive the 16 keys.
* (Outdated, sniffing is no longer required now that the KDF is known) Keys can be sniffed by using a device (such as a ProxMark 3) to listen in on the communication between the AMS and the rfid tag.
* Once the keys have been sniffed, they can be saved and used to read the contents of the tag directly (without an AMS). (Reminder, the saved keys will ONLY work for the tag they were sniffed from)
* RSA Signature
* One of the blocks contains a 2048-bit RSA Signature
* RSA signatures are a way to digitally sign / certify authenticity of content, and they are effectively un-breakable (this is how things like cryptocurrency remain secure)
* RSA signatures encompass all of the data of the RFID tag. Changing a single byte somewhere else in the tag would require a completely different signature to be considered genuine
* Bambu printers check the content of the tag and then check if the signature is valid. If the signature is invalid, it rejects the tag
* Cloning Tags
* Even though there is a signature, a tag can be cloned
* To clone a tag, it must have the same UID, identical content from the data blocks, and the identical RSA signature
* Changing even one byte will cause the signature to be invalid, and the tag will be rejected
* Custom Tags
* This is very unlikely to happen, mostly due to the RSA signature. Only Bambu has their "Private Key" which is used to digitally sign these tags.
* To create a custom key, you need to know the following info:
* RSA Signature Private Key. You'd have to get this from bambu, good luck
* Since Bambulab will likely not remove the signature requirement, you would need custom AMS firmware to read tags and ignore the signature
- **Can I create custom tags?**
- No, tags are digitally signed. Even if you modify the contents, the printer will reject any tags without a valid RSA signature
- An [Open Source RFID Tag](OpenSourceRfid.md) has been proposed to allow anyone to create / modify their own tags. This must be adopted by printer manufacturers, or you can mod your own printer for support
- **Can I clone tags?**
- Yes, you can read and clone tags using a tool such as a Proxmark3. Check out our [collection of scanned tags](https://github.com/queengooborg/Bambu-Lab-RFID-Library)
- **What are the next steps for this project?**
- Decyphering the rest of the unknown tag content
- Custom AMS firmware that allows custom tags to be read while ignoring the signature
- See [Todos/Timeline/Next steps](#todostimelinenext-steps) for more info
### How to contribute
If you have a Proxmark3 (or other RFID debugging tool), you can sniff and decrypt the contents of your tags and submit them for review.
The more data we have, the easier it is to compare differences to learn what each byte represents. A lot of the contents have been deciphered (see [Tag stucture](#tag-stucture)), but there is still more unknown data still left.
## Todos/Timeline/Next steps
If you have a Proxmark3 (or other RFID debugging tool), you can decrypt the contents of your Bambu Lab RFID tags and submit them via [Discord](https://discord.gg/zVfCVubwr7).
A lot of the contents have been deciphered, but the more data we have, the easier it is to compare differences to learn what each byte represents and double-check our answers.
### Todos/Timeline/Next steps
- [ ] Tool for automatic trace analysis
- [ ] Web service for tag submisson with automatic anonymized data publishing to github
- [ ] Tag content analysis
- [ ] Generate keys based on an arbitrary UID
- [x] Tag content analysis
- [x] Generate keys based on an arbitrary UID
## Requirements
## Required Equipment
- Bambulab 3D Printer with AMS or AMS Lite
- Bambulab Filament spool **or** the related tags
- A Proxmark3-compatible RFID reader
- The [proxmark3 software](https://github.com/RfidResearchGroup/proxmark3)
- A computer running macOS or Linux, or a Windows computer with a WSL installation
- Python 3.6 or higher
- Bambu Lab Filament spool **or** the related tags
- An NFC/RFID reader that can read encrypted tags, such as...
- A Proxmark3-compatible RFID reader (recommended)
- The [proxmark3 (Iceman fork) software](https://github.com/RfidResearchGroup/proxmark3)
- Requires v4.18994 (codename "Backdoor") or higher
- You MUST use the Iceman fork as the original version of the software is unmaintained; all instructions and scripts are written for the Iceman fork and will not work on the original version
- A Flipper Zero
### Proxmark3 compatible readers
#### Proxmark3 Easy
![](images/Proxmark3_easy.png)
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.
## Hacking a Bambulab Tag and readout of its data
We document here the most simple approach to get all required A-Keys and the data of the tag.
The easiest way is to sniff the data.
## Hacking a Bambu Lab Tag and readout of its data
Update November 2024: In 2024 a new backdoor was found which requires no sniffing. Details can be found [here](https://eprint.iacr.org/2024/1275.pdf). Overall this makes it much easier get the keys and the tags data.
We document here the most simple approach to get all required A-Keys and the data of the tag. The easiest way is to derive the keys using the Python script in this repository.
### Deriving the keys
A way to derive the keys from the UID of an RFID tag was discovered, which unlocked the ability to scan and scrape RFID tag data without sniffing, as well as with other devices like the Flipper Zero. A script is included in the repository to derive the keys from the UID of a tag.
First, obtain the tag's UID:
- Proxmark3
1. Run the Proxmark3 software by running `pm3` in the terminal
2. Place the Proxmark3 device on the RFID tag of the spool
3. Run `hf mf info` and look for the UID line item
- Flipper Zero
1. Open the NFC app and scan the tag
2. The Flipper will attempt to decrypt the tag, but you can skip the "Nested Dictionary (Backdoor)" step for speed
3. The UID of the tag will appear on-screen
- Bambu Lab AMS
1. Load the spool into an AMS slot and wait for it to finish loading
2. View the spool's details on the printer's touchscreen, Bambu Studio or Bambu Handy
3. The UID is the first eight characters of the spool's serial number
Next, run the key derivation script and pipe its output to a file by running `python3 deriveKeys.py [UID] > ./keys.dic`.
Then, use the keys file to extract the data from the RFID tag:
- Proxmark3
1. Run the Proxmark3 software by running `pm3` in the terminal
2. Place the Proxmark3 device on the RFID tag of the spool
3. Run `hf mf dump -k ./keys.dic` to dump the RFID tag's contents
- Flipper Zero
1. Open the qFlipper program and connect your Flipper to your computer
- You may also connect the SD card directly to your computer
2. Navigate to `SD Card/nfc/assets/`
3. Copy the `mf_classic_dict_user.nfc` file to your computer
4. Copy the contents of `keys.dic` to `mf_classic_dict_user.nfc`
5. Copy `mf_classic_dict_user.nfc` back onto your Flipper
6. Use the NFC app to scan your tag
### Proxmark3 fm11rf08s recovery script
This script is included in proxmarx3 since its release "Backdoor" and later.
In 2024, a new backdoor[^rfid-backdoor] was found that makes it much easier to obtain the data from the RFID tags. A script is included in the proxmark3 software since v4.18994 (nicknamed "Backdoor"), which allows us to utilize this backdoor. Before this script was implemented, the tag had to be sniffed by placing the spool in the AMS and sniffing the packets transferred between the tag and the AMS.
Place your reader on the tag, start proxmark3 and run the following command.
Place your reader on the tag, start proxmark3 (run `pm3`) and run the following command:
`script run fm11rf08s_recovery`
This requires some time but once done you receive a binary key file and a dump.
This script takes about 15-20 minutes to complete. Once it has finished, you will receive a binary key file and a dump.
To visualize the data on the tag you can run now:
To visualize the data on the tag, run the following:
`script run fm11rf08_full -b`
### Bambulab AMS RFID reader location
The Bambulab AMS RFID readers are located between slots 1&2 and slots 3&4.
### Sniffing the tag data with a Proxmark3 (legacy method)
![](images/filament-slots.jpg)
Before the above methods were developed, tag data had to be obtained by sniffing the data between the RFID tag and the AMS using a Proxmark3-compatible device.
### Bambulab AMS Lite RFID reader location (legacy)
The Bambulab AMS Lite RFID readers are located at the base of each spool holder.
To read how to obtain the tag data using the legacy sniffing method, see the [TagSniffing.md](./TagSniffing.md).
For sniffing, you will need to place the Proxmark in between the RFID tag and the reader on the AMS. 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.
### Proxmark3 placement for sniffing (legacy)
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).
> [!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.
### Key Derivation ###
As of 11/19/24, keys can now be derived from the UID of a tag.
```python
from Cryptodome.Protocol.KDF import HKDF
from Cryptodome.Hash import SHA256
uid=bytes([0x02,0x3b,0x44,0x74])
master = bytes([0x9a,0x75,0x9c,0xf2,0xc4,0xf7,0xca,0xff,0x22,0x2c,0xb9,0x76,0x9b,0x41,0xbc,0x96])
keys=HKDF(uid, 6, master, SHA256, 16, context=b"RFID-A\0")
print([a.hex() for a in keys])
```
### Dump RFID Contents (.bin) (legacy)
1. **Run ProxMark3 Software**
In a terminal, run `pm3` to start the Proxmark3 Software
2. **Sniff Communication**
- Start sniffing with: `hf 14a sniff -c -r`<br>
(hf=High Frequency, 14a=Tag Type, Sniff=command, -c and -r mean "capture on triggers instead of continuously)
- Place your Proxmark3 between the tag and the AMS. Recommended: Use tape to hold it in place.
- Load a strand of filament into the AMS. This is what triggers the AMS to attempt to read the RFID tag.
- Press the button on the ProxMark to end capture after the filament has completed loading
3. **Extract the Keys**
1. **Automatic** (recommended)
1. Save the trace results to a file with: `trace save -f [FILENAME]`
2. Open a new terminal window and run the trace key extractor script in this repository with Python 3: `python3 traceKeyExtractor.py`
3. Input the trace results filepath or drag and drop it into the terminal window
4. After the keys are extracted, return to the Proxmark3 software
5. Remove the spool from the AMS and hold the Proxmark3 against the RFID tag of the spool
6. Run `hf mf fchk -f [dictionaryFilepath] --dump` to create a key file
- The program will report the destination of the key file that it saved. Copy this filepath to your clipboard.
- Example:
```
[+] Found keys have been dumped to /Users/mitch/hf-mf-75066B1D-key.bin
```
2. **Manual** (not recommended)
1. **Create a Key Dictionary**
- We will discover keys one at a time and save them to a dictionary file.
- Navigate to your Proxmark3 software installation directory. This will be specific to your Operating System and Installation.
- macOS (Intel) Example: `/usr/local/Cellar/proxmark3/4.17768/share/proxmark3/`
- macOS (ARM) Eample: `/opt/homebrew/Cellar/proxmark3/4.17768/share/proxmark3/`
- Windows Example: TBD
- Linux Example: TBD
- Open a text editor and save a blank file called `myDictionary.dic` into the `dictionaries/` folder of your Proxmark3 software installation directory.
(You can call this file anything you want, but for the rest of this example, we will refer to it as "myDictionary")
- Leave this file open, we will continue to add keys to it in the next step
2. **Extract Keys From Trace**
- Run `trace list -t mf -f myDictionary` to view the trace that was recorded from sniffing in the previous step.
This uses the key dictionary `myDictionary.dic` that we created in step 3.
- Read the output and look for anything that mentions a key.
- Three Possible Formats:
- `key E0B50731BE27 prng WEAK` - Follow Step 5
- `nested probable key: 50B0318A4FE7` - Follow Step 6
- `Nested authentication detected.` - Follow Step 7
- Each of these 3 entries can provide us with a valid key. Follow step 5, 6, or 7 depending on which type of key you encounter.
3. **First Key - Plain Text**
- Example: `key E0B50731BE27 prng WEAK`
- This is the first key that was discovered by sniffing AMS traffic.
- Copy/paste this key into the `myDictionary.dic` file that you created in step 3, then save the file.
4. **Nested Probable Key**
- Example: `nested probable key: 50B0318A4FE7`
- Copy/paste this key into the `myDictionary.dic` file that you created in step 3, then save the file.
5. **Nested Authentication Key**
- Example:
```
Nested authentication detected.
tools/mf_nonce_brute/mf_nonce_brute 75066b1d 4db2f2ac 0101 70fcdd3d 328eb1e6 1101 28b75cfd 0010 5196401C
```
- Open a second terminal window, and change directories into your Proxmark3 software installation directory. This is specific to your OS and PM3 installation.
- macOS/Linux: `cd $(brew --prefix proxmark3)/share/proxmark3/`
- Windows: TBD
- CD into the tools folder `cd tools/`
- Copy the command from ProxMark starting at `mf_nonce_brute`, including all the arguments (random letters/numbers) after it, and run the program from the `tools/` directory.
- Example (macOS/Linux): `./mf_nonce_brute 75066b1d 4db2f2ac 0101 70fcdd3d 328eb1e6 1101 28b75cfd 0010 5196401C`
- Example (Windows): `mf_nonce_brute.exe 75066b1d 4db2f2ac 0101 70fcdd3d 328eb1e6 1101 28b75cfd 0010 5196401C`
- The program will discover a key. Copy/paste this key into your `myDictionary.dic` file, and SAVE IT.
- Example Output:
```
Valid Key found [ 202efd3dcdfd ]
```
6. **Check Keys (Optional)**
- If you want to check how many valid keys you've discovered, you can do this test
- This is optional, and you can choose to wait until you have discovered all of the keys
- **WARNING**: Performing a key check will erase the trace that you recorded during step 2, and will require you to re-sniff data (repeat step 2)
- If you want to save your trace to avoid re-sniffing, use `trace save -f <trace-name>` and `trace load -f <trace-name>`
- Run `hf mf fchk --1k -f myDictionary` to test your keys
- Example Output (showing 11/16 keys discovered):
```
[+] found keys:
[+] -----+-----+--------------+---+--------------+----
[+] Sec | Blk | key A |res| key B |res
[+] -----+-----+--------------+---+--------------+----
[+] 000 | 003 | E0B50731BE27 | 1 | ------------ | 0
[+] 001 | 007 | 63654DB94D97 | 1 | ------------ | 0
[+] 002 | 011 | 387C06EFFDC8 | 1 | ------------ | 0
[+] 003 | 015 | 38963E577E43 | 1 | ------------ | 0
[+] 004 | 019 | 8A3EA2564692 | 1 | ------------ | 0
[+] 005 | 023 | 935E0F11857A | 1 | ------------ | 0
[+] 006 | 027 | EBC8F7D23A06 | 1 | ------------ | 0
[+] 007 | 031 | DD6128F13D4C | 1 | ------------ | 0
[+] 008 | 035 | ------------ | 0 | ------------ | 0
[+] 009 | 039 | 4E470B09521F | 1 | ------------ | 0
[+] 010 | 043 | 50EB8811A69C | 1 | ------------ | 0
[+] 011 | 047 | 4BDD25091824 | 1 | ------------ | 0
[+] 012 | 051 | ------------ | 0 | ------------ | 0
[+] 013 | 055 | ------------ | 0 | ------------ | 0
[+] 014 | 059 | ------------ | 0 | ------------ | 0
[+] 015 | 063 | ------------ | 0 | ------------ | 0
[+] -----+-----+--------------+---+--------------+----
[+] ( 0:Failed / 1:Success )
```
7. **Find Remaining Keys**
- Repeat step 4 until all 16 keys are discovered
- Your dictionary may be larger than 16 entries if you accidentally copied a duplicate key or an invalid key. These invalid entries are fine, and you can ignore them
- **Recommended**: When you think you have discovered all 16 keys, perform step 8 to verify that your keys are correct.
8. **Convert Dictionary to Key File**
- Remove the spool from the AMS and hold the Proxmark3 against the RFID tag of the spool
- Run `hf mf fchk --1k -f myDictionary --dump` to create a key file
- The program will report the destination of the key file that it saved. Copy this filepath to your clipboard
- Example:
```
[+] Found keys have been dumped to /Users/mitch/hf-mf-75066B1D-key.bin
```
4. **Dump RFID Contents**
- Run `hf mf dump -k [path-to-keyfile]` while the Proxmark3 is on the spool's RFID tag to dump the contents of the tag using the 16 keys we discovered
- There should be no errors
- The output should tell you where your `.bin` file is saved
- Example:
```
[+] saved 1024 bytes to binary file /Users/mitch/hf-mf-75066B1D-dump.bin
```
## Tag Documentation
This contains documentation for the known and unknown data that is contained in each block on the RFID tag.
For a description of the blocks of a Bambu Lab RFID tag, see [BambuLabRfid.md](./BambuLabRfid.md).
### Block Overview
For a description of the blocks of a Creality RFID tag, see [CrealityRfid.md](./CrealityRfid.md).
Summary of what kind of data is stored in each block. Detailed info for each block is documented below.
| sec | blk | Data |
|-----|-----|----------------------------------------------------------------------------------------|
| 0 | 0 | [Block 0](#block-0) UID and Tag Manufacturer Data |
| 0 | 1 | [Block 1](#block-1) Tray Info Index |
| 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, 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, Nozzle Diameter |
| 2 | 1 | [Block 9](#block-9) Tray UID |
| 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) 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) 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 |
| 5 | 0 | **Empty** |
| 5 | 1 | **Empty** |
| 5 | 2 | **Empty** |
| 5 | 3 | [Block 23](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab |
| 6 | 0 | **Empty** |
| 6 | 1 | **Empty** |
| 6 | 2 | **Empty** |
| 6 | 3 | [Block 27](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab |
| 7 | 0 | **Empty** |
| 7 | 1 | **Empty** |
| 7 | 2 | **Empty** |
| 7 | 3 | [Block 31](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab |
| 8 | 0 | **Empty** |
| 8 | 1 | **Empty** |
| 8 | 2 | **Empty** |
| 8 | 3 | [Block 35](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab |
| 9 | 0 | **Empty** |
| 9 | 1 | **Empty** |
| 9 | 2 | **Empty** |
| 9 | 3 | [Block 39](#mifare-encryption-keys) MIFARE encryption keys, Unrelated to BambuLab |
| 10-15 | \* | **RSA-2048 Signature** |
An open-source standard proposal, Open 3D-RFID, is being incubated in this repository. For a description of the standard, see [OpenSourceRfid.md](./OpenSourceRfid.md).
The first part of the filament serial number seems to be the Tag UID.
## How do RFID tags work?
> [!NOTE]
> All numbers are encoded as Little Endian (LE).
Here's a high-level summary of how everything works:
### MIFARE Encryption Keys
- Bambu Lab printers use MiFare 13.56MHZ RFID tags
- These tags contain a unique ID that is not encrypted (called the UID)
- In most cases UID is fixed (not-changable). Some "hackable" RFID tags allow you to set the UID to anything you want
- Blocks (Encrypted)
- MiFare tags also contain "Blocks" of data. Each block contains info about the spool, such as Material, Color, Manufacturing Date, etc.
- The blocks are encrypted, meaning that you need to have a KEY to decipher them
- Each block is encrypted with a different key
- Encryption Keys
- Keys are unique to each RFID tag. Even if you discover the key for one tag, that doesn't mean you can use that same key to unlock a different tag.
- As of 11/19/24, keys can be derived from the UID. After reading the UID from the tag, the KDF (key derivation function) can be used to derive the 16 keys.
- (Outdated, sniffing is no longer required now that the KDF is known) Keys can be sniffed by using a device (such as a ProxMark 3) to listen in on the communication between the AMS and the rfid tag.
- Once the keys have been sniffed, they can be saved and used to read the contents of the tag directly (without an AMS). (Reminder, the saved keys will ONLY work for the tag they were sniffed from)
- RSA Signature
- One of the blocks contains a 2048-bit RSA Signature
- RSA signatures are a way to digitally sign / certify authenticity of content, and they are effectively un-breakable (this is how things like cryptocurrency remain secure)
- RSA signatures encompass all of the data of the RFID tag. Changing a single byte somewhere else in the tag would require a completely different signature to be considered genuine
- Bambu printers check the content of the tag and then check if the signature is valid. If the signature is invalid, it rejects the tag
- Cloning Tags
- Even though there is a signature, a tag can be cloned
- To clone a tag, it must have the same UID, identical content from the data blocks, and the identical RSA signature
- Changing even one byte will cause the signature to be invalid, and the tag will be rejected
- Custom Tags
- This is very unlikely to happen, mostly due to the RSA signature. Only Bambu Lab has their "Private Key" which is used to digitally sign these tags.
- To create a custom key, you need to know the following info:
- RSA Signature Private Key. You'd have to get this from bambu, good luck
- Since Bambu Lab will likely not remove the signature requirement, you would need custom AMS firmware to read tags and ignore the signature
Every 4th block (eg Sector X, Block 3) contains encryption keys that are part of the MIFARE RFID standard.
This has nothing to do with BambuLab's memory format.
All BambuLab tags use the same Permission Bits (Access Control)
Example Data:
`AA AA AA AA AA AA PP PP PP PP BB BB BB BB BB BB`
| position | length | type | Description |
| -------- | ------ | ------- | ------------------------------------------------------------------------------ |
| 0 (AA) | 6 | RAW Bin | A-Key |
| 6 (PP) | 4 | RAW Bin | Permission Bits (Access Control)<br>ALWAYS `87 87 87 69` (hex) for Bambu Tags |
| 10 (BB) | 6 | RAW Bin | B-Key (always `00 00 00 00 00 00` for Bambu tags) |
### Block 0
Note: Block 0 is Read-only. The contents are set by the tag manufacturer.
Example Data:
`AA AA AA AA BB BB BB BB BB BB BB BB BB BB BB BB`
| position | length | type | Description |
| -------- | ------ | ------- | --------------------- |
| 0 (AA) | 4 | string | Tag UID |
| 4 (BB) | 12 | RAW Bin | Tag Manufacturer Data |
### Block 1
Example Data:
`AA AA AA AA AA AA AA AA BB BB BB BB BB BB BB BB`
| position | length | type | Description |
| -------- | ------ | ------ | --------------------------------------------- |
| 0 (AA) | 8 | string | Tray Info Index - Material Variant Identifier |
| 8 (BB) | 16 | string | Tray Info Index - Unique Material Identifier |
### Block 2
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | ------------- |
| 0 (AA) | 16 | string | Filament Type |
### Block 4
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | description |
| -------- | ------ | ------ | ---------------------- |
| 0 (AA) | 16 | string | Detailed Filament Type |
Known Values:
- PLA Basic
- PLA Matte
- PLA Silk
- PLA Galaxy
- PLA Sparkle
- Support for PLA (prev. Support W)
- PLA-CF (prev. PLA Tough)
- PETG Basic
### Block 5
Example Data:
`AA AA AA AA BB BB __ __ CC CC CC CC __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | -------------------------------------------- |
| 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 |
### Block 6
Example Data:
`AA AA BB BB CC CC DD DD EE EE FF FF __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | --------------------------------------- |
| 0 (AA) | 2 | uint16 (LE) | Drying Temperature in °C |
| 2 (BB) | 2 | uint16 (LE) | Drying time in hours |
| 4 (CC) | 2 | uint16 (LE) | Bed Temerature Type **(types unknown)** |
| 6 (DD) | 2 | uint16 (LE) | Bed Temperature in °C |
| 8 (EE) | 2 | uint16 (LE) | Max Temperature for Hotend in °C |
| 10 (FF) | 2 | uint16 (LE) | Min Temperature for Hotend in °C |
### Block 8
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA BB BB BB BB`
| position | length | type | description |
| -------- | ------ | ---------- | ----------------------- |
| 0 (AA) | 12 | RAW Bin | X Cam info |
| 12 (BB) | 4 | float (LE) | **Nozzle Diameter...?** |
### Block 9
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | ----------- |
| 0 (AA) | 16 | string | Tray UID |
### Block 10
Example Data:
`__ __ __ __ AA AA __ __ __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ------- | ------------------------- |
| 4 (AA) | 2 | uint16 (LE) | Spool Width in µm (`E1 19` --> 6625µm --> 66.25mm ) |
### Block 12
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | -------------------------------------------------------------------------- |
| 0 (AA) | 16 | string | Production Date and Time in ASCII (`<year>_<month>_<day>_<hour>_<minute>`) |
### Block 13
Example Data:
`AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA`
| position | length | type | Description |
| -------- | ------ | ------ | ---------------------------------- |
| 0 (AA) | 16 | string | **Short Production Date/Time...?** |
### Block 14
Example Data:
`__ __ __ __ AA AA __ __ __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | --------------------------------- |
| 4 (AA) | 2 | uint16 (LE) | **Filament length in meters...?** |
### Block 16
Example Data:
`AA AA BB BB CC CC CC CC __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | ---------------------------------- |
| 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:
`AA AA __ __ __ __ __ __ __ __ __ __ __ __ __ __`
| position | length | type | Description |
| -------- | ------ | ----------- | ---------------------------------- |
| 0 (AA) | 2 | **Unknown** | **Unknown** |
## Compatible RFID tags - By generation
## Compatible RFID tags - By generation
There are tags known as "Magic Tags" which allow functionality that's not part of the classic MIFARE spec.
One example is that most Magic Tags allow the UID to be changed, which is normally read-only on MIFARE tags.
Magic tags are often refered to by their "generation", eg "Magic Gen 1". Each newer generation increases the functionality, but tends to also be more expensive)
Magic tags are often refered to by their "generation", eg "Magic Gen 1". Each newer generation increases the functionality, but tends to also be more expensive)
Gen 1 --> **Not compatible**(due to AMS checking if tag is unlockable with command 0x40)
@@ -563,7 +192,6 @@ FUID --> **Works** "Fused UID" aka "write-once UID". Once a UID is written, it c
## Reverse engineering RFID Board
For ease of debugging and lowering the cost of failures the RFID board is reverse engineered. You can find complete production ready gerber files and bill of materials in rfid-board folder
For ease of debugging and lowering the cost of failures, the RFID board is reverse-engineered. You can find complete production-ready gerber files and a bill of materials in [rfid-board](./rfid-board) folder.
As a nice to benefit to have is that you can manufacture boards in different colors.
![](rfid-board/Photo_PCB_BBL-RFID.jpg)
[^rfid-backdoor]: https://eprint.iacr.org/2024/1275.pdf
+181
View File
@@ -0,0 +1,181 @@
# Sniffing the tag data
> [!NOTE]
> This document describes the legacy method for obtaining Bambu Lab RFID tag data. See the [Readme](./README.md#proxmark3-fm11rf08s-recovery-script) for instructions on the new method.
To obtain the data from an RFID tag on a Bambu Lab spool, the user used to have to sniff the data transferred between the tag and the AMS reader to obtain the encryption keys used to decrypt the tag data. This document explains how to sniff the data.
## Proxmark3 placement for sniffing
For sniffing, you will need to place the Proxmark in between the RFID tag and the reader on the AMS. 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.
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.
> [!TIP]
> Proxmark3 Easy users: 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.
### Bambu Lab AMS RFID Reader Location (for X1/P1 series)
The Bambu Lab AMS RFID readers are located between slots 1&2 and slots 3&4.
![](images/filament-slots.jpg)
It is recommended to place your Proxmark3 device 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).
### Bambu Lab AMS Lite RFID Reader Location (for A1 series)
The Bambu Lab AMS Lite RFID readers are located at the base of each spool holder.
You must place your Proxmark3 device between the reader and the spool.
## Dump RFID Contents (.bin)
1. **Run ProxMark3 Software**
In a terminal, run `pm3` to start the Proxmark3 Software
2. **Sniff Communication**
- Start sniffing with: `hf 14a sniff -c -r`<br>
(hf=High Frequency, 14a=Tag Type, Sniff=command, -c and -r mean "capture on triggers instead of continuously)
- Place your Proxmark3 between the tag and the AMS. Recommended: Use tape to hold it in place.
- Load a strand of filament into the AMS. This is what triggers the AMS to attempt to read the RFID tag.
- Press the button on the ProxMark to end capture after the filament has completed loading
3. **Obtain the Keys**
1. **Automatic** (recommended)
1. Save the trace results to a file with: `trace save -f [FILENAME]`
2. Open a new terminal window and run the trace key extractor script in this repository with Python 3: `python3 traceKeyExtractor.py`
3. Input the trace results filepath or drag and drop it into the terminal window
4. After the keys are extracted, return to the Proxmark3 software
5. Remove the spool from the AMS and hold the Proxmark3 against the RFID tag of the spool
6. Run `hf mf fchk -f [dictionaryFilepath] --dump` to create a key file
- The program will report the destination of the key file that it saved. Copy this filepath to your clipboard.
- Example:
```
[+] Found keys have been dumped to /Users/mitch/hf-mf-75066B1D-key.bin
```
2. **Manual** (not recommended)
1. **Create a Key Dictionary**
- We will discover keys one at a time and save them to a dictionary file.
- Navigate to your Proxmark3 software installation directory. This will be specific to your Operating System and Installation.
- macOS (via Homebrew) Example: `cd $(brew --prefix proxmark3)/share/proxmark3/`
- Linux Eample: `/usr/local/proxmark3/4.17768/share/proxmark3/`
- Windows Example: TBD
- Open a text editor and save a blank file called `myDictionary.dic` into the `dictionaries/` folder of your Proxmark3 software installation directory.
(You can call this file anything you want, but for the rest of this example, we will refer to it as "myDictionary")
- Leave this file open, we will continue to add keys to it in the next step
2. **Extract Keys From Trace**
- Run `trace list -t mf -f myDictionary` to view the trace that was recorded from sniffing in the previous step.
This uses the key dictionary `myDictionary.dic` that we created in step 3.
- Read the output and look for anything that mentions a key.
- Three Possible Formats:
- `key E0B50731BE27 prng WEAK` - Follow Step 5
- `nested probable key: 50B0318A4FE7` - Follow Step 6
- `Nested authentication detected.` - Follow Step 7
- Each of these 3 entries can provide us with a valid key. Follow step 5, 6, or 7 depending on which type of key you encounter.
3. **First Key - Plain Text**
- Example: `key E0B50731BE27 prng WEAK`
- This is the first key that was discovered by sniffing AMS traffic.
- Copy/paste this key into the `myDictionary.dic` file that you created in step 3, then save the file.
4. **Nested Probable Key**
- Example: `nested probable key: 50B0318A4FE7`
- Copy/paste this key into the `myDictionary.dic` file that you created in step 3, then save the file.
5. **Nested Authentication Key**
- Example:
```
Nested authentication detected.
tools/mf_nonce_brute/mf_nonce_brute 75066b1d 4db2f2ac 0101 70fcdd3d 328eb1e6 1101 28b75cfd 0010 5196401C
```
- Open a second terminal window, ensuring you are still in the Proxmark3 installation directory.
- CD into the tools folder `cd tools/`
- Copy the command from ProxMark starting at `mf_nonce_brute`, including all the arguments (random letters/numbers) after it, and run the program from the `tools/` directory.
- Example (macOS/Linux): `./mf_nonce_brute 75066b1d 4db2f2ac 0101 70fcdd3d 328eb1e6 1101 28b75cfd 0010 5196401C`
- Example (Windows): `mf_nonce_brute.exe 75066b1d 4db2f2ac 0101 70fcdd3d 328eb1e6 1101 28b75cfd 0010 5196401C`
- The program will discover a key. Copy/paste this key into your `myDictionary.dic` file, and SAVE IT.
- Example Output:
```
Valid Key found [ 202efd3dcdfd ]
```
6. **Check Keys (Optional)**
- If you want to check how many valid keys you've discovered, you can do this test
- This is optional, and you can choose to wait until you have discovered all of the keys
- **WARNING**: Performing a key check will erase the trace that you recorded during step 2, and will require you to re-sniff data (repeat step 2)
- If you want to save your trace to avoid re-sniffing, use `trace save -f <trace-name>` and `trace load -f <trace-name>`
- Run `hf mf fchk --1k -f myDictionary` to test your keys
- Example Output (showing 11/16 keys discovered):
```
[+] found keys:
[+] -----+-----+--------------+---+--------------+----
[+] Sec | Blk | key A |res| key B |res
[+] -----+-----+--------------+---+--------------+----
[+] 000 | 003 | E0B50731BE27 | 1 | ------------ | 0
[+] 001 | 007 | 63654DB94D97 | 1 | ------------ | 0
[+] 002 | 011 | 387C06EFFDC8 | 1 | ------------ | 0
[+] 003 | 015 | 38963E577E43 | 1 | ------------ | 0
[+] 004 | 019 | 8A3EA2564692 | 1 | ------------ | 0
[+] 005 | 023 | 935E0F11857A | 1 | ------------ | 0
[+] 006 | 027 | EBC8F7D23A06 | 1 | ------------ | 0
[+] 007 | 031 | DD6128F13D4C | 1 | ------------ | 0
[+] 008 | 035 | ------------ | 0 | ------------ | 0
[+] 009 | 039 | 4E470B09521F | 1 | ------------ | 0
[+] 010 | 043 | 50EB8811A69C | 1 | ------------ | 0
[+] 011 | 047 | 4BDD25091824 | 1 | ------------ | 0
[+] 012 | 051 | ------------ | 0 | ------------ | 0
[+] 013 | 055 | ------------ | 0 | ------------ | 0
[+] 014 | 059 | ------------ | 0 | ------------ | 0
[+] 015 | 063 | ------------ | 0 | ------------ | 0
[+] -----+-----+--------------+---+--------------+----
[+] ( 0:Failed / 1:Success )
```
7. **Find Remaining Keys**
- Repeat step 4 until all 16 keys are discovered
- Your dictionary may be larger than 16 entries if you accidentally copied a duplicate key or an invalid key. These invalid entries are fine, and you can ignore them
- **Recommended**: When you think you have discovered all 16 keys, perform step 8 to verify that your keys are correct.
8. **Convert Dictionary to Key File**
- Remove the spool from the AMS and hold the Proxmark3 against the RFID tag of the spool
- Run `hf mf fchk --1k -f myDictionary --dump` to create a key file
- The program will report the destination of the key file that it saved. Copy this filepath to your clipboard
- Example:
```
[+] Found keys have been dumped to /current/directory/hf-mf-75066B1D-key.bin
```
4. **Dump RFID Contents**
- Run `hf mf dump -k [path-to-keyfile]` while the Proxmark3 is on the spool's RFID tag to dump the contents of the tag using the 16 keys we discovered
- There should be no errors
- The output should tell you where your `.bin` file is saved
- Example:
```
[+] saved 1024 bytes to binary file /current/directory/hf-mf-75066B1D-dump.bin
```
+24
View File
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Python script to generate keys for Bambu Lab RFID tags
# Created for https://github.com/Bambu-Research-Group/RFID-Tag-Guide
# Written by thekakester (https://github.com/thekakester) and Vinyl Da.i'gyu-Kazotetsu (www.queengoob.org), 2024
import sys
from Cryptodome.Protocol.KDF import HKDF
from Cryptodome.Hash import SHA256
if not sys.version_info >= (3, 6):
print("Python 3.6 or higher is required!")
exit(-1)
def kdf(uid):
master = bytes([0x9a,0x75,0x9c,0xf2,0xc4,0xf7,0xca,0xff,0x22,0x2c,0xb9,0x76,0x9b,0x41,0xbc,0x96])
return HKDF(uid, 6, master, SHA256, 16, context=b"RFID-A\0")
if __name__ == '__main__':
uid = bytes.fromhex(sys.argv[1])
keys = kdf(uid)
output = [a.hex().upper() for a in keys]
print("\n".join(output))
+24
View File
@@ -6,6 +6,7 @@
import sys
import struct
import re
from datetime import datetime
from pathlib import Path
@@ -47,6 +48,26 @@ def bytes_to_date(data):
minute=int(parts[4])
)
# Flipper Helper
def strip_flipper_data(string):
# Remove comments
pattern = re.compile(r"^[\w\s]+: [\w\s\d?]+$", re.M)
data = dict([x.split(": ") for x in pattern.findall(string.decode())])
# Ensure the scan file is for the proper type of tag
assert(data.get("Version") == "4")
assert(data.get("Data format version") == "2")
assert(data.get("Device type") == "Mifare Classic")
assert(data.get("Mifare Classic type") == "1K")
output = b""
for key in data:
if key.startswith("Block "):
output += bytes.fromhex(data[key].replace("??", "00"))
return output
# Classes
class TagLengthMismatchError(TypeError):
@@ -110,6 +131,9 @@ class ColorList(list):
class Tag():
def __init__(self, filename, data):
# Check to make sure the data is 1KB or a known alternative
if data.startswith(b"Filetype: Flipper NFC"):
# Flipper NFC dump
data = strip_flipper_data(data)
if len(data) not in TOTAL_BYTES:
raise TagLengthMismatchError(len(data))
+52 -57
View File
@@ -8,10 +8,6 @@ if not sys.version_info >= (3, 6):
print("Python 3.6 or higher is required!")
exit(-1)
# List of possible directories for Proxmark3 to try
# XXX Populate with results for Windows
pm3_dirs = []
#Global variables
#Default name of the dictionary file we create
dictionaryFilename = "myKeyDictionary.dic" #Arbitrary filename for storing dictionary file
@@ -22,45 +18,51 @@ pm3Location = None #Calculated. The location of Proxm
pm3Command = "bin/pm3" # The command that works to start proxmark3
mfNonceBruteCommand = "share/proxmark3/tools/mf_nonce_brute" # The command to execute mfNonceBrute
trace = ""; #Prompted during runtime. Trace filename that the user provides
def main():
global pm3Location,dictionaryFilepath,trace
print("--------------------------------------------------------")
print("RFID Key Extractor v0.2 - Bambu Research Group 2024")
print("--------------------------------------------------------")
print("This will extract the keys from a trace file")
print("that was saved from sniffing communication between")
print("the AMS and RFID tag.")
print("");
print("Instructions to sniff and save the trace can be found at")
print("https://github.com/Bambu-Research-Group/RFID-Tag-Guide");
print("--------------------------------------------------------")
print("")
def setup():
global pm3Location,dictionaryFilepath
pm3Location = get_proxmark3_location()
#Create a dictionary file to store keys that we discover
print(f"Creating dictionary file '{dictionaryFilename}'")
dictionaryFile = open(dictionaryFilename, "w")
dictionaryFile.close();
dictionaryFile.close()
dictionaryFilepath = os.path.abspath(dictionaryFilename)
print(f"Saved dictionary to {dictionaryFilepath}")
#Instruct the user to create a trace file
print()
print("Start by creating a trace file. In the proxmark terminal, execute command `hf 14a sniff -c -r`.")
print("Then, place the Proxmark3 between the RFID reader and spool.")
print("Load in filament and wait for the process to complete, then press the button on the Proxmark3.")
print("Finally, in the proxmark terminal, execute command `trace save -f [FILEPATH]` to create the trace file.")
print("See the GitHub repository for more details.")
print()
def main():
print("--------------------------------------------------------")
print("RFID Key Extractor v0.2.1 - Bambu Research Group 2024")
print("--------------------------------------------------------")
print("This will extract the keys from a trace file")
print("that was saved from sniffing communication between")
print("the AMS and RFID tag.")
print("")
print("Instructions to sniff and save the trace can be found at")
print("https://github.com/Bambu-Research-Group/RFID-Tag-Guide")
print("--------------------------------------------------------")
print("")
#Get the tracename/filepath from user
trace = input("Enter trace name or full trace filepath: ")
# Run setup
setup()
discoverKeys()
if len(sys.argv) > 1:
# If the user included an argument, assume it's the path to the tracefile
trace = os.path.abspath(sys.argv[1])
else:
#Instruct the user to create a trace file
print()
print("Start by creating a trace file. In the proxmark terminal, execute command `hf 14a sniff -c -r`.")
print("Then, place the Proxmark3 between the RFID reader and spool.")
print("Load in filament and wait for the process to complete, then press the button on the Proxmark3.")
print("Finally, in the proxmark terminal, execute command `trace save -f [FILEPATH]` to create the trace file.")
print("See the GitHub repository for more details.")
print()
#Get the tracename/filepath from user
trace = input("Enter trace name or full trace filepath: ")
discoverKeys(trace)
print("Keys obtained. Remove the spool from the AMS and place the Proxmark3 on the spool's tag.")
print(f"In proxmark terminal, execute command `hf mf fchk -f {dictionaryFilepath} --dump` to create a keyfile from this dictionary.")
@@ -68,26 +70,26 @@ def main():
#Loop 16 times to attempt to extract all 16 keys from the tracefile
def discoverKeys():
def discoverKeys(traceFilepath):
print("PROGRAM: ", mfNonceBruteCommand)
keyList = [];
keyList = []
# Run a max of 16 times.
for i in range(16):
loopNum = i+1;
loopNum = i+1
print("----------------------")
print(f"Loop {loopNum} of 16")
#Run PM3 with the trace
# -o means run without connecting to PM3 hardware
# -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"];
cmd_list = [pm3Location / pm3Command,"-o","-c", f"trace load -f {traceFilepath}; trace list -1 -t mf -f {dictionaryFilepath}; exit"]
print(f"Viewing tracelog with {len(keyList)} discovered keys")
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;
output = result.stdout
@@ -111,20 +113,20 @@ def discoverKeys():
print("Found line containing a key:")
print(f" {line}")
# split the line into "words", which are whitespace separated
words = line.split(" ");
words = line.split(" ")
key = ""
#find the word "key", and then grab the word directly after it
for j in range(len(words)-1):
w = words[j];
w = words[j]
if w == "key" or w == "key:":
key = words[j+1]; #Guaranteed to not be out of bounds because we loop to words length - 1
key = words[j+1] #Guaranteed to not be out of bounds because we loop to words length - 1
break
#If we didn't find a key, skip this line
if key == "":
continue;
continue
#If key ends with a vertical bar |, remove it
key = key.replace('|', '')
@@ -133,7 +135,7 @@ def discoverKeys():
#Add this key to our keylist if it's new
if key in keyList:
print(f" Duplicate key, ignoring: {key}")
continue;
continue
keyList.append(key)
print(f" Found new key: {key}")
@@ -151,7 +153,7 @@ def discoverKeys():
if "mf_nonce_brute" in words[j]:
#Add the rest of the line to our arguments
args = words[j+1:] #can't be out of bounds because we loop to len(words)-1
break;
break
key = bruteForce(args)
@@ -159,14 +161,14 @@ def discoverKeys():
key = strip_color_codes(key)
if key == "":
continue;
continue
key = key.upper()
#Add this key to our keylist if it's new
if key in keyList:
print(f" Duplicate key, ignoring: {key}")
continue;
continue
keyList.append(key)
print(f" Found new key: {key}")
@@ -179,9 +181,9 @@ def discoverKeys():
for j in range(len(keyList)):
print(f" {j}: {keyList[j]}")
dictionaryFile.write(keyList[j])
dictionaryFile.write("\n");
dictionaryFile.write("\n")
print()
dictionaryFile.close();
dictionaryFile.close()
#Done! Show results
print(f"{len(keyList)} keys saved to file: {dictionaryFilepath}")
@@ -208,7 +210,7 @@ def bruteForce(args):
print(f" {line}")
#Parse out the key from within the brackets
words = line.split(" ");
words = line.split(" ")
for i in range(len(words)-1):
if words[i] == "[":
return words[i+1]
@@ -248,12 +250,6 @@ def get_proxmark3_location():
print(f"Found global installation ({pm3_location})!")
return pm3_location
# Check pm3_dirs paths
pm3_dirs_result = testCommands(pm3_dirs, "bin/pm3", "--help")
if pm3_dirs_result:
print(f"Found installation in {pm3_dirs_result}!")
return pm3_dirs_result
# At this point, we've tried all the paths to find it
print("Failed to find working 'pm3' command. You can set the Proxmark3 directory via the 'PROXMARK3_DIR' environment variable.")
exit(-1) # Halt program
@@ -294,6 +290,5 @@ def testCommands(directories, command, arguments = ""):
return None #We didn't find any program that worked
main(); #Run main program
if __name__ == "__main__":
main() #Run main program