Git Product home page Git Product logo

nfc-card-emulator's Introduction

nfc-card-emulator

Group project for IMT 3673 Mobile/Wearable Programming (2 people)

The idea

The idea is to use your card as an emulator for an access card, such as the NTNU cards. You scan a card and store it, and then it can later be used as a replacement for the card.

The main motivation behind the idea was to use the NTNU cards, as such the app only supports reading of Mifare Classic 1K cards (which is the technology the NTNU cards use). The app can recognice any NFC card, but will not do anything other than say the card type is not supported.

Testing this app requires a physical device with NFC (an emulator does not suffice) and an NTNU card (or other Mifare Classic 1K cards).

Features of the app

NFC: Reading of Mifare Classic 1K cards

Localization: The user can change between English and Norwegian

Location services: The app stores (if permitted by the user) the location when a card is added. When selecting a card to emulate or edit, the user can select to sort based on location. The app finds the users current location and compares that to the location of the cards. The cards are then sorted based on your current location, the cards created closest to the current location are shown first. The idea behind this is that one might have multiple cards for different places, and when selecting a card would probably want to see the closest first.

Storage is done with SQLite and Room.

Scanning a Mifare Classic card when the app is closed opens the scanning activity (still needs to be rescanned inside the app)

How the app works

  1. To scan a new card, click the "Scan" button in the start activity. If your device does not support NFC you will not be allowed to enter this activity.
  2. Hold the card to your phone for 3-5 seconds (if you don't hold it long enough an error message will appear). When everything is read from the card you can continue to the next activity to store the card.
  3. If this is the first time adding a card, a request for your location will appear. If you accept this request your location at the time of adding the card will be stored. Give your card a name and click "Add card".
  4. Click on "Emulate". Here you can sort your cards based on time of creation, the cards name, or the location the card was added at relative to your current position (the closest cards come first).
  5. Select a card by clicking on it and hold your phone towards a card reader (the emulating functionality doesn't work)
  6. Cards can be edited by clicking the "Edit" button in the start activity. The same list as in the emulate activity will be shown, select an item and you can change the name of the card.
  7. Language can be changed by clicking the flag button in the start activity (Norwegian and English support).

Problems with emulating

If you've stumbled across this repo by trying to emulate Mifare Classic cards on Android, I'm sorry to tell you that you're out of luck. Doesn't work (at least at the time of writing).

Mifare is a proprietary technology and Mifare Classic doesn't seem to use NDEF messages to hold data. We tried gathering the data by reading the blocks inside the sectors on the card, and we do get some data, but we haven't found a way to use this in a meaningful way.

As seen from this answer on StackOverflow, Mifare Classic only partially operates on ISO/IEC 14443-3 (which is a part of the Android Host Card Emulation, HCE, stack), so it is not possible to emulate Mifare Classic cards with HCE (this answer is from late 2013, but we haven't found anything else to make it seem like it's possible now).

Using HCE requires a resource file (see app/src/main/res/xml/apduservice.xml) which includes AID (application ID) filters that decide what the app should recognize. The AID in that file is found here (search for "GOOGLE_MIFARE_MANAGER_AID"), in hopes that it would work for Mifare Classic, but we were out of luck.

According to the first comment on this question on StackOverflow (answered by the same person as the first question, this time in 2016), Mifare Classic readers do not use AIDs (and that makes it not possible to use with HCE)

We have tried with both HCE and Peer-to-peer communication (Android Beam), but we haven't been able to emulate the cards. The card readers recognize the phone (they probably recognize anything with NFC), but we haven't been able to make the phone detect it and therefore can't communicate with it.

nfc-card-emulator's People

Contributors

hakonschia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.