Changed drastically Hitag S ARM code to remove state machines and ease way to build new commands, Fixed Hitag S crypto mode with key or NrAr, fixed lf hitag cc, fixed pwd dump in hitagS dump with LKP

This commit is contained in:
Philippe Teuwen 2022-01-02 01:02:08 +01:00
parent 3491157345
commit 0f9315391a
5 changed files with 452 additions and 977 deletions

View file

@ -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... 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] ## [unreleased][unreleased]
- Changed drastically Hitag S ARM code to remove state machines and ease way to build new commands (@doegox)
- Fixed Hitag S crypto mode with key or NrAr, fixed `lf hitag cc`, fixed pwd dump in hitagS dump with LKP (@doegox)
- Changed `trace list -h` - textual change (@iceman1001) - Changed `trace list -h` - textual change (@iceman1001)
- Fixed `hf iclass config` - not get stuck when trying to make a keyroll config card (@iceman1001) - Fixed `hf iclass config` - not get stuck when trying to make a keyroll config card (@iceman1001)
- Changed textual output for iclass (@iceman1001) - Changed textual output for iclass (@iceman1001)

View file

@ -1094,7 +1094,7 @@ static void PacketReceived(PacketCommandNG *packet) {
break; break;
} }
case CMD_LF_HITAGS_TEST_TRACES: { // Tests every challenge within the given file case CMD_LF_HITAGS_TEST_TRACES: { // Tests every challenge within the given file
check_challenges((bool)packet->oldarg[0], packet->data.asBytes, true); Hitag_check_challenges(packet->data.asBytes, packet->oldarg[0], true);
break; break;
} }
case CMD_LF_HITAGS_READ: { //Reader for only Hitag S tags, args = key or challenge case CMD_LF_HITAGS_READ: { //Reader for only Hitag S tags, args = key or challenge

File diff suppressed because it is too large Load diff

View file

@ -19,6 +19,5 @@
void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data, bool ledcontrol); void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data, bool ledcontrol);
void ReadHitagS(hitag_function htf, hitag_data *htd, bool ledcontrol); void ReadHitagS(hitag_function htf, hitag_data *htd, bool ledcontrol);
void WritePageHitagS(hitag_function htf, hitag_data *htd, int page, bool ledcontrol); void WritePageHitagS(hitag_function htf, hitag_data *htd, int page, bool ledcontrol);
void check_challenges(bool file_given, uint8_t *data, bool ledcontrol); void Hitag_check_challenges(uint8_t *data, uint32_t datalen, bool ledcontrol);
#endif #endif

View file

@ -576,8 +576,8 @@ static int CmdLFHitagReader(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
if (nalen != 0 && nalen != 6) { if (nalen != 0 && nalen != 8) {
PrintAndLogEx(WARNING, "Wrong NR/AR len expected 0 or 6, got %d", nalen); PrintAndLogEx(WARNING, "Wrong NR/AR len expected 0 or 8, got %d", nalen);
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -629,7 +629,6 @@ static int CmdLFHitagReader(const char *Cmd) {
PrintAndLogEx(WARNING, "timeout while waiting for reply."); PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
if (resp.oldarg[0] == false) { if (resp.oldarg[0] == false) {
PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed"); PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed");
return PM3_ESOFT; return PM3_ESOFT;
@ -658,7 +657,7 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_str0("f", "file", "<fn>", "filename to load ( w/o ext )"), arg_str1("f", "file", "<fn>", "filename to load ( w/o ext )"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -671,22 +670,18 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
if (fnlen > 0) { uint8_t *data = NULL;
uint8_t *data = NULL; size_t datalen = 0;
size_t datalen = 0; int res = loadFile_safe(filename, ".cc", (void **)&data, &datalen);
int res = loadFile_safe(filename, ".cc", (void **)&data, &datalen); if (res == PM3_SUCCESS) {
if (res == PM3_SUCCESS) { if (datalen % 8 == 0) {
if (datalen == (8 * 60)) { SendCommandMIX(CMD_LF_HITAGS_TEST_TRACES, datalen, 0, 0, data, datalen);
SendCommandOLD(CMD_LF_HITAGS_TEST_TRACES, 1, 0, 0, data, datalen); } else {
} else { PrintAndLogEx(ERR, "Error, file length mismatch. Expected multiple of 8, got %zu", datalen);
PrintAndLogEx(ERR, "Error, file length mismatch. Expected %d, got %zu", 8 * 60, datalen);
}
} }
if (data) { }
free(data); if (data) {
} free(data);
} else {
SendCommandMIX(CMD_LF_HITAGS_TEST_TRACES, 0, 0, 0, NULL, 0);
} }
return PM3_SUCCESS; return PM3_SUCCESS;