Skip to content

Add macOS support for nonce extraction and key loading#27

Open
tomholford wants to merge 6 commits into
equipter:mainfrom
tomholford:feat/macos-flipper-mfkey-support
Open

Add macOS support for nonce extraction and key loading#27
tomholford wants to merge 6 commits into
equipter:mainfrom
tomholford:feat/macos-flipper-mfkey-support

Conversation

@tomholford

@tomholford tomholford commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Adds first-class macOS support to the Flipper Zero CLI workflow for collecting nonces with "Detect Reader" and recovering MIFARE Classic keys with mfkey32v2, then safely loading them into the device user dictionary.

Previously the Python extractor was Linux-only for serial port detection, had no automatic backup before overwriting the user dictionary, and documentation assumed Linux paths and commands. macOS users had to manually discover ports and risked losing their existing key dictionary.

Changes

  • mfkey_extract.py: Replace Linux-only detectFlipperLinux with _detect_flipper_port supporting macOS (/dev/cu.usbmodem*, preferring names containing "flip"), Linux, and basic POSIX fallbacks. Updated connection logic, --detect mode, error messages, and argparse description.
  • Safer dictionary handling: In the --cli full-auto path, explicitly create a .bkp copy of mf_classic_dict_user.nfc on the device before removing and rewriting the merged set of keys.
  • New Docs/macOS.md: Dedicated guide covering brew requirements, port discovery with ls /dev/cu.*, pyserial install, qFlipper hidden files, web/lab.flipper.net fallback, the critical device paths (/ext/nfc/.mfkey32.log and /ext/nfc/assets/mf_classic_dict_user.nfc), cache clearing, and post-load steps.
  • Convenience tooling: Added executable flipper-crack wrapper script and make flipper-crack target that handles build + pyserial + runs --cli.
  • Docs/Flippercli.md: Added pointer to the new macOS guide.
  • .gitignore: Added common ignores for the built mfkey32v2 binary, __pycache__, generated .nfc files, and logs.
  • Minor doc/verification updates and a branch initialization commit.

Validation

  • Built and tested the C mfkey32v2 binary with the exact example from README.md (successfully recovers a0a1a2a3a4a5).
  • Full end-to-end --cli flow tested on macOS 26.5 (Apple M4) with attached Flipper Zero (auto-detected as /dev/cu.usbmodemflip_YourName).
  • Successfully read a large nonce log, recovered 21 unique keys, performed backup + merge into the user dictionary, and cleaned up.
  • Ran the new --clean-cache and --clean-mfkey32-log maintenance commands successfully against the device.
  • macOS port detection logic exercised both with and without the device present.

Post-Merge

  • macOS users can now run ./flipper-crack (or make flipper-crack) after collecting nonces.
  • Existing Linux users are unaffected.
  • Consider updating the main README.md quickstart to mention the macOS guide.

- Replace Linux-only detectFlipperLinux with _detect_flipper_port
  supporting macOS (ls /dev/cu.usbmodem* etc), Linux, basic POSIX.
- Prefers port names containing 'flip'.
- Update _connectToFlipperCli + --detect handler.
- Relax platform guards and improve error messages + argparse text.
- Original Linux behavior preserved for compatibility.
@tomholford tomholford changed the title Add macOS support for Flipper Zero nonce extraction and key loading Add macOS support for nonce extraction and key loading Jun 11, 2026
@tomholford tomholford force-pushed the feat/macos-flipper-mfkey-support branch from 34397e5 to fbd49a9 Compare June 11, 2026 06:20
@tomholford tomholford marked this pull request as ready for review June 11, 2026 06:21
- In --cli full-auto path (writeUserDictToFlipper): always create a .bkp via storage copy before removing + rewriting the user dict. Merge of old+new keys was already present; now more explicitly safe.
- Add new Docs/macOS.md with mac-specific steps (port discovery with ls /dev/cu.*, pyserial via pip, qFlipper hidden files, web fallback, post-load cache clear).
- Update Docs/Flippercli.md with pointer to the macOS guide.
- Reminds the critical device paths: /ext/nfc/.mfkey32.log and /ext/nfc/assets/mf_classic_dict_user.nfc

This commit makes the workflow much safer on macOS while preserving existing behavior.
…OS flow

- New executable flipper-crack script: builds if needed, ensures pyserial, then runs --cli with helpful messages.
- Makefile: added 'make flipper-crack' phony target (same behavior).
- Minor update to Docs/macOS.md to document the new helper.

Users on macOS can now often just run ./flipper-crack after the initial clone+make (once nonces are collected on the device).
- Confirmed on this macOS machine:
  - make mfkey32v2 builds a working binary.
  - README example cracks successfully (Found Key: [a0a1a2a3a4a5]).
  - mfkey_extract.py --help and --detect work (detector found real attached device /dev/cu.usbmodemflip_Kuch1n01).
  - flipper-crack wrapper and make flipper-crack target are present and executable.
- Added Verification section to Docs/macOS.md summarizing the above + reminder of the device paths.
- All changes are on the feature branch in ~/dev/forks/mfkey32v2.

The setup is ready for actual nonce extraction + key load (run ./flipper-crack or the python --cli when you have collected nonces on the Kuch1n01 device).
…ditor files

Keeps the working tree clean after make + python runs (binary, __pycache__, any .nfc or log files produced by the tools).
@tomholford tomholford force-pushed the feat/macos-flipper-mfkey-support branch from fbd49a9 to ada6bfa Compare June 11, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant