nfc decode - detects and prints application/json

This commit is contained in:
iceman1001 2021-11-24 20:23:34 +01:00
commit e6cc0ed836

View file

@ -25,9 +25,11 @@
#define NDEF_WIFIAPPL "application/vnd.wfa" #define NDEF_WIFIAPPL "application/vnd.wfa"
#define NDEF_BLUEAPPL "application/vnd.bluetooth" #define NDEF_BLUEAPPL "application/vnd.bluetooth"
#define NDEF_JSONAPPL "application/json"
#define NDEF_VCARDTEXT "text/vcard" #define NDEF_VCARDTEXT "text/vcard"
#define NDEF_XVCARDTEXT "text/x-vcard" #define NDEF_XVCARDTEXT "text/x-vcard"
static const char *TypeNameFormat_s[] = { static const char *TypeNameFormat_s[] = {
"Empty Record", "Empty Record",
"Well Known Record", "Well Known Record",
@ -517,6 +519,14 @@ static int ndefDecodeMime_vcard(NDEFHeader_t *ndef) {
} }
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int ndefDecodeMime_json(NDEFHeader_t *ndef) {
PrintAndLogEx(INFO, _CYAN_("JSON details"));
if (ndef->PayloadLen > 1) {
PrintAndLogEx(INFO, "");
PrintAndLogEx(INFO, _GREEN_("%.*s"), (int)ndef->PayloadLen, ndef->Payload);
}
return PM3_SUCCESS;
}
static int ndefDecodeMime_bt(NDEFHeader_t *ndef) { static int ndefDecodeMime_bt(NDEFHeader_t *ndef) {
PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type); PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type);
@ -651,6 +661,9 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
if (str_startswith(begin, NDEF_BLUEAPPL)) { if (str_startswith(begin, NDEF_BLUEAPPL)) {
ndefDecodeMime_bt(ndef); ndefDecodeMime_bt(ndef);
} }
if (str_startswith(begin, NDEF_JSONAPPL)) {
ndefDecodeMime_json(ndef);
}
free(begin); free(begin);
begin = NULL; begin = NULL;
@ -673,6 +686,7 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
PrintAndLogEx(INFO, "- decoder to be impl -"); PrintAndLogEx(INFO, "- decoder to be impl -");
break; break;
} }
PrintAndLogEx(INFO, "");
return PM3_SUCCESS; return PM3_SUCCESS;
} }