Next-Flip / Momentum-Firmware

🐬 Feature-rich, stable and customizable Flipper Firmware
https://momentum-fw.dev
GNU General Public License v3.0
4.29k stars 167 forks source link

NFC: Add parser for CSC Service Works Reloadable Cash Card #137

Closed zinongli closed 2 months ago

zinongli commented 4 months ago

What's new

If it's a normal card:

Screenshot-20240526-023832

Screenshot-20240526-023844

If it's a new card. The card price is read from the card itself. If there were no signature of refill from a vending machine, then the last refill value in the card would reflect the price for getting this card.

Screenshot-20240526-025514


For the reviewer

Willy-JL commented 4 months ago

thank you! ill get to reviewing the code shortly

I can't seem to upload the dumps from both of my cards here for the reviewers to test on their own. Please let me know what would be the best way I can get that to you.

you should be able to drag and drop into the github text box. if not, open up a ticket on discord :D (i think you already have one, if so let us know there and we'll open a new one)

The wordings I chose like "Refill Times" can sound unobvious because this is not my first language. If you have better word-choice ideas please let me know.

i assume "refill times" means how many times the card balance was refilled? and if it was never refilled, it shows "new card"? if so, maybe "Topped up X times" or "Top-up Count: X" could work

on the other hand, im not sure what the difference between "balance" and "refilled balance" is, and what "card usage left" means

zinongli commented 4 months ago

Sure. I will send that to you on Discord.

I see. Top-up count does sound better. Balance is the remaining balance while refilled balance is how much there were when last refilled. So for example if I refilled 20 dollars and spent 10, then I have balance of 10 and refilled balance of 20. Card usage left is a counter that I found on the card memory. It decrements by one each time I use it.

Willy-JL commented 4 months ago

nice, so maybe "Top-up Count", "Last Top-up", "Card Usages Left", and "Card Value" for new card, those sound good to me )

gonna get to reviewing properly tomorrow, and thanks for the files. also, the section with the checkboxes in the PR template is for the reviewer checking your code :D leave them unchecked, we will check them once we try the code

zinongli commented 4 months ago

Cool! I just changed the wordings accordingly. Thanks and sorry about the checkboxes. This is my first time being involved in a public repo. Still have a lot to learn.

Willy-JL commented 4 months ago

undraft when ready

zinongli commented 4 months ago

I completely agree about hardcoding key values affecting universal applicability. I have been learning more about the parser verification process and about how to avoid false positives & misses. From my understanding, inside the _verify function one can't access card memory. But the most robust way to verify is checking the format of the memory because they are ususally the most custom designed for the specific company. So I will move all verification steps into the _parser function and leave the task of decoding keys to the users. It's a MFC 1k anyway.

To answer your question about Key B, I don't have the value of Key B but Key A suffices reading 16/16 blocks. I tried flipper nested but it didn't support this kind of card. And I don't have a pm3 at hand so... It will be a mystery to be solved.

I will send in my commit shortly. Thanks for the review!

octopus8321 commented 3 months ago

I am not a developer but I greatly admire the work that all developers do. It's a great job they do

Willy-JL commented 2 months ago

@zinongli sorry for the delay, i finally looked better at the implementation and it seems meaningful. i cleaned it up a little, remvoed read and verify rather than returning true. can you please verify if it still works correctly? thanks :D

zinongli commented 2 months ago

Works great on my end too. Ready for merge!

Willy-JL commented 2 months ago

thank you!