add one more ndef message decoder. This one is for android managed provision message. Its just printing the text. Most likely other decoding needed

This commit is contained in:
iceman1001 2024-01-16 00:06:03 +01:00
parent 805269ad4a
commit ad50a6a6c5
2 changed files with 18 additions and 2 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Changed `nfc decode` - now supports Android Managed Provision NDEF message decoding (@iceman1001)
- Changed `hf_cardhopper` - Allow button presses to break, handle non-zero CID from reader by relaying RATS and improving PPS and WTX handling, more reliably cook ATS, ignore client packets on serial line (@nvx) - Changed `hf_cardhopper` - Allow button presses to break, handle non-zero CID from reader by relaying RATS and improving PPS and WTX handling, more reliably cook ATS, ignore client packets on serial line (@nvx)
- Fixed `data diff` - client no longer crashes when using short widths on long filenames (@iceman1001) - Fixed `data diff` - client no longer crashes when using short widths on long filenames (@iceman1001)
- Added `hf 15 wipe` - fills card memory with zeros (@iceman1001) - Added `hf 15 wipe` - fills card memory with zeros (@iceman1001)

View file

@ -42,6 +42,8 @@
#define NDEF_BLUEAPPL_LE "application/vnd.bluetooth.le.oob" #define NDEF_BLUEAPPL_LE "application/vnd.bluetooth.le.oob"
#define NDEF_BLUEAPPL_SECURE_LE "application/vnd.bluetooth.secure.le.oob" #define NDEF_BLUEAPPL_SECURE_LE "application/vnd.bluetooth.secure.le.oob"
#define NDEF_ANDROID_PROVISION "application/com.android.managedprovisioning"
static const char *TypeNameFormat_s[] = { static const char *TypeNameFormat_s[] = {
"Empty Record", "Empty Record",
@ -592,7 +594,6 @@ static int ndefDecodePayloadSmartPoster(uint8_t *ndef, size_t ndeflen, bool prin
return PM3_SUCCESS; return PM3_SUCCESS;
} }
typedef struct ndef_wifi_type_s { typedef struct ndef_wifi_type_s {
const char *description; const char *description;
uint8_t bytes[2]; uint8_t bytes[2];
@ -943,6 +944,17 @@ static int ndefDecodeMime_bt(NDEFHeader_t *ndef) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int ndefDecodeMime_android_provision(NDEFHeader_t *ndef) {
if (ndef->PayloadLen == 0) {
PrintAndLogEx(INFO, "no payload");
return PM3_SUCCESS;
}
PrintAndLogEx(INFO, _CYAN_("Android Managed Provision"));
PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, "%.*s", (int)ndef->PayloadLen, ndef->Payload);
return PM3_SUCCESS;
}
// https://raw.githubusercontent.com/haldean/ndef/master/docs/NFCForum-TS-RTD_1.0.pdf // https://raw.githubusercontent.com/haldean/ndef/master/docs/NFCForum-TS-RTD_1.0.pdf
static int ndefDecodeExternal_record(NDEFHeader_t *ndef) { static int ndefDecodeExternal_record(NDEFHeader_t *ndef) {
@ -1079,6 +1091,10 @@ static int ndefDecodePayload(NDEFHeader_t *ndef, bool verbose) {
ndefDecodeMime_json(ndef); ndefDecodeMime_json(ndef);
} }
if (str_startswith(begin, NDEF_ANDROID_PROVISION)) {
ndefDecodeMime_android_provision(ndef);
}
free(begin); free(begin);
begin = NULL; begin = NULL;
break; break;
@ -1297,7 +1313,6 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
int NDEFGetTotalLength(uint8_t *ndef, size_t ndeflen, size_t *outlen) { int NDEFGetTotalLength(uint8_t *ndef, size_t ndeflen, size_t *outlen) {
size_t idx = 0; size_t idx = 0;