Merge branch 'main' into mf_nonce_brute-fix
This commit is contained in:
14 files changed
+14539
-222
No files matched your search
@@ -0,0 +1 @@
|
||||
*.dic
|
||||
+14
-5
@@ -19,7 +19,15 @@ We want to make a standard that is simple to implement and as future-proof as po
|
||||
|
||||
# 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.
|
||||
* [Polar Filament](https://polarfilament.com)
|
||||
* 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/)
|
||||
* 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?
|
||||
@@ -37,9 +45,10 @@ What is the benefit of adding RFID chips to filament?
|
||||
# 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 RC522 (as low as $1). This module communicates over SPI.
|
||||
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/RC522-Reader.jpg" width=200>
|
||||
<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.
|
||||
|
||||
@@ -120,7 +129,7 @@ This is additional data that not all manufacturers will implement. These fields
|
||||
|-------------|---------------|------------|----|-----|
|
||||
| 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).
|
||||
| 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)
|
||||
@@ -134,4 +143,4 @@ This is additional data that not all manufacturers will implement. These fields
|
||||
|
||||
|
||||
## Memory Map
|
||||
A list of where each datapoint lives in memory, sorted into sectors and blocks. This will be generated after the [Data Points](#data-points) section has been mostly finalized.
|
||||
A list of where each datapoint lives in memory, sorted into sectors and blocks. This will be generated after the [Data Points](#data-points) section has been mostly finalized.
|
||||
@@ -15,10 +15,12 @@ We are currently working on a way to submit the tag data in a secure way so anal
|
||||
* [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)
|
||||
* [Proxmark3 fm11rf08s recovery script](#proxmark3-fm11rf08s-recovery-script)
|
||||
* [Bambulab AMS RFID reader location](#bambulab-ams-rfid-reader-location)
|
||||
* [Bambulab AMS Lite RFID reader location](#bambulab-ams-lite-rfid-reader-location)
|
||||
* [Proxmark3 placement for sniffing](#proxmark3-placement-for-sniffing)
|
||||
* [Dump RFID Contents (.bin)](#dump-rfid-contents-bin)
|
||||
* [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)
|
||||
* [Tag Documentation](#tag-documentation)
|
||||
* [Block Overview](#block-overview)
|
||||
* [MIFARE Encryption Keys](#mifare-encryption-keys)
|
||||
@@ -34,7 +36,10 @@ 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)
|
||||
* [Block 17](#block-17)
|
||||
* [Compatible RFID tags - By generation](#compatible-rfid-tags----by-generation)
|
||||
* [Reverse engineering RFID Board](#reverse-engineering-rfid-board)
|
||||
<!--te-->
|
||||
|
||||
## Project Summary
|
||||
@@ -62,8 +67,8 @@ Here's a high-level summary of how everything works:
|
||||
* 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.
|
||||
* Keys are likely derived from the UID. The UID goes through an algorithm (known only by Bambu) to reveal a set of keys for each block
|
||||
* 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.
|
||||
* 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
|
||||
@@ -77,7 +82,6 @@ Here's a high-level summary of how everything works:
|
||||
* 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:
|
||||
* UUID -> Encryption Key algorithm (or just use known UID + Key pairs)
|
||||
* 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
|
||||
|
||||
@@ -108,29 +112,62 @@ 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.
|
||||
|
||||
## 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.
|
||||
The easiest way is to sniff the 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.
|
||||
|
||||
### Proxmark3 fm11rf08s recovery script
|
||||
|
||||
This script is included in proxmarx3 since its release "Backdoor" and later.
|
||||
|
||||
Place your reader on the tag, start proxmark3 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.
|
||||
|
||||
To visualize the data on the tag you can run now:
|
||||
|
||||
`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.
|
||||
|
||||

|
||||
|
||||
### Bambulab AMS Lite RFID reader location
|
||||
### Bambulab AMS Lite RFID reader location (legacy)
|
||||
The Bambulab AMS Lite RFID readers are located at the base of each spool holder.
|
||||
|
||||
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
|
||||
### Proxmark3 placement for sniffing (legacy)
|
||||
|
||||
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.
|
||||
|
||||
### Dump RFID Contents (.bin)
|
||||
### 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**
|
||||
|
||||
@@ -145,104 +182,135 @@ If you place the Proxmark in between the AMS reader and the spool, make sure tha
|
||||
- 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. **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.
|
||||
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**
|
||||
|
||||
(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
|
||||
|
||||
4. **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.
|
||||
|
||||
5. **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.
|
||||
6. **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.
|
||||
7. **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 ]
|
||||
```
|
||||
8. **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 )
|
||||
```
|
||||
|
||||
9. **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.
|
||||
|
||||
10. **Convert Dictionary to Key File**
|
||||
- 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
|
||||
```
|
||||
11. **Dump RFID Contents**
|
||||
- Run `hf mf dump -k [path-to-keyfile]` to dump the contents of the tag using the 16 keys we discovered
|
||||
- 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:
|
||||
@@ -263,19 +331,19 @@ 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 | **Empty** |
|
||||
| 4 | 1 | **Empty** |
|
||||
| 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** |
|
||||
@@ -363,9 +431,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
|
||||
@@ -375,7 +446,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 |
|
||||
|
||||
@@ -388,10 +459,10 @@ 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 |
|
||||
| 8 (EE) | 2 | uint16 (LE) | Max Temperature for Hotend in °C |
|
||||
| 10 (FF) | 2 | uint16 (LE) | Min Temperature for Hotend in °C |
|
||||
|
||||
### Block 8
|
||||
|
||||
@@ -448,8 +519,36 @@ Example Data:
|
||||
| -------- | ------ | ----------- | --------------------------------- |
|
||||
| 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
|
||||
|
||||
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)
|
||||
|
||||
Gen 1 --> **Not compatible**(due to AMS checking if tag is unlockable with command 0x40)
|
||||
|
||||
Gen 2 --> **Works**
|
||||
@@ -459,3 +558,12 @@ Gen 2 OTW --> **Not tested**
|
||||
Gen 3 --> **Not tested**
|
||||
|
||||
Gen 4 --> **Not tested**(The best option but pricey and hard to source in small chip formfactor)
|
||||
|
||||
FUID --> **Works** "Fused UID" aka "write-once UID". Once a UID is written, it cannot be changed
|
||||
|
||||
## 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
|
||||
|
||||
As a nice to benefit to have is that you can manufacture boards in different colors.
|
||||

|
||||
Binary file not shown.
|
After Width: | Height: | Size: 546 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
@@ -7,13 +7,18 @@
|
||||
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
|
||||
|
||||
BYTES_PER_BLOCK = 16
|
||||
BLOCKS_PER_TAG = 64
|
||||
TOTAL_BYTES = BLOCKS_PER_TAG * BYTES_PER_BLOCK
|
||||
BLOCKS_PER_TAG = [64, 72] # 64 = 1KB, 72 = Output from Proxmark fm11rf08 script
|
||||
TOTAL_BYTES = [blocks * BYTES_PER_BLOCK for blocks in BLOCKS_PER_TAG]
|
||||
|
||||
# Byte conversions
|
||||
def bytes_to_string(data):
|
||||
@@ -21,7 +26,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')
|
||||
@@ -77,26 +82,56 @@ 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
|
||||
if len(data) != TOTAL_BYTES:
|
||||
# Check to make sure the data is 1KB or a known alternative
|
||||
if len(data) not in TOTAL_BYTES:
|
||||
raise TagLengthMismatchError(len(data))
|
||||
|
||||
# Store the raw data
|
||||
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
|
||||
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]) 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"),
|
||||
@@ -116,11 +151,33 @@ class Tag():
|
||||
"x_cam_info": self.blocks[8][0:12],
|
||||
"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[17][0:2], # Only been "0100" on the PLA Silk Dual Color, "0000" otherwise
|
||||
}
|
||||
|
||||
# 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])
|
||||
|
||||
# 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)],
|
||||
17: range(2,16)
|
||||
}
|
||||
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))
|
||||
|
||||
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 +189,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):
|
||||
@@ -157,11 +219,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
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
After Width: | Height: | Size: 127 KiB |
+88
-81
@@ -1,41 +1,16 @@
|
||||
#########################
|
||||
# CONFIGURATION (Begin) #
|
||||
#########################
|
||||
# Change these variables to match the install locations for your specific computer
|
||||
# Some examples are provided, and you can comment/uncomment specific lines, or
|
||||
# manually type them in if your computer differs from the examples
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# -----------
|
||||
# PM3 Program
|
||||
# -----------
|
||||
#The main proxmark program, for most installations, proxmark3 can be started
|
||||
# with the command "pm3" in the terminal.
|
||||
# If your computer doesn't recognize this, you may need to navigate to the actual
|
||||
# installation directory
|
||||
|
||||
#List of possible commands to try
|
||||
pm3 = [
|
||||
#"pm3", #Default installation location
|
||||
"/usr/local/opt/proxmark3/bin/pm3", #MAC Installataion - using BREW
|
||||
"" #Windows specific install location TBD
|
||||
]
|
||||
|
||||
# ---------------------------------
|
||||
# Brute Force Tool (mf_nonce_brute)
|
||||
# ---------------------------------
|
||||
# This is a tool that comes with the PM3 program
|
||||
# It is located in the "tools" directory of your PM3 installation location
|
||||
mfNonceBrute = [
|
||||
"/usr/local/opt/proxmark3/share/proxmark3/tools/mf_nonce_brute", #MAC Install, using Brew
|
||||
"" #Windows TBD
|
||||
]
|
||||
|
||||
|
||||
#########################
|
||||
# CONFIGURATION (End) #
|
||||
#########################
|
||||
# Do not modify anything beyond this point, unless you're a developer
|
||||
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
|
||||
@@ -43,17 +18,14 @@ dictionaryFilename = "myKeyDictionary.dic" #Arbitrary filename for storing dict
|
||||
dictionaryFilepath = "" #Calculated. Absolute path to dictionary file
|
||||
dictionaryFile = "" #File object for writing keys
|
||||
|
||||
pm3Command = ""; #Calculated. The command that works to start proxmark3
|
||||
mfNonceBruteCommand = "" #Calculated. The command to execute mfNonceBrute
|
||||
pm3Location = None #Calculated. The location of Proxmark3
|
||||
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
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
|
||||
def main():
|
||||
global pm3Command, mfNonceBruteCommand,dictionaryFilepath,trace
|
||||
global pm3Location,dictionaryFilepath,trace
|
||||
|
||||
print("--------------------------------------------------------")
|
||||
print("RFID Key Extractor v0.1 - Bambu Research Group 2024")
|
||||
@@ -67,19 +39,7 @@ def main():
|
||||
print("--------------------------------------------------------")
|
||||
print("")
|
||||
|
||||
# Find a "pm3" command that works from a list of OS-specific possibilities
|
||||
print("Checking program: pm3")
|
||||
pm3Command = testCommands(pm3,"--help"); #Execute "pm3 --help" to test if the install location works
|
||||
if pm3Command is None:
|
||||
print("Failed to find working PM3 command. Modify the \"pm3\" variable in this program to match your installation location")
|
||||
return; #Halt program
|
||||
|
||||
# Find a "mf_nonce_brute" command that works from a list of OS-specific possibilities
|
||||
print("Checking program: mf_nonce_brute")
|
||||
mfNonceBruteCommand = testCommands(mfNonceBrute,""); #Execute "mf_nonce_brute" to test if the install location works
|
||||
if mfNonceBruteCommand is None:
|
||||
print("Failed to find working mf_nonce_brute command. Modify the \"mf_nonce_brute\" variable in this program to match your installation location")
|
||||
return; #Halt program
|
||||
pm3Location = get_proxmark3_location()
|
||||
|
||||
#Create a dictionary file to store keys that we discover
|
||||
print(f"Creating dictionary file '{dictionaryFilename}'")
|
||||
@@ -88,16 +48,23 @@ def main():
|
||||
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()
|
||||
|
||||
#Get the tracename/filepath from user
|
||||
print("");
|
||||
trace = input("Enter trace name or full trace filepath: ")
|
||||
|
||||
discoverKeys();
|
||||
discoverKeys()
|
||||
|
||||
print(f"In proxmark terminal, execute command `hf mf fchk -f {dictionaryFilepath} --dump`")
|
||||
print(" to create a keyfile from this dictionary")
|
||||
print()
|
||||
print("Then execute `hf mf dump` to dump the contents of the RFID tag")
|
||||
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.")
|
||||
print("Then, execute `hf mf dump` to dump the contents of the RFID tag.")
|
||||
|
||||
|
||||
#Loop 16 times to attempt to extract all 16 keys from the tracefile
|
||||
@@ -116,9 +83,9 @@ def discoverKeys():
|
||||
#Run PM3 with the trace
|
||||
# -o means run without connecting to PM3 hardware
|
||||
# -c specifies commands within proxmark 3 software
|
||||
cmd_list = [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 {trace}; trace list -1 -t mf -f {dictionaryFilepath}; exit"];
|
||||
print(f"Viewing tracelog with {len(keyList)} discovered keys")
|
||||
print(" ".join(cmd_list))
|
||||
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;
|
||||
|
||||
@@ -222,10 +189,10 @@ def discoverKeys():
|
||||
#Run the mf_nonce_brute program with the provided arguments to decode a key
|
||||
#Returns a key on success, "" otherwise
|
||||
def bruteForce(args):
|
||||
cmd_list = [mfNonceBruteCommand] + args
|
||||
cmd_list = [pm3Location / mfNonceBruteCommand] + args
|
||||
print(" Running bruteforce command:")
|
||||
print(" ",end = "")
|
||||
print(" ".join(cmd_list))
|
||||
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
|
||||
@@ -256,6 +223,52 @@ def strip_color_codes(input_string):
|
||||
# Use the sub method to replace the escape sequences with an empty string
|
||||
return ansi_escape.sub('', input_string)
|
||||
|
||||
def get_proxmark3_location():
|
||||
# Find a "pm3" command that works from a list of OS-specific possibilities
|
||||
print("Checking program: pm3")
|
||||
|
||||
# Check PROXMARK3_DIR environment variable
|
||||
if os.environ.get('PROXMARK3_DIR'):
|
||||
if run_command(os.environ['PROXMARK3_DIR'] + "/bin/pm3", "--help"):
|
||||
return os.environ['PROXMARK3_DIR']
|
||||
else:
|
||||
print("Warning: PROXMARK3_DIR environment variable points to the wrong folder, ignoring")
|
||||
|
||||
# Get Homebrew installation
|
||||
brew_install = run_command(["brew", "--prefix", "proxmark3"])
|
||||
if brew_install:
|
||||
print("Found installation via Homebrew!")
|
||||
return Path(brew_install)
|
||||
|
||||
# Get global installation
|
||||
which_pm3 = run_command(["which", "pm3"])
|
||||
if which_pm3:
|
||||
which_pm3 = Path(which_pm3)
|
||||
pm3_location = which_pm3.parent.parent
|
||||
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
|
||||
|
||||
def run_command(command):
|
||||
try:
|
||||
# On Windows, use the shell=True argument to run the command
|
||||
result = subprocess.run(command, shell=os.name == 'nt', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
# Check the return code to determine if the command was successful
|
||||
if result.returncode == 0 or result.returncode == 1:
|
||||
return result.stdout.decode("utf-8").strip()
|
||||
return None
|
||||
except Exception as e:
|
||||
return None
|
||||
|
||||
# Test a list of commands to see which one works
|
||||
# This lets us provide a list of OS-specific commands, test them
|
||||
# and figure out which one works on this specific computer
|
||||
@@ -264,26 +277,20 @@ def strip_color_codes(input_string):
|
||||
# - arguments: Optional arguments to be appended to the command. Useful for programs that don't exit on their own
|
||||
# This returns the command (string) of the first working command we encounter
|
||||
#
|
||||
def testCommands(commandList, arguments = ""):
|
||||
def testCommands(directories, command, arguments = ""):
|
||||
|
||||
for command in commandList:
|
||||
for directory in directories:
|
||||
|
||||
if directory is None:
|
||||
continue
|
||||
|
||||
#OPTIONAL: add arguments such as "--help" to help identify programs that don't exit on their own
|
||||
cmd_list = [command, arguments]
|
||||
cmd_list = [directory+"/"+command, arguments]
|
||||
|
||||
#Test if this program works
|
||||
print(" Trying:", command, end=" ... ")
|
||||
try:
|
||||
# On Windows, use the shell=True argument to run the command
|
||||
result = subprocess.run(cmd_list, shell=os.name == 'nt', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
# Check the return code to determine if the command was successful
|
||||
if result.returncode == 0 or result.returncode == 1:
|
||||
print(" SUCCESS!")
|
||||
return command
|
||||
except Exception as e:
|
||||
#print(e) #DEBUG
|
||||
print(" FAIL");
|
||||
continue
|
||||
print(" Trying:", directory, end=" ... ")
|
||||
if run_command(cmd_list):
|
||||
return Path(directory)
|
||||
|
||||
return None #We didn't find any program that worked
|
||||
|
||||
|
||||
Reference in new issue
Block a user