0

Is there a way to log the binary data send to the tranceive method of a NFC tag? https://developer.android.com/reference/android/nfc/tech/NfcV.html#transceive(byte[])

I am trying to find the last few missing pieces in a protocol and it would help if I could listen to the data getting sent.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
NKCSS
  • 2,716
  • 1
  • 22
  • 38

1 Answers1

0

I'm guessing that:

  • You want to monitor the APDUs/bytes sent from an app you have installed.
  • You've already searched for info about that specific protocol and found nothing.
  • At the Logcat, no relevant info is shown (by default).

Looking up at the transceive source code

 public byte[] transceive(byte[] data) throws IOException {
       return transceive(data, true);
    }

which redirects to:

    byte[] transceive(byte[] data, boolean raw) throws IOException {
        checkConnected();

        try {
            TransceiveResult result = mTag.getTagService().transceive(mTag.getServiceHandle(),
                    data, raw);
            if (result == null) {
                throw new IOException("transceive failed");
            } else {
                return result.getResponseOrThrow();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "NFC service dead", e);
            throw new IOException("NFC service died");
        }
   }

Which goes on to the TransceiveResult class.

My best bet (if you wish to get to the very end) is to recompile an Android source code that prints out the data input'd to the byte[] transceive(byte[] data) function. Good luck.

EDIT: Another option I happened to realise is to use an APDU sniffer, although I legitimately don't know how legal this option is.

Sairam
  • 169
  • 12
alvaroga91
  • 126
  • 1
  • 9
  • You are right regarding your guesses :) I figured recompiling android was the only way; but I don't have the time to do that I'm afraid. Thanks though. – NKCSS Jul 04 '16 at 12:23