Remove ecp argument from commands

This commit is contained in:
kormax 2025-04-10 08:17:45 +03:00
commit eb2324ed93
3 changed files with 12 additions and 51 deletions

View file

@ -78,12 +78,6 @@ static const iso14a_polling_frame_t MAGWUPA4_FRAME = {
{ 0x7D }, 1, 7, 0 { 0x7D }, 1, 7, 0
}; };
static const iso14a_polling_frame_t ECP_FRAME = {
.frame = { 0x6a, 0x02, 0xC8, 0x01, 0x00, 0x03, 0x00, 0x02, 0x79, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xD8},
.frame_length = 15,
.last_byte_bits = 8,
.extra_delay = 0
};
// based on ISO/IEC JTC1/SC17 STANDING DOCUMENT 5 (Updated 20 September 2024) Register of IC manufacturers // based on ISO/IEC JTC1/SC17 STANDING DOCUMENT 5 (Updated 20 September 2024) Register of IC manufacturers
@ -595,24 +589,8 @@ int Hf14443_4aGetCardData(iso14a_card_select_t *card) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
iso14a_polling_parameters_t iso14a_get_polling_parameters(bool use_ecp, bool use_magsafe) { iso14a_polling_parameters_t iso14a_get_polling_parameters(bool use_magsafe) {
// Extra 100ms give enough time for Apple (ECP) devices to proccess field info and make a decision if (use_magsafe) {
if (use_ecp && use_magsafe) {
iso14a_polling_parameters_t full_polling_parameters = {
.frames = { WUPA_FRAME, ECP_FRAME, MAGWUPA1_FRAME, MAGWUPA2_FRAME, MAGWUPA3_FRAME, MAGWUPA4_FRAME },
.frame_count = 6,
.extra_timeout = 100
};
return full_polling_parameters;
} else if (use_ecp) {
iso14a_polling_parameters_t ecp_polling_parameters = {
.frames = { WUPA_FRAME, ECP_FRAME },
.frame_count = 2,
.extra_timeout = 100
};
return ecp_polling_parameters;
} else if (use_magsafe) {
iso14a_polling_parameters_t magsafe_polling_parameters = { iso14a_polling_parameters_t magsafe_polling_parameters = {
.frames = { WUPA_FRAME, MAGWUPA1_FRAME, MAGWUPA2_FRAME, MAGWUPA3_FRAME, MAGWUPA4_FRAME }, .frames = { WUPA_FRAME, MAGWUPA1_FRAME, MAGWUPA2_FRAME, MAGWUPA3_FRAME, MAGWUPA4_FRAME },
.frame_count = 5, .frame_count = 5,
@ -635,7 +613,6 @@ static int CmdHF14AReader(const char *Cmd) {
"Act as a ISO-14443a reader to identify tag. Look for ISO-14443a tags until Enter or the pm3 button is pressed", "Act as a ISO-14443a reader to identify tag. Look for ISO-14443a tags until Enter or the pm3 button is pressed",
"hf 14a reader\n" "hf 14a reader\n"
"hf 14a reader -@ -> Continuous mode\n" "hf 14a reader -@ -> Continuous mode\n"
"hf 14a reader --ecp -> trigger apple enhanced contactless polling\n"
"hf 14a reader --mag -> trigger apple magsafe polling\n" "hf 14a reader --mag -> trigger apple magsafe polling\n"
); );
@ -645,7 +622,6 @@ static int CmdHF14AReader(const char *Cmd) {
arg_lit0("s", "silent", "silent (no messages)"), arg_lit0("s", "silent", "silent (no messages)"),
arg_lit0(NULL, "drop", "just drop the signal field"), arg_lit0(NULL, "drop", "just drop the signal field"),
arg_lit0(NULL, "skip", "ISO14443-3 select only (skip RATS)"), arg_lit0(NULL, "skip", "ISO14443-3 select only (skip RATS)"),
arg_lit0(NULL, "ecp", "Use enhanced contactless polling"),
arg_lit0(NULL, "mag", "Use Apple magsafe polling"), arg_lit0(NULL, "mag", "Use Apple magsafe polling"),
arg_lit0("@", NULL, "continuous reader mode"), arg_lit0("@", NULL, "continuous reader mode"),
arg_lit0("w", "wait", "wait for card"), arg_lit0("w", "wait", "wait for card"),
@ -669,12 +645,11 @@ static int CmdHF14AReader(const char *Cmd) {
cm |= ISO14A_NO_RATS; cm |= ISO14A_NO_RATS;
} }
bool use_ecp = arg_get_lit(ctx, 5); bool use_magsafe = arg_get_lit(ctx, 5);
bool use_magsafe = arg_get_lit(ctx, 6);
iso14a_polling_parameters_t *polling_parameters = NULL; iso14a_polling_parameters_t *polling_parameters = NULL;
iso14a_polling_parameters_t parameters = iso14a_get_polling_parameters(use_ecp, use_magsafe); iso14a_polling_parameters_t parameters = iso14a_get_polling_parameters(use_magsafe);
if (use_ecp || use_magsafe) { if (use_magsafe) {
cm |= ISO14A_USE_CUSTOM_POLLING; cm |= ISO14A_USE_CUSTOM_POLLING;
polling_parameters = &parameters; polling_parameters = &parameters;
} }
@ -1546,7 +1521,6 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
"Sends raw bytes over ISO14443a. With option to use TOPAZ 14a mode.", "Sends raw bytes over ISO14443a. With option to use TOPAZ 14a mode.",
"hf 14a raw -sc 3000 -> select, crc, where 3000 == 'read block 00'\n" "hf 14a raw -sc 3000 -> select, crc, where 3000 == 'read block 00'\n"
"hf 14a raw -ak -b 7 40 -> send 7 bit byte 0x40\n" "hf 14a raw -ak -b 7 40 -> send 7 bit byte 0x40\n"
"hf 14a raw --ecp -s -> send ECP before select\n"
"Crypto1 session example, with special auth shortcut 6xxx<key>:\n" "Crypto1 session example, with special auth shortcut 6xxx<key>:\n"
"hf 14a raw --crypto1 -skc 6000FFFFFFFFFFFF\n" "hf 14a raw --crypto1 -skc 6000FFFFFFFFFFFF\n"
"hf 14a raw --crypto1 -kc 3000\n" "hf 14a raw --crypto1 -kc 3000\n"
@ -1565,7 +1539,6 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
arg_int0("t", "timeout", "<ms>", "Timeout in milliseconds"), arg_int0("t", "timeout", "<ms>", "Timeout in milliseconds"),
arg_int0("b", NULL, "<dec>", "Number of bits to send. Useful for send partial byte"), arg_int0("b", NULL, "<dec>", "Number of bits to send. Useful for send partial byte"),
arg_lit0("v", "verbose", "Verbose output"), arg_lit0("v", "verbose", "Verbose output"),
arg_lit0(NULL, "ecp", "Use enhanced contactless polling"),
arg_lit0(NULL, "mag", "Use Apple magsafe polling"), arg_lit0(NULL, "mag", "Use Apple magsafe polling"),
arg_lit0(NULL, "topaz", "Use Topaz protocol to send command"), arg_lit0(NULL, "topaz", "Use Topaz protocol to send command"),
arg_lit0(NULL, "crypto1", "Use crypto1 session"), arg_lit0(NULL, "crypto1", "Use crypto1 session"),
@ -1583,10 +1556,9 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
uint32_t timeout = (uint32_t)arg_get_int_def(ctx, 7, 0); uint32_t timeout = (uint32_t)arg_get_int_def(ctx, 7, 0);
uint16_t numbits = (uint16_t)arg_get_int_def(ctx, 8, 0); uint16_t numbits = (uint16_t)arg_get_int_def(ctx, 8, 0);
bool verbose = arg_get_lit(ctx, 9); bool verbose = arg_get_lit(ctx, 9);
bool use_ecp = arg_get_lit(ctx, 10); bool use_magsafe = arg_get_lit(ctx, 10);
bool use_magsafe = arg_get_lit(ctx, 11); bool topazmode = arg_get_lit(ctx, 11);
bool topazmode = arg_get_lit(ctx, 12); bool crypto1mode = arg_get_lit(ctx, 12);
bool crypto1mode = arg_get_lit(ctx, 13);
int datalen = 0; int datalen = 0;
uint8_t data[PM3_CMD_DATA_SIZE_MIX] = {0}; uint8_t data[PM3_CMD_DATA_SIZE_MIX] = {0};
@ -1646,7 +1618,7 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
if (crypto1mode) { if (crypto1mode) {
flags |= ISO14A_CRYPTO1MODE; flags |= ISO14A_CRYPTO1MODE;
if (numbits > 0 || topazmode || use_ecp || use_magsafe) { if (numbits > 0 || topazmode || use_magsafe) {
PrintAndLogEx(FAILED, "crypto1 mode cannot be used with other modes or partial bytes"); PrintAndLogEx(FAILED, "crypto1 mode cannot be used with other modes or partial bytes");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -1656,13 +1628,6 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
flags |= ISO14A_NO_RATS; flags |= ISO14A_NO_RATS;
} }
// TODO: allow to use reader command with both data and polling configuration
if (use_ecp || use_magsafe) {
PrintAndLogEx(WARNING, "ECP and Magsafe not supported with this command at this moment. Instead use 'hf 14a reader -sk --ecp/--mag'");
// flags |= ISO14A_USE_MAGSAFE;
// flags |= ISO14A_USE_ECP;
}
// Max buffer is PM3_CMD_DATA_SIZE_MIX // Max buffer is PM3_CMD_DATA_SIZE_MIX
datalen = (datalen > PM3_CMD_DATA_SIZE_MIX) ? PM3_CMD_DATA_SIZE_MIX : datalen; datalen = (datalen > PM3_CMD_DATA_SIZE_MIX) ? PM3_CMD_DATA_SIZE_MIX : datalen;

View file

@ -70,7 +70,7 @@ int Hf14443_4aGetCardData(iso14a_card_select_t *card);
int ExchangeAPDU14a(const uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen); int ExchangeAPDU14a(const uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, bool silentMode); int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, bool silentMode);
iso14a_polling_parameters_t iso14a_get_polling_parameters(bool use_ecp, bool use_magsafe); iso14a_polling_parameters_t iso14a_get_polling_parameters(bool use_magsafe);
int SelectCard14443A_4(bool disconnect, bool verbose, iso14a_card_select_t *card); int SelectCard14443A_4(bool disconnect, bool verbose, iso14a_card_select_t *card);
int SelectCard14443A_4_WithParameters(bool disconnect, bool verbose, iso14a_card_select_t *card, iso14a_polling_parameters_t *polling_parameters); int SelectCard14443A_4_WithParameters(bool disconnect, bool verbose, iso14a_card_select_t *card, iso14a_polling_parameters_t *polling_parameters);

View file

@ -1324,7 +1324,6 @@
"notes": [ "notes": [
"hf 14a raw -sc 3000 -> select, crc, where 3000 == 'read block 00'", "hf 14a raw -sc 3000 -> select, crc, where 3000 == 'read block 00'",
"hf 14a raw -ak -b 7 40 -> send 7 bit byte 0x40", "hf 14a raw -ak -b 7 40 -> send 7 bit byte 0x40",
"hf 14a raw --ecp -s -> send ECP before select",
"Crypto1 session example, with special auth shortcut 6xxx<key>:", "Crypto1 session example, with special auth shortcut 6xxx<key>:",
"hf 14a raw --crypto1 -skc 6000FFFFFFFFFFFF", "hf 14a raw --crypto1 -skc 6000FFFFFFFFFFFF",
"hf 14a raw --crypto1 -kc 3000", "hf 14a raw --crypto1 -kc 3000",
@ -1343,13 +1342,12 @@
"-t, --timeout <ms> Timeout in milliseconds", "-t, --timeout <ms> Timeout in milliseconds",
"-b <dec> Number of bits to send. Useful for send partial byte", "-b <dec> Number of bits to send. Useful for send partial byte",
"-v, --verbose Verbose output", "-v, --verbose Verbose output",
"--ecp Use enhanced contactless polling",
"--mag Use Apple magsafe polling", "--mag Use Apple magsafe polling",
"--topaz Use Topaz protocol to send command", "--topaz Use Topaz protocol to send command",
"--crypto1 Use crypto1 session", "--crypto1 Use crypto1 session",
"<hex> Raw bytes to send" "<hex> Raw bytes to send"
], ],
"usage": "hf 14a raw [-hack3rsv] [-t <ms>] [-b <dec>] [--ecp] [--mag] [--topaz] [--crypto1] <hex> [<hex>]..." "usage": "hf 14a raw [-hack3rsv] [-t <ms>] [-b <dec>] [--mag] [--topaz] [--crypto1] <hex> [<hex>]..."
}, },
"hf 14a reader": { "hf 14a reader": {
"command": "hf 14a reader", "command": "hf 14a reader",
@ -1357,7 +1355,6 @@
"notes": [ "notes": [
"hf 14a reader", "hf 14a reader",
"hf 14a reader -@ -> Continuous mode", "hf 14a reader -@ -> Continuous mode",
"hf 14a reader --ecp -> trigger apple enhanced contactless polling",
"hf 14a reader --mag -> trigger apple magsafe polling" "hf 14a reader --mag -> trigger apple magsafe polling"
], ],
"offline": false, "offline": false,
@ -1367,12 +1364,11 @@
"-s, --silent silent (no messages)", "-s, --silent silent (no messages)",
"--drop just drop the signal field", "--drop just drop the signal field",
"--skip ISO14443-3 select only (skip RATS)", "--skip ISO14443-3 select only (skip RATS)",
"--ecp Use enhanced contactless polling",
"--mag Use Apple magsafe polling", "--mag Use Apple magsafe polling",
"-@ continuous reader mode", "-@ continuous reader mode",
"-w, --wait wait for card" "-w, --wait wait for card"
], ],
"usage": "hf 14a reader [-hks@w] [--drop] [--skip] [--ecp] [--mag]" "usage": "hf 14a reader [-hks@w] [--drop] [--skip] [--mag]"
}, },
"hf 14a sim": { "hf 14a sim": {
"command": "hf 14a sim", "command": "hf 14a sim",