mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
the ndef printing is now more dense and it honors verbose output
This commit is contained in:
parent
69fd1ac889
commit
2627f3b3b9
11 changed files with 130 additions and 97 deletions
|
@ -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 ndef output to be more dense. Honors verbose now (@iceman1001)
|
||||||
- Fixed `hf mf ndefwrite` - now skips not ndef formatted sectors (@iceman1001)
|
- Fixed `hf mf ndefwrite` - now skips not ndef formatted sectors (@iceman1001)
|
||||||
- Fixed `hf mf ndefread` - now skips not ndef formatted sectors correctly (@iceman1001)
|
- Fixed `hf mf ndefread` - now skips not ndef formatted sectors correctly (@iceman1001)
|
||||||
- Fixed `lf hitag` - keep inside the arrays for key/password/nrar (@iceman1001)
|
- Fixed `lf hitag` - keep inside the arrays for key/password/nrar (@iceman1001)
|
||||||
|
|
|
@ -2633,12 +2633,15 @@ int CmdHF14ANdefRead(const char *Cmd) {
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_str0("f", "file", "<fn>", "save raw NDEF to file"),
|
arg_str0("f", "file", "<fn>", "save raw NDEF to file"),
|
||||||
|
arg_litn("v", "verbose", 0, 2, "show technical data"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
int fnlen = 0;
|
int fnlen = 0;
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
|
|
||||||
|
bool verbose = arg_get_lit(ctx, 2);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
bool activate_field = true;
|
bool activate_field = true;
|
||||||
|
@ -2828,7 +2831,7 @@ int CmdHF14ANdefRead(const char *Cmd) {
|
||||||
saveFile(filename, ".bin", ndef_file, ndef_size);
|
saveFile(filename, ".bin", ndef_file, ndef_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
NDEFRecordsDecodeAndPrint(ndef_file, ndef_size);
|
NDEFRecordsDecodeAndPrint(ndef_file, ndef_size, verbose);
|
||||||
free(ndef_file);
|
free(ndef_file);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2004,12 +2004,15 @@ int CmdHF14BNdefRead(const char *Cmd) {
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_str0("f", "file", "<fn>", "save raw NDEF to file"),
|
arg_str0("f", "file", "<fn>", "save raw NDEF to file"),
|
||||||
|
arg_litn("v", "verbose", 0, 2, "show technical data"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
int fnlen = 0;
|
int fnlen = 0;
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
|
|
||||||
|
bool verbose = arg_get_lit(ctx, 2);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
bool activate_field = true;
|
bool activate_field = true;
|
||||||
|
@ -2096,7 +2099,7 @@ int CmdHF14BNdefRead(const char *Cmd) {
|
||||||
if (fnlen != 0) {
|
if (fnlen != 0) {
|
||||||
saveFile(filename, ".bin", response + 2, resplen - 4);
|
saveFile(filename, ".bin", response + 2, resplen - 4);
|
||||||
}
|
}
|
||||||
res = NDEFRecordsDecodeAndPrint(response + 2, resplen - 4);
|
res = NDEFRecordsDecodeAndPrint(response + 2, resplen - 4, verbose);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
switch_off_field_14b();
|
switch_off_field_14b();
|
||||||
|
|
|
@ -215,7 +215,7 @@ static void jooki_printEx(uint8_t *b64, uint8_t *iv, uint8_t tid, uint8_t fid, u
|
||||||
PrintAndLogEx(INFO, "NDEF raw..... %s", sprint_hex_inrow(ndefmsg, sizeof(ndefmsg)));
|
PrintAndLogEx(INFO, "NDEF raw..... %s", sprint_hex_inrow(ndefmsg, sizeof(ndefmsg)));
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
int res = NDEFRecordsDecodeAndPrint(ndefmsg, sizeof(ndefmsg));
|
int res = NDEFRecordsDecodeAndPrint(ndefmsg, sizeof(ndefmsg), verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
NDEFDecodeAndPrint(ndefmsg, sizeof(ndefmsg), verbose);
|
NDEFDecodeAndPrint(ndefmsg, sizeof(ndefmsg), verbose);
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ static int jooki_selftest(void) {
|
||||||
jooki_create_ndef(b64, ndefmsg);
|
jooki_create_ndef(b64, ndefmsg);
|
||||||
PrintAndLogEx(INFO, "NDEF raw .... %s", sprint_hex(ndefmsg, sizeof(ndefmsg)));
|
PrintAndLogEx(INFO, "NDEF raw .... %s", sprint_hex(ndefmsg, sizeof(ndefmsg)));
|
||||||
|
|
||||||
int status = NDEFRecordsDecodeAndPrint(ndefmsg, sizeof(ndefmsg));
|
int status = NDEFRecordsDecodeAndPrint(ndefmsg, sizeof(ndefmsg), true);
|
||||||
if (status != PM3_SUCCESS) {
|
if (status != PM3_SUCCESS) {
|
||||||
status = NDEFDecodeAndPrint(ndefmsg, sizeof(ndefmsg), true);
|
status = NDEFDecodeAndPrint(ndefmsg, sizeof(ndefmsg), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5693,12 +5693,16 @@ int CmdHFMFNDEFRead(const char *Cmd) {
|
||||||
res = NDEFDecodeAndPrint(data, datalen, verbose);
|
res = NDEFDecodeAndPrint(data, datalen, verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
||||||
res = NDEFRecordsDecodeAndPrint(data, datalen);
|
res = NDEFRecordsDecodeAndPrint(data, datalen, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose == false) {
|
||||||
|
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -v`") " for more details");
|
||||||
|
} else {
|
||||||
if (verbose2 == false) {
|
if (verbose2 == false) {
|
||||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -vv`") " for more details");
|
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -vv`") " for more details");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6021,8 +6025,8 @@ int CmdHFMFNDEFWrite(const char *Cmd) {
|
||||||
free(dump);
|
free(dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has raw bytes ndef message header?
|
// Has raw bytes ndef message header?bytes
|
||||||
switch(raw[0]) {
|
switch (raw[0]) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
case 0x01:
|
case 0x01:
|
||||||
case 0x02:
|
case 0x02:
|
||||||
|
@ -6042,7 +6046,7 @@ int CmdHFMFNDEFWrite(const char *Cmd) {
|
||||||
memcpy(tmp_raw, raw, sizeof(tmp_raw));
|
memcpy(tmp_raw, raw, sizeof(tmp_raw));
|
||||||
raw[0] = 0x03;
|
raw[0] = 0x03;
|
||||||
raw[1] = bytes;
|
raw[1] = bytes;
|
||||||
memcpy(raw + 2, tmp_raw, sizeof(raw) - 2 );
|
memcpy(raw + 2, tmp_raw, sizeof(raw) - 2);
|
||||||
bytes += 2;
|
bytes += 2;
|
||||||
PrintAndLogEx(SUCCESS, "Added generic message header (0x03)");
|
PrintAndLogEx(SUCCESS, "Added generic message header (0x03)");
|
||||||
}
|
}
|
||||||
|
@ -6100,8 +6104,10 @@ int CmdHFMFNDEFWrite(const char *Cmd) {
|
||||||
block_no = mfFirstBlockOfSector(i);
|
block_no = mfFirstBlockOfSector(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "Sector %u is NDEF formatted", i);
|
PrintAndLogEx(INFO, "Sector %u is NDEF formatted", i);
|
||||||
sum += (MFBLOCK_SIZE * 3 );
|
}
|
||||||
|
sum += (MFBLOCK_SIZE * 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6145,7 +6151,7 @@ int CmdHFMFNDEFWrite(const char *Cmd) {
|
||||||
block_no++;
|
block_no++;
|
||||||
|
|
||||||
// skip sectors which isn't ndef formatted
|
// skip sectors which isn't ndef formatted
|
||||||
while ( freemem[mfSectorNum(block_no)] == 0 ) {
|
while (freemem[mfSectorNum(block_no)] == 0) {
|
||||||
block_no++;
|
block_no++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3958,6 +3958,7 @@ int CmdHF14MfuNDEFRead(const char *Cmd) {
|
||||||
arg_str0("k", "key", "Replace default key for NDEF", NULL),
|
arg_str0("k", "key", "Replace default key for NDEF", NULL),
|
||||||
arg_lit0("l", NULL, "Swap entered key's endianness"),
|
arg_lit0("l", NULL, "Swap entered key's endianness"),
|
||||||
arg_str0("f", "file", "<fn>", "Save raw NDEF to file"),
|
arg_str0("f", "file", "<fn>", "Save raw NDEF to file"),
|
||||||
|
arg_litn("v", "verbose", 0, 2, "show technical data"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
@ -3966,6 +3967,7 @@ int CmdHF14MfuNDEFRead(const char *Cmd) {
|
||||||
int fnlen = 0;
|
int fnlen = 0;
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 3), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIParamStrToBuf(arg_get_str(ctx, 3), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
|
bool verbose = arg_get_lit(ctx, 4);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
switch (keylen) {
|
switch (keylen) {
|
||||||
|
@ -4052,9 +4054,9 @@ int CmdHF14MfuNDEFRead(const char *Cmd) {
|
||||||
if (fnlen != 0) {
|
if (fnlen != 0) {
|
||||||
saveFile(filename, ".bin", records, (size_t)maxsize);
|
saveFile(filename, ".bin", records, (size_t)maxsize);
|
||||||
}
|
}
|
||||||
status = NDEFRecordsDecodeAndPrint(records, (size_t)maxsize);
|
status = NDEFRecordsDecodeAndPrint(records, (size_t)maxsize, verbose);
|
||||||
if (status != PM3_SUCCESS) {
|
if (status != PM3_SUCCESS) {
|
||||||
status = NDEFDecodeAndPrint(records, (size_t)maxsize, true);
|
status = NDEFDecodeAndPrint(records, (size_t)maxsize, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *jooki = strstr((char *)records, "s.jooki.rocks/s/?s=");
|
char *jooki = strstr((char *)records, "s.jooki.rocks/s/?s=");
|
||||||
|
|
|
@ -287,6 +287,7 @@ int CmdHFST25TANdefRead(const char *Cmd) {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_str0("p", "pwd", "<hex>", "16 byte read password"),
|
arg_str0("p", "pwd", "<hex>", "16 byte read password"),
|
||||||
arg_str0("f", "file", "<fn>", "save raw NDEF to file"),
|
arg_str0("f", "file", "<fn>", "save raw NDEF to file"),
|
||||||
|
arg_litn("v", "verbose", 0, 2, "show technical data"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
@ -294,6 +295,7 @@ int CmdHFST25TANdefRead(const char *Cmd) {
|
||||||
int fnlen = 0;
|
int fnlen = 0;
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
|
bool verbose = arg_get_lit(ctx, 3);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (pwdlen == 0) {
|
if (pwdlen == 0) {
|
||||||
|
@ -404,7 +406,7 @@ int CmdHFST25TANdefRead(const char *Cmd) {
|
||||||
if (fnlen != 0) {
|
if (fnlen != 0) {
|
||||||
saveFile(filename, ".bin", response + 2, resplen - 4);
|
saveFile(filename, ".bin", response + 2, resplen - 4);
|
||||||
}
|
}
|
||||||
NDEFRecordsDecodeAndPrint(response + 2, resplen - 4);
|
NDEFRecordsDecodeAndPrint(response + 2, resplen - 4, verbose);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ static int CmdNfcDecode(const char *Cmd) {
|
||||||
res = NDEFDecodeAndPrint(dump, bytes_read, verbose);
|
res = NDEFDecodeAndPrint(dump, bytes_read, verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
||||||
res = NDEFRecordsDecodeAndPrint(dump, bytes_read);
|
res = NDEFRecordsDecodeAndPrint(dump, bytes_read, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dump);
|
free(dump);
|
||||||
|
@ -123,7 +123,7 @@ static int CmdNfcDecode(const char *Cmd) {
|
||||||
res = NDEFDecodeAndPrint(data, datalen, verbose);
|
res = NDEFDecodeAndPrint(data, datalen, verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
||||||
res = NDEFRecordsDecodeAndPrint(data, datalen);
|
res = NDEFRecordsDecodeAndPrint(data, datalen, verbose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -113,8 +113,8 @@ static const char *URI_s[] = {
|
||||||
"urn:nfc:" // 0x23
|
"urn:nfc:" // 0x23
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen);
|
static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen, bool verbose);
|
||||||
static int ndefDecodePayload(NDEFHeader_t *ndef);
|
static int ndefDecodePayload(NDEFHeader_t *ndef, bool verbose);
|
||||||
|
|
||||||
static uint16_t ndefTLVGetLength(const uint8_t *data, size_t *indx) {
|
static uint16_t ndefTLVGetLength(const uint8_t *data, size_t *indx) {
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
|
@ -166,9 +166,10 @@ static int ndefDecodeHeader(uint8_t *data, size_t datalen, NDEFHeader_t *header)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ndefPrintHeader(NDEFHeader_t *header) {
|
static int ndefPrintHeader(NDEFHeader_t *header, bool verbose) {
|
||||||
PrintAndLogEx(INFO, _CYAN_("Header info"));
|
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
PrintAndLogEx(INFO, _CYAN_("Header info"));
|
||||||
PrintAndLogEx(SUCCESS, " %s ....... Message begin", STRBOOL(header->MessageBegin));
|
PrintAndLogEx(SUCCESS, " %s ....... Message begin", STRBOOL(header->MessageBegin));
|
||||||
PrintAndLogEx(SUCCESS, " %s ...... Message end", STRBOOL(header->MessageEnd));
|
PrintAndLogEx(SUCCESS, " %s ...... Message end", STRBOOL(header->MessageEnd));
|
||||||
PrintAndLogEx(SUCCESS, " %s ..... Chunk flag", STRBOOL(header->ChunkFlag));
|
PrintAndLogEx(SUCCESS, " %s ..... Chunk flag", STRBOOL(header->ChunkFlag));
|
||||||
|
@ -180,9 +181,10 @@ static int ndefPrintHeader(NDEFHeader_t *header) {
|
||||||
PrintAndLogEx(SUCCESS, " Type length........ %zu", header->TypeLen);
|
PrintAndLogEx(SUCCESS, " Type length........ %zu", header->TypeLen);
|
||||||
PrintAndLogEx(SUCCESS, " Payload length..... %zu", header->PayloadLen);
|
PrintAndLogEx(SUCCESS, " Payload length..... %zu", header->PayloadLen);
|
||||||
PrintAndLogEx(SUCCESS, " ID length.......... %zu", header->IDLen);
|
PrintAndLogEx(SUCCESS, " ID length.......... %zu", header->IDLen);
|
||||||
PrintAndLogEx(SUCCESS, " Record length...... %zu", header->RecLen);
|
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, " Type name format... [ 0x%02x ] " _YELLOW_("%s"), header->TypeNameFormat, TypeNameFormat_s[header->TypeNameFormat]);
|
PrintAndLogEx(SUCCESS, " Type name format... [ 0x%02x ] " _YELLOW_("%s"), header->TypeNameFormat, TypeNameFormat_s[header->TypeNameFormat]);
|
||||||
|
PrintAndLogEx(SUCCESS, " Record length...... %zu", header->RecLen);
|
||||||
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,14 +485,13 @@ static int ndefDecodePayloadSmartPoster(uint8_t *ndef, size_t ndeflen, bool prin
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
ndefPrintHeader(&NDEFHeader, verbose);
|
||||||
ndefPrintHeader(&NDEFHeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NDEFHeader.TypeLen && NDEFHeader.PayloadLen) {
|
if (NDEFHeader.TypeLen && NDEFHeader.PayloadLen) {
|
||||||
ndefDecodePayload(&NDEFHeader);
|
ndefDecodePayload(&NDEFHeader, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
if (NDEFHeader.TypeLen) {
|
if (NDEFHeader.TypeLen) {
|
||||||
PrintAndLogEx(INFO, "Type data");
|
PrintAndLogEx(INFO, "Type data");
|
||||||
print_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, 1);
|
print_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, 1);
|
||||||
|
@ -503,6 +504,8 @@ static int ndefDecodePayloadSmartPoster(uint8_t *ndef, size_t ndeflen, bool prin
|
||||||
PrintAndLogEx(INFO, "Payload data");
|
PrintAndLogEx(INFO, "Payload data");
|
||||||
print_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, 1);
|
print_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// recursive
|
// recursive
|
||||||
if (NDEFHeader.MessageEnd == false) {
|
if (NDEFHeader.MessageEnd == false) {
|
||||||
ndefDecodePayloadSmartPoster(ndef + NDEFHeader.RecLen, ndeflen - NDEFHeader.RecLen, false, false);
|
ndefDecodePayloadSmartPoster(ndef + NDEFHeader.RecLen, ndeflen - NDEFHeader.RecLen, false, false);
|
||||||
|
@ -825,7 +828,7 @@ static int ndefDecodeMime_bt(NDEFHeader_t *ndef) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ndefDecodePayload(NDEFHeader_t *ndef) {
|
static int ndefDecodePayload(NDEFHeader_t *ndef, bool verbose) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "");
|
PrintAndLogEx(INFO, "");
|
||||||
switch (ndef->TypeNameFormat) {
|
switch (ndef->TypeNameFormat) {
|
||||||
|
@ -868,7 +871,7 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncmp((char *)ndef->Type, "Sp", ndef->TypeLen)) {
|
if (!strncmp((char *)ndef->Type, "Sp", ndef->TypeLen)) {
|
||||||
ndefDecodePayloadSmartPoster(ndef->Payload, ndef->PayloadLen, true, false);
|
ndefDecodePayloadSmartPoster(ndef->Payload, ndef->PayloadLen, true, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncmp((char *)ndef->Type, "Di", ndef->TypeLen)) {
|
if (!strncmp((char *)ndef->Type, "Di", ndef->TypeLen)) {
|
||||||
|
@ -947,16 +950,17 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
|
static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen, bool verbose) {
|
||||||
NDEFHeader_t NDEFHeader = {0};
|
NDEFHeader_t NDEFHeader = {0};
|
||||||
int res = ndefDecodeHeader(ndefRecord, ndefRecordLen, &NDEFHeader);
|
int res = ndefDecodeHeader(ndefRecord, ndefRecordLen, &NDEFHeader);
|
||||||
if (res != PM3_SUCCESS)
|
if (res != PM3_SUCCESS)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
ndefPrintHeader(&NDEFHeader);
|
ndefPrintHeader(&NDEFHeader, verbose);
|
||||||
PrintAndLogEx(INFO, "");
|
PrintAndLogEx(INFO, "");
|
||||||
PrintAndLogEx(INFO, _CYAN_("Payload info"));
|
PrintAndLogEx(INFO, _CYAN_("Payload info"));
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
if (NDEFHeader.TypeLen) {
|
if (NDEFHeader.TypeLen) {
|
||||||
PrintAndLogEx(INFO, "Type data");
|
PrintAndLogEx(INFO, "Type data");
|
||||||
print_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, 1);
|
print_buffer(NDEFHeader.Type, NDEFHeader.TypeLen, 1);
|
||||||
|
@ -969,14 +973,16 @@ static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
|
||||||
PrintAndLogEx(INFO, "Payload data");
|
PrintAndLogEx(INFO, "Payload data");
|
||||||
print_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, 1);
|
print_buffer(NDEFHeader.Payload, NDEFHeader.PayloadLen, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (NDEFHeader.TypeLen && NDEFHeader.PayloadLen) {
|
if (NDEFHeader.TypeLen && NDEFHeader.PayloadLen) {
|
||||||
ndefDecodePayload(&NDEFHeader);
|
ndefDecodePayload(&NDEFHeader, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NDEFRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
|
int NDEFRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen, bool verbose) {
|
||||||
bool firstRec = true;
|
bool firstRec = true;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
size_t counter = 0;
|
size_t counter = 0;
|
||||||
|
@ -1005,7 +1011,7 @@ int NDEFRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(SUCCESS, _CYAN_("Record") " " _YELLOW_("%zu"), counter);
|
PrintAndLogEx(SUCCESS, _CYAN_("Record") " " _YELLOW_("%zu"), counter);
|
||||||
PrintAndLogEx(INFO, "-----------------------------------------------------");
|
PrintAndLogEx(INFO, "-----------------------------------------------------");
|
||||||
ndefRecordDecodeAndPrint(&ndefRecord[len], NDEFHeader.RecLen);
|
ndefRecordDecodeAndPrint(&ndefRecord[len], NDEFHeader.RecLen, verbose);
|
||||||
|
|
||||||
len += NDEFHeader.RecLen;
|
len += NDEFHeader.RecLen;
|
||||||
|
|
||||||
|
@ -1085,9 +1091,9 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
PrintAndLogEx(SUCCESS, "Found NDEF message w zero length");
|
PrintAndLogEx(SUCCESS, "Found NDEF message w zero length");
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, "Found NDEF message (%d bytes)", len);
|
PrintAndLogEx(SUCCESS, "Found NDEF message ( " _YELLOW_("%d") " bytes )", len);
|
||||||
|
|
||||||
int res = NDEFRecordsDecodeAndPrint(&ndef[indx], len);
|
int res = NDEFRecordsDecodeAndPrint(&ndef[indx], len, verbose);
|
||||||
if (res != PM3_SUCCESS)
|
if (res != PM3_SUCCESS)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1118,4 +1124,3 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||||
}
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,6 @@ typedef struct {
|
||||||
} NDEFHeader_t;
|
} NDEFHeader_t;
|
||||||
|
|
||||||
int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose);
|
int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose);
|
||||||
int NDEFRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen);
|
int NDEFRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen, bool verbose);
|
||||||
|
|
||||||
#endif // _NDEF_H_
|
#endif // _NDEF_H_
|
||||||
|
|
|
@ -1162,9 +1162,10 @@
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-f, --file <fn> save raw NDEF to file"
|
"-f, --file <fn> save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf 14a ndefread [-h] [-f <fn>]"
|
"usage": "hf 14a ndefread [-hv] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"hf 14a raw": {
|
"hf 14a raw": {
|
||||||
"command": "hf 14a raw",
|
"command": "hf 14a raw",
|
||||||
|
@ -1348,9 +1349,10 @@
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-f, --file <fn> save raw NDEF to file"
|
"-f, --file <fn> save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf 14b ndefread [-h] [-f <fn>]"
|
"usage": "hf 14b ndefread [-hv] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"hf 14b raw": {
|
"hf 14b raw": {
|
||||||
"command": "hf 14b raw",
|
"command": "hf 14b raw",
|
||||||
|
@ -4394,20 +4396,23 @@
|
||||||
"command": "hf mf ndefwrite",
|
"command": "hf mf ndefwrite",
|
||||||
"description": "Write raw NDEF hex bytes to tag. This commands assumes tag already been NFC/NDEF formatted.",
|
"description": "Write raw NDEF hex bytes to tag. This commands assumes tag already been NFC/NDEF formatted.",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf mf ndefread -d 0300FE -> write empty record to tag",
|
"hf mf ndefwrite -d 0300FE -> write empty record to tag",
|
||||||
"hf mf ndefread -f myfilename"
|
"hf mf ndefwrite -f myfilename",
|
||||||
|
"hf mf ndefwrite -d 033fd1023a53709101195405656e2d55534963656d616e2054776974746572206c696e6b5101195502747769747465722e636f6d2f686572726d616e6e31303031"
|
||||||
],
|
],
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-d <hex> raw NDEF hex bytes",
|
"-d <hex> raw NDEF hex bytes",
|
||||||
"-f, --file <fn> write raw NDEF file to tag",
|
"-f, --file <fn> write raw NDEF file to tag",
|
||||||
|
"-p fix NDEF record headers / terminator block if missing",
|
||||||
"--mini MIFARE Classic Mini / S20",
|
"--mini MIFARE Classic Mini / S20",
|
||||||
"--1k MIFARE Classic 1k / S50 (def)",
|
"--1k MIFARE Classic 1k / S50 (def)",
|
||||||
"--2k MIFARE Classic/Plus 2k",
|
"--2k MIFARE Classic/Plus 2k",
|
||||||
"--4k MIFARE Classic 4k / S70"
|
"--4k MIFARE Classic 4k / S70",
|
||||||
|
"-v, --verbose verbose output"
|
||||||
],
|
],
|
||||||
"usage": "hf mf ndefwrite [-h] [-d <hex>] [-f <fn>] [--mini] [--1k] [--2k] [--4k]"
|
"usage": "hf mf ndefwrite [-hpv] [-d <hex>] [-f <fn>] [--mini] [--1k] [--2k] [--4k]"
|
||||||
},
|
},
|
||||||
"hf mf nested": {
|
"hf mf nested": {
|
||||||
"command": "hf mf nested",
|
"command": "hf mf nested",
|
||||||
|
@ -6112,9 +6117,10 @@
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-l Swap entered key's endianness",
|
"-l Swap entered key's endianness",
|
||||||
"-f, --file <fn> Save raw NDEF to file"
|
"-f, --file <fn> Save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf mfu ndefread [-hl] [-k Replace default key for NDEF] [-f <fn>]"
|
"usage": "hf mfu ndefread [-hlv] [-k Replace default key for NDEF] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"hf mfu otptear": {
|
"hf mfu otptear": {
|
||||||
"command": "hf mfu otptear",
|
"command": "hf mfu otptear",
|
||||||
|
@ -6454,9 +6460,10 @@
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-p, --pwd <hex> 16 byte read password",
|
"-p, --pwd <hex> 16 byte read password",
|
||||||
"-f, --file <fn> save raw NDEF to file"
|
"-f, --file <fn> save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf st25ta ndefread [-h] [-p <hex>] [-f <fn>]"
|
"usage": "hf st25ta ndefread [-hv] [-p <hex>] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"hf st25ta protect": {
|
"hf st25ta protect": {
|
||||||
"command": "hf st25ta protect",
|
"command": "hf st25ta protect",
|
||||||
|
@ -10632,9 +10639,10 @@
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-l Swap entered key's endianness",
|
"-l Swap entered key's endianness",
|
||||||
"-f, --file <fn> Save raw NDEF to file"
|
"-f, --file <fn> Save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf mfu ndefread [-hl] [-k Replace default key for NDEF] [-f <fn>]"
|
"usage": "hf mfu ndefread [-hlv] [-k Replace default key for NDEF] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"nfc type4a help": {
|
"nfc type4a help": {
|
||||||
"command": "nfc type4a help",
|
"command": "nfc type4a help",
|
||||||
|
@ -10654,9 +10662,10 @@
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-f, --file <fn> save raw NDEF to file"
|
"-f, --file <fn> save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf 14a ndefread [-h] [-f <fn>]"
|
"usage": "hf 14a ndefread [-hv] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"nfc type4a st25taread": {
|
"nfc type4a st25taread": {
|
||||||
"command": "nfc type4a st25taread",
|
"command": "nfc type4a st25taread",
|
||||||
|
@ -10669,9 +10678,10 @@
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-p, --pwd <hex> 16 byte read password",
|
"-p, --pwd <hex> 16 byte read password",
|
||||||
"-f, --file <fn> save raw NDEF to file"
|
"-f, --file <fn> save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf st25ta ndefread [-h] [-p <hex>] [-f <fn>]"
|
"usage": "hf st25ta ndefread [-hv] [-p <hex>] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"nfc type4b help": {
|
"nfc type4b help": {
|
||||||
"command": "nfc type4b help",
|
"command": "nfc type4b help",
|
||||||
|
@ -10691,9 +10701,10 @@
|
||||||
"offline": false,
|
"offline": false,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-f, --file <fn> save raw NDEF to file"
|
"-f, --file <fn> save raw NDEF to file",
|
||||||
|
"-v, --verbose show technical data"
|
||||||
],
|
],
|
||||||
"usage": "hf 14b ndefread [-h] [-f <fn>]"
|
"usage": "hf 14b ndefread [-hv] [-f <fn>]"
|
||||||
},
|
},
|
||||||
"prefs get barmode": {
|
"prefs get barmode": {
|
||||||
"command": "prefs get barmode",
|
"command": "prefs get barmode",
|
||||||
|
@ -11389,6 +11400,6 @@
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"commands_extracted": 721,
|
"commands_extracted": 721,
|
||||||
"extracted_by": "PM3Help2JSON v1.00",
|
"extracted_by": "PM3Help2JSON v1.00",
|
||||||
"extracted_on": "2022-10-20T15:33:35"
|
"extracted_on": "2022-10-23T00:39:16"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue