-
Notifications
You must be signed in to change notification settings - Fork 3k
NFC: Add support for Gallagher access control (MIFARE Classic only) #3306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
gallagher_util shouldn't be part of firmware in NFC library. The perfect solution would be to put this lib in NFC application helpers and expose this API for plugins. We don't have this yet, but an example in applications/examples/example_plugins_advanced/ may give you tips how that can be done.
I suggest two solutions. You can add NFC application API for plugins with gallagher_util wrapped as it's done in example_plugins_advanced. Or you can temporary put gallagher_util inside gallagher plugin and we will rework that in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know what you choose or if you have any questions.
Thanks, @gornekich! I'll take a crack at the plugins approach, but it might be a bit after the holidays til I get around to it. |
…y NfcSupportedCardsLoadContext to contain a pointer to a resolver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are on the right way.
One more time: gallagher_util shouldn't be in lib/nfc, it should be in NFC application. And NFC app should expose API from gallagher_util, so that gallagher plugin could resolve symbols using NFC app API
applications/main/nfc/nfc_app_api.h
Outdated
* It is also exposed to plugins to allow them to use the application's API. | ||
*/ | ||
#include <stdint.h> | ||
#include <nfc/helpers/gallagher_util.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gallagher_util should become part of NFC app. It shouldn't be in lib/nfc.
Thanks - I've got it near working locally. This WIP push wasn't supposed to update the PR, I forgot GitHub did that. At the moment I've got the functionality exposed as part of the plugins API and housed within the NFC app. All I've got left to do is expose the constants defined in the utils headers to the plugins. Any suggestions? Currently getting complaints about the symbols being unresolved since they're no longer linked directly. |
I'll drop a comment on this PR when it's ready to be looked at as well |
Hard to say without looking at code. You can push code and may be I will come up with a solution :) |
…aving resolution issues
… this fixes our woes, which it does not.
Here you go. This is still a WIP - but I'm open to any solutions. It "should work" in the sense that we're now passing a composite resolver all the way through to Notes:
|
You think me leaving Just kidding. Give me a bit more to sort the rest out, then I'll comment again when it's ready for review. |
Btw |
Yeap -- I had completely forgot that I left this in while debugging another issue. I thought my symbol resolver was broken but in fact it was working perfectly, and hitting this line. |
Okay. Things are working. I'd like some feedback on the following:
Thanks! |
Hey @gornekich, just pinging you on this. It's fully functional except for the compiler warning that I need some input to resolve. Do I need to change the status on this PR? No rush, just want to make sure I was clear. Thanks! |
@nickmooney thanks! I will review the code in a few days |
@nickmooney I am sorry for pushing to your branch. I think it's better than making a big patch. First of all, thanks for your work. Actually you made everything right, and I made small changes. Answering your questions:
I made some changes in your code:
Please, let me know if my changes work for you. If everything OK, we will merge your PR |
Thanks so much for the review. All the changes you've made seem reasonable and good to me! I'm happy with this PR in its current state. |
Hello friends, I am new to flipper devices , and I am wondering if it is appropriate to seek some advice here. Please advise if I should have posted this message somewhere else. I installed the newest firmware 0.98.3, and tried to read a gallagher NFC card. The card can be recognised by flipper, but not as a gallagher card. I am wondering if I need to install some library or dependencies manually before I can use firmware 0.98.3 to emulate gallagher card? Thank you for your help |
@doomwastaken @nickmooney @hedger I think I saw some abnormalities in this specific plugin linking
|
What's new
Based on the reverse-engineering work presented by megabug in this repository and this Kawaiicon talk, this pull request implements the ability for Flipper Zero to parse Gallagher cardholder credentials from MIFARE Classic cards.
Note that this implementation is relatively limited: it will only work if the Gallagher installation is using the default site keys, or if the MIFARE Classic dictionary on the Flipper contains the site-specific keys. Additionally, only one cardholder credential (the default credential, held in sector 15) is currently supported. Emulation of this type of Gallagher credential is already supported by the Flipper's MIFARE Classic emulation functionality.
This is my first contribution to the Flipper Zero ecosystem; I'm open to feedback.
Verification
If you don't have access to a Gallagher MIFARE Classic, you can write/emulate the following blocks:
This encodes a Gallagher credential with region code 1, facility code 2, card number 3, and issue level 4. The keys in the last block are the default Gallagher site keys -- the first is already present in the Flipper MIFARE Classic dictionary.
The tag should parse like shown:
Note that the facility / region codes are displayed combined (i.e. an alphabet letter A-P for the region, followed by the numeric facility). I'm open to displaying this data in other formats.
Checklist (For Reviewer)