mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
added legic view command, and converted OLD -> NG comms
This commit is contained in:
@@ -3,6 +3,8 @@ 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...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Changed `hf legic *` - now uses NG instead (@iceman1001)
|
||||
- Added `hf legic view` - view contents of LEGIC Prime dump files (@iceman1001)
|
||||
- Changed `hf mfu restore` - now takes bin/json as dump files (@iceman1001)
|
||||
- Added `hf mfu view` - view contents of MFU dump files (@iceman1001)
|
||||
- Changed `hf_mf_uidbruteforce` - added support for S70, enhance UID length management (@cactuschibre)
|
||||
|
||||
+6
-5
@@ -1285,11 +1285,13 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
break;
|
||||
}
|
||||
case CMD_HF_LEGIC_WRITER: {
|
||||
LegicRfWriter(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes);
|
||||
legic_packet_t *payload = (legic_packet_t*) packet->data.asBytes;
|
||||
LegicRfWriter(payload->offset, payload->len, payload->iv, payload->data);
|
||||
break;
|
||||
}
|
||||
case CMD_HF_LEGIC_READER: {
|
||||
LegicRfReader(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2]);
|
||||
legic_packet_t *payload = (legic_packet_t*) packet->data.asBytes;
|
||||
LegicRfReader(payload->offset, payload->len, payload->iv);
|
||||
break;
|
||||
}
|
||||
case CMD_HF_LEGIC_INFO: {
|
||||
@@ -1302,10 +1304,9 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
// involved in dealing with emulator memory. But if it is called later, it might
|
||||
// destroy the Emulator Memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
// arg0 = offset
|
||||
// arg1 = num of bytes
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
emlSet(packet->data.asBytes, packet->oldarg[0], packet->oldarg[1]);
|
||||
legic_packet_t *payload = (legic_packet_t*) packet->data.asBytes;
|
||||
emlSet(payload->data, payload->offset, payload->len);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
+11
-11
@@ -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();
|
||||
|
||||
@@ -170,14 +170,9 @@ end
|
||||
-- read LEGIC data
|
||||
local function readlegicdata(offset, length, iv)
|
||||
-- Read data
|
||||
local command = Command:newMIX{
|
||||
cmd = cmds.CMD_HF_LEGIC_READER
|
||||
, arg1 = offset
|
||||
, arg2 = length
|
||||
, arg3 = iv
|
||||
, data = nil
|
||||
}
|
||||
local result, err = command:sendMIX()
|
||||
local d0 = ('%04X%04X%02X'):format(offset, len, iv)
|
||||
local c = Command:newNG{cmd = cmds.CMD_HF_LEGIC_READER, data = d0}
|
||||
local result, err = c:sendNG()
|
||||
if not result then return oops(err) end
|
||||
-- result is a packed data structure, data starts at offset 33
|
||||
return result
|
||||
|
||||
+228
-67
File diff suppressed because it is too large
Load Diff
@@ -1239,6 +1239,10 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||
JsonLoadBufAsHex(root, "$.raw", udata, maxdatalen, datalen);
|
||||
}
|
||||
|
||||
if (!strcmp(ctype, "legic")) {
|
||||
JsonLoadBufAsHex(root, "$.raw", udata, maxdatalen, datalen);
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
if (callback != NULL) {
|
||||
|
||||
+8
-1
@@ -30,7 +30,14 @@ typedef struct {
|
||||
uint8_t cmdsize;
|
||||
uint8_t addrsize;
|
||||
uint16_t cardsize;
|
||||
} legic_card_select_t;
|
||||
} PACKED legic_card_select_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t offset;
|
||||
uint16_t len;
|
||||
uint8_t iv;
|
||||
uint8_t data[];
|
||||
} PACKED legic_packet_t;
|
||||
|
||||
// iceman: todo : this should be packed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user