Skip to content

Commit

Permalink
Merge pull request #29 from RfidResearchGroup/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
mwalker33 committed Apr 5, 2020
2 parents c424a5f + 3464dc2 commit 108b426
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 295 deletions.
2 changes: 1 addition & 1 deletion armsrc/lfops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,7 @@ void SendForward(uint8_t fwd_bit_count) {
WaitUS(32 * 8);
} else {
TurnReadLF_off(23 * 8);
TurnReadLFOn(32-23 * 8);
TurnReadLFOn((32-23) * 8);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/cmdhf.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int CmdHFSearch(const char *Cmd) {
PrintAndLogEx(INPLACE, "Searching for LEGIC tag...");
if (IfPm3Legicrf()) {
if (readLegicUid(false) == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("LEGIC tag") "found\n");
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("LEGIC Prime tag") "found\n");
res = PM3_SUCCESS;
}
}
Expand Down
39 changes: 19 additions & 20 deletions client/cmdhflegic.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int usage_legic_dump(void) {
PrintAndLogEx(NORMAL, " x : deobfuscate dump data (xor with MCC)");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic dump -- uses UID as filename"));
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic dump - uses UID as filename"));
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic dump f myfile"));
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic dump x"));
return PM3_SUCCESS;
Expand Down Expand Up @@ -154,7 +154,7 @@ static int usage_legic_esave(void) {
PrintAndLogEx(NORMAL, " f <filename> : filename w/o .bin to load");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic esave 2 -- uses UID as filename"));
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic esave 2 - uses UID as filename"));
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic esave 2 f myfile"));
return PM3_SUCCESS;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ static int CmdLegicInfo(const char *Cmd) {
return PM3_ESOFT;
}

PrintAndLogEx(SUCCESS, "Reading full tag memory of %d bytes...", card.cardsize);
PrintAndLogEx(SUCCESS, "Reading full tag memory of " _YELLOW_("%d") "bytes...", card.cardsize);

// allocate receiver buffer
uint8_t *data = calloc(card.cardsize, sizeof(uint8_t));
Expand All @@ -235,15 +235,13 @@ static int CmdLegicInfo(const char *Cmd) {

// Output CDF System area (9 bytes) plus remaining header area (12 bytes)
crc = data[4];
uint32_t calc_crc = CRC8Legic(data, 4);
uint32_t calc_crc = CRC8Legic(data, 4);

PrintAndLogEx(SUCCESS, _YELLOW_("CDF: System Area"));
PrintAndLogEx(SUCCESS, " " _CYAN_("CDF: System Area"));
PrintAndLogEx(NORMAL, "------------------------------------------------------");
PrintAndLogEx(NORMAL, "MCD: %02x, MSN: %02x %02x %02x, MCC: %02x %s",
PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s)",
data[0],
data[1],
data[2],
data[3],
sprint_hex(data +1, 3),
data[4],
(calc_crc == crc) ? _GREEN_("OK") : _RED_("Fail")
);
Expand Down Expand Up @@ -350,7 +348,7 @@ static int CmdLegicInfo(const char *Cmd) {
if (dcf > 60000)
goto out;

PrintAndLogEx(SUCCESS, _YELLOW_("\nADF: User Area"));
PrintAndLogEx(SUCCESS, _CYAN_("ADF: User Area"));
PrintAndLogEx(NORMAL, "------------------------------------------------------");

if (bIsSegmented) {
Expand Down Expand Up @@ -383,7 +381,7 @@ static int CmdLegicInfo(const char *Cmd) {
segCalcCRC = CRC8Legic(segCrcBytes, 8);
segCRC = data[i + 4] ^ crc;

PrintAndLogEx(SUCCESS, "Segment | %02u ", segmentNum);
PrintAndLogEx(SUCCESS, "Segment | " _YELLOW_("%02u"), segmentNum);
PrintAndLogEx(SUCCESS, "raw header | 0x%02X 0x%02X 0x%02X 0x%02X",
data[i] ^ crc,
data[i + 1] ^ crc,
Expand All @@ -396,7 +394,7 @@ static int CmdLegicInfo(const char *Cmd) {
(segment_flag & 0x4) >> 2,
(segment_flag & 0x8) >> 3
);
PrintAndLogEx(SUCCESS, " | WRP: %02u, WRC: %02u, RD: %01u, CRC: 0x%02X (%s)",
PrintAndLogEx(SUCCESS, " | WRP: %02u, WRC: %02u, RD: %01u, CRC: 0x%02X ( %s)",
wrp,
wrc,
((data[i + 3] ^ crc) & 0x80) >> 7,
Expand Down Expand Up @@ -821,16 +819,16 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
PacketResponseNG resp;

uint8_t timeout = 0;
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
while (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
++timeout;
printf(".");
fflush(stdout);
if (timeout > 7) {
if (timeout > 14) {
PrintAndLogEx(WARNING, "\ncommand execution time out");
return PM3_ETIMEOUT;
}
}
PrintAndLogEx(NORMAL, "\n");
PrintAndLogEx(NORMAL, "");

uint8_t isOK = resp.oldarg[0] & 0xFF;
*outlen = resp.oldarg[1];
Expand All @@ -856,13 +854,13 @@ int legic_print_type(uint32_t tagtype, uint8_t spaces) {
char *spacer = spc + (10 - spaces);

if (tagtype == 22)
PrintAndLogEx(SUCCESS, "%sTYPE : MIM%d card (outdated)", spacer, tagtype);
PrintAndLogEx(SUCCESS, "%sTYPE: " _YELLOW_("MIM%d card (outdated)"), spacer, tagtype);
else if (tagtype == 256)
PrintAndLogEx(SUCCESS, "%sTYPE : MIM%d card (234 bytes)", spacer, tagtype);
PrintAndLogEx(SUCCESS, "%sTYPE: " _YELLOW_("MIM%d card (234 bytes)"), spacer, tagtype);
else if (tagtype == 1024)
PrintAndLogEx(SUCCESS, "%sTYPE : MIM%d card (1002 bytes)", spacer, tagtype);
PrintAndLogEx(SUCCESS, "%sTYPE: " _YELLOW_("MIM%d card (1002 bytes)"), spacer, tagtype);
else
PrintAndLogEx(INFO, "%sTYPE : Unknown %06x", spacer, tagtype);
PrintAndLogEx(INFO, "%sTYPE: " _YELLOW_("Unknown %06x"), spacer, tagtype);
return PM3_SUCCESS;
}
int legic_get_type(legic_card_select_t *card) {
Expand Down Expand Up @@ -1393,7 +1391,8 @@ int readLegicUid(bool verbose) {
break;
}
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, " UID : %s", sprint_hex(card.uid, sizeof(card.uid)));
PrintAndLogEx(SUCCESS, " MCD: " _GREEN_("%02X"), card.uid[0]);
PrintAndLogEx(SUCCESS, " MSN: " _GREEN_("%s"), sprint_hex(card.uid + 1, sizeof(card.uid) - 1));
legic_print_type(card.cardsize, 0);
return PM3_SUCCESS;
}
Loading

0 comments on commit 108b426

Please sign in to comment.