Merge pull request #1825 from natmchugh/master

Get the hitag2 dump command working as per docs
This commit is contained in:
Iceman 2022-12-04 13:45:57 +01:00 committed by GitHub
commit ce3ca0e7d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View file

@ -17,6 +17,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001) - Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001)
- Added `hf mf gload, gsave, ggetblk, gsetblk` for Gen4 GTU in mifare classic mode (@DidierA) - Added `hf mf gload, gsave, ggetblk, gsetblk` for Gen4 GTU in mifare classic mode (@DidierA)
- Fixed SPI flash overflow when loading dictionnaries into flash. Breaking change: added 1 more sector for Mifare - dictionnaries should be loaded again (@jmichelp) - Fixed SPI flash overflow when loading dictionnaries into flash. Breaking change: added 1 more sector for Mifare - dictionnaries should be loaded again (@jmichelp)
- Fixed `lf hitag dump` - Should now work as described in the command help (@natmchugh)
## [Radium.4.15864][2022-10-29] ## [Radium.4.15864][2022-10-29]
- Changed `lf indala sim` - now accepts fc / cn (@iceman1001) - Changed `lf indala sim` - now accepts fc / cn (@iceman1001)

View file

@ -844,15 +844,40 @@ static int CmdLFHitag2Dump(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
PrintAndLogEx(SUCCESS, "Dumping tag memory..."); hitag_function htf;
hitag_data htd;
memset(&htd, 0, sizeof(htd));
if (keylen == 6) {
htf = RHT2F_CRYPTO;
memcpy(htd.crypto.key, key, sizeof(htd.crypto.key));
PrintAndLogEx(INFO, "Authenticating in crypto mode");
} else {
htf = RHT2F_PASSWORD;
memcpy(htd.pwd.password, key, sizeof(htd.pwd.password));
PrintAndLogEx(INFO, "Authenticating in password mode");
}
uint16_t cmd = CMD_LF_HITAG_READER;
clearCommandBuffer(); clearCommandBuffer();
//SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd)); SendCommandMIX(cmd, htf, 0, 0, &htd, sizeof(htd));
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000) == false) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return PM3_ETIMEOUT;
}
if (resp.oldarg[0] == false) {
PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed");
return PM3_ESOFT;
}
uint8_t *data = resp.data.asBytes; uint8_t *data = resp.data.asBytes;
if (data == NULL) if (data == NULL)
return PM3_ESOFT; return PM3_ESOFT;
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
if (fnlen < 1) { if (fnlen < 1) {
char *fptr = filename; char *fptr = filename;
fptr += snprintf(filename, sizeof(filename), "lf-hitag-"); fptr += snprintf(filename, sizeof(filename), "lf-hitag-");