mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
hf 14b ndef - hooking up some steps
This commit is contained in:
parent
a14c7f90b2
commit
9140579735
1 changed files with 36 additions and 24 deletions
|
@ -1599,8 +1599,8 @@ static int CmdHF14BNdef(const char *Cmd) {
|
||||||
char c = tolower(param_getchar(Cmd, 0));
|
char c = tolower(param_getchar(Cmd, 0));
|
||||||
if (c == 'h' || c == 0x00) return usage_hf_14b_ndef();
|
if (c == 'h' || c == 0x00) return usage_hf_14b_ndef();
|
||||||
|
|
||||||
// bool activate_field = true;
|
bool activate_field = true;
|
||||||
// bool keep_field_on = true;
|
bool keep_field_on = true;
|
||||||
uint8_t response[PM3_CMD_DATA_SIZE];
|
uint8_t response[PM3_CMD_DATA_SIZE];
|
||||||
int resplen = 0;
|
int resplen = 0;
|
||||||
|
|
||||||
|
@ -1608,22 +1608,25 @@ static int CmdHF14BNdef(const char *Cmd) {
|
||||||
uint8_t aSELECT_AID[80];
|
uint8_t aSELECT_AID[80];
|
||||||
int aSELECT_AID_n = 0;
|
int aSELECT_AID_n = 0;
|
||||||
param_gethex_to_eol("00a4040007d276000085010100", 0, aSELECT_AID, sizeof(aSELECT_AID), &aSELECT_AID_n);
|
param_gethex_to_eol("00a4040007d276000085010100", 0, aSELECT_AID, sizeof(aSELECT_AID), &aSELECT_AID_n);
|
||||||
int res = 0;
|
int res = exchange_14b_apdu(aSELECT_AID, aSELECT_AID_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
||||||
// int res = ExchangeAPDU14a(aSELECT_AID, aSELECT_AID_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
if (res) {
|
||||||
if (res)
|
goto out;
|
||||||
return res;
|
}
|
||||||
|
|
||||||
if (resplen < 2)
|
if (resplen < 2) {
|
||||||
return PM3_ESOFT;
|
res = PM3_ESOFT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t sw = get_sw(response, resplen);
|
uint16_t sw = get_sw(response, resplen);
|
||||||
if (sw != 0x9000) {
|
if (sw != 0x9000) {
|
||||||
PrintAndLogEx(ERR, "Selecting NDEF aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(ERR, "Selecting NDEF aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
return PM3_ESOFT;
|
res = PM3_ESOFT;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// activate_field = false;
|
activate_field = false;
|
||||||
// keep_field_on = true;
|
keep_field_on = true;
|
||||||
// --------------- Send CC select ----------------
|
// --------------- Send CC select ----------------
|
||||||
// --------------- Read binary ----------------
|
// --------------- Read binary ----------------
|
||||||
|
|
||||||
|
@ -1631,48 +1634,57 @@ static int CmdHF14BNdef(const char *Cmd) {
|
||||||
uint8_t aSELECT_FILE_NDEF[30];
|
uint8_t aSELECT_FILE_NDEF[30];
|
||||||
int aSELECT_FILE_NDEF_n = 0;
|
int aSELECT_FILE_NDEF_n = 0;
|
||||||
param_gethex_to_eol("00a4000c020001", 0, aSELECT_FILE_NDEF, sizeof(aSELECT_FILE_NDEF), &aSELECT_FILE_NDEF_n);
|
param_gethex_to_eol("00a4000c020001", 0, aSELECT_FILE_NDEF, sizeof(aSELECT_FILE_NDEF), &aSELECT_FILE_NDEF_n);
|
||||||
// res = ExchangeAPDU14a(aSELECT_FILE_NDEF, aSELECT_FILE_NDEF_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
res = exchange_14b_apdu(aSELECT_FILE_NDEF, aSELECT_FILE_NDEF_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
goto out;
|
||||||
|
|
||||||
sw = get_sw(response, resplen);
|
sw = get_sw(response, resplen);
|
||||||
if (sw != 0x9000) {
|
if (sw != 0x9000) {
|
||||||
PrintAndLogEx(ERR, "Selecting NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(ERR, "Selecting NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
return PM3_ESOFT;
|
res = PM3_ESOFT;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------- Read binary ----------------
|
// --------------- Read binary ----------------
|
||||||
uint8_t aREAD_NDEF[30];
|
uint8_t aREAD_NDEF[30];
|
||||||
int aREAD_NDEF_n = 0;
|
int aREAD_NDEF_n = 0;
|
||||||
param_gethex_to_eol("00b0000002", 0, aREAD_NDEF, sizeof(aREAD_NDEF), &aREAD_NDEF_n);
|
param_gethex_to_eol("00b0000002", 0, aREAD_NDEF, sizeof(aREAD_NDEF), &aREAD_NDEF_n);
|
||||||
// res = ExchangeAPDU14a(aREAD_NDEF, aREAD_NDEF_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
res = exchange_14b_apdu(aREAD_NDEF, aREAD_NDEF_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
sw = get_sw(response, resplen);
|
sw = get_sw(response, resplen);
|
||||||
if (sw != 0x9000) {
|
if (sw != 0x9000) {
|
||||||
PrintAndLogEx(ERR, "reading NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(ERR, "reading NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
return PM3_ESOFT;
|
res = PM3_ESOFT;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
// take offset from response
|
// take offset from response
|
||||||
uint8_t offset = response[1];
|
uint8_t offset = response[1];
|
||||||
|
|
||||||
// --------------- Read binary w offset ----------------
|
// --------------- Read binary w offset ----------------
|
||||||
// keep_field_on = false;
|
keep_field_on = false;
|
||||||
aREAD_NDEF_n = 0;
|
aREAD_NDEF_n = 0;
|
||||||
param_gethex_to_eol("00b00002", 0, aREAD_NDEF, sizeof(aREAD_NDEF), &aREAD_NDEF_n);
|
param_gethex_to_eol("00b00002", 0, aREAD_NDEF, sizeof(aREAD_NDEF), &aREAD_NDEF_n);
|
||||||
aREAD_NDEF[4] = offset;
|
aREAD_NDEF[4] = offset;
|
||||||
// res = ExchangeAPDU14a(aREAD_NDEF, aREAD_NDEF_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
res = exchange_14b_apdu(aREAD_NDEF, aREAD_NDEF_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
sw = get_sw(response, resplen);
|
sw = get_sw(response, resplen);
|
||||||
if (sw != 0x9000) {
|
if (sw != 0x9000) {
|
||||||
PrintAndLogEx(ERR, "reading NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
PrintAndLogEx(ERR, "reading NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
|
||||||
return PM3_ESOFT;
|
res = PM3_ESOFT;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NDEFRecordsDecodeAndPrint(response + 2, resplen - 4);
|
res = NDEFRecordsDecodeAndPrint(response + 2, resplen - 4);
|
||||||
|
|
||||||
|
out:
|
||||||
|
switch_off_field_14b();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue