mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
added legic view command, and converted OLD -> NG comms
This commit is contained in:
parent
12695a984a
commit
63bc9b5eb2
7 changed files with 262 additions and 92 deletions
|
@ -422,7 +422,7 @@ void LegicRfInfo(void) {
|
|||
// establish shared secret and detect card type
|
||||
uint8_t card_type = setup_phase(0x01);
|
||||
if (init_card(card_type, &card) != PM3_SUCCESS) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_INFO, PM3_EINIT, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,7 @@ void LegicRfInfo(void) {
|
|||
for (uint8_t i = 0; i < sizeof(card.uid); ++i) {
|
||||
int16_t byte = read_byte(i, card.cmdsize);
|
||||
if (byte == -1) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_INFO, PM3_EFAILED, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
card.uid[i] = byte & 0xFF;
|
||||
|
@ -440,12 +440,12 @@ void LegicRfInfo(void) {
|
|||
int16_t mcc = read_byte(4, card.cmdsize);
|
||||
int16_t calc_mcc = CRC8Legic(card.uid, 4);
|
||||
if (mcc != calc_mcc) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_INFO, PM3_ESOFT, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
// OK
|
||||
reply_mix(CMD_ACK, 1, 0, 0, (uint8_t *)&card, sizeof(legic_card_select_t));
|
||||
reply_ng(CMD_HF_LEGIC_INFO, PM3_SUCCESS, (uint8_t *)&card, sizeof(legic_card_select_t));
|
||||
|
||||
OUT:
|
||||
switch_off();
|
||||
|
@ -497,7 +497,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
|||
// establish shared secret and detect card type
|
||||
uint8_t card_type = setup_phase(iv);
|
||||
if (init_card(card_type, &card) != PM3_SUCCESS) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_READER, PM3_EINIT, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
|||
for (uint16_t i = 0; i < len; ++i) {
|
||||
int16_t byte = read_byte(offset + i, card.cmdsize);
|
||||
if (byte == -1) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_READER, PM3_EFAILED, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
legic_mem[i] = byte;
|
||||
|
@ -520,7 +520,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
|||
}
|
||||
|
||||
// OK
|
||||
reply_mix(CMD_ACK, 1, len, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_READER, PM3_SUCCESS, (uint8_t*)&len, sizeof(len));
|
||||
|
||||
OUT:
|
||||
switch_off();
|
||||
|
@ -533,14 +533,14 @@ void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data) {
|
|||
|
||||
// uid is not writeable
|
||||
if (offset <= WRITE_LOWERLIMIT) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_WRITER, PM3_EINVARG, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
// establish shared secret and detect card type
|
||||
uint8_t card_type = setup_phase(iv);
|
||||
if (init_card(card_type, &card) != PM3_SUCCESS) {
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_WRITER, PM3_EINIT, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
@ -553,13 +553,13 @@ void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data) {
|
|||
while (len-- > 0 && BUTTON_PRESS() == false) {
|
||||
if (write_byte(len + offset, data[len], card.addrsize) == false) {
|
||||
Dbprintf("operation failed | %02X | %02X | %02X", len + offset, len, data[len]);
|
||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_WRITER, PM3_EFAILED, NULL, 0);
|
||||
goto OUT;
|
||||
}
|
||||
}
|
||||
|
||||
// OK
|
||||
reply_mix(CMD_ACK, 1, len, 0, 0, 0);
|
||||
reply_ng(CMD_HF_LEGIC_WRITER, PM3_SUCCESS, (uint8_t*)&len, sizeof(len));
|
||||
|
||||
OUT:
|
||||
switch_off();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue