mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-20 20:18:17 +08:00
fix: 'hf 15 dump' the crc now calcs over the right number of bytes in order to be compared with the check
This commit is contained in:
parent
d894e36b95
commit
c8f087eeb9
1 changed files with 49 additions and 42 deletions
|
@ -298,7 +298,7 @@ int usage_15_reader(void){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int usage_15_sim(void){
|
int usage_15_sim(void){
|
||||||
PrintAndLog("Usage: hf 15 sim <UID>");
|
PrintAndLog("usage: hf 15 sim <UID>");
|
||||||
PrintAndLog("");
|
PrintAndLog("");
|
||||||
PrintAndLog("sample:");
|
PrintAndLog("sample:");
|
||||||
PrintAndLog(" hf 15 sim E016240000000000");
|
PrintAndLog(" hf 15 sim E016240000000000");
|
||||||
|
@ -308,7 +308,16 @@ int usage_15_findafi(void){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int usage_15_dump(void){
|
int usage_15_dump(void){
|
||||||
PrintAndLog("'hf 15 dump' needs a helptext..");
|
PrintAndLog("This command dumps the contents of a ISO-15693 tag and save it to file");
|
||||||
|
PrintAndLog("");
|
||||||
|
PrintAndLog("usage: hf 15 dump [h] <f filname> ");
|
||||||
|
PrintAndLog("options:");
|
||||||
|
PrintAndLog(" h this help");
|
||||||
|
PrintAndLog(" f <name> filename, if no <name> UID will be used as filename");
|
||||||
|
PrintAndLog("");
|
||||||
|
PrintAndLog("sample:");
|
||||||
|
PrintAndLog(" hf 15 dump f");
|
||||||
|
PrintAndLog(" hf 15 dump f mydump");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int usage_15_restore(void){
|
int usage_15_restore(void){
|
||||||
|
@ -636,12 +645,7 @@ int CmdHF15Dump(const char*Cmd) {
|
||||||
char * fptr = filename;
|
char * fptr = filename;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
|
|
||||||
uint8_t uid[8] = {0,0,0,0,0,0,0,0};
|
uint8_t uid[8] = {0,0,0,0,0,0,0,0};
|
||||||
if (!getUID(uid)) {
|
|
||||||
PrintAndLog("No tag found.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
switch(param_getchar(Cmd, cmdp)) {
|
switch(param_getchar(Cmd, cmdp)) {
|
||||||
|
@ -651,15 +655,6 @@ int CmdHF15Dump(const char*Cmd) {
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'F':
|
case 'F':
|
||||||
fileNameLen = param_getstr(Cmd, cmdp+1, filename, FILE_PATH_SIZE);
|
fileNameLen = param_getstr(Cmd, cmdp+1, filename, FILE_PATH_SIZE);
|
||||||
if (fileNameLen < 1) {
|
|
||||||
PrintAndLog("Using UID as filename");
|
|
||||||
|
|
||||||
fptr += sprintf(fptr, "dump15_");
|
|
||||||
|
|
||||||
for (int j = sizeof(uid)-1; j >=0 ; j--) {
|
|
||||||
fptr += sprintf(fptr, "%02X", uid[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdp += 2;
|
cmdp += 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -668,9 +663,24 @@ int CmdHF15Dump(const char*Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Validations
|
//Validations
|
||||||
if (errors) return usage_15_dump();
|
if (errors) return usage_15_dump();
|
||||||
|
|
||||||
|
if (fileNameLen < 1) {
|
||||||
|
|
||||||
|
PrintAndLog("Using UID as filename");
|
||||||
|
|
||||||
|
if (!getUID(uid)) {
|
||||||
|
PrintAndLog("No tag found.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fptr += sprintf(fptr, "dump15_");
|
||||||
|
|
||||||
|
for (int j = sizeof(uid)-1; j >=0 ; j--)
|
||||||
|
fptr += sprintf(fptr, "%02X", uid[j]);
|
||||||
|
}
|
||||||
// detect blocksize from card :)
|
// detect blocksize from card :)
|
||||||
|
|
||||||
PrintAndLog("Reading memory from tag UID %s", sprintUID(NULL, uid));
|
PrintAndLog("Reading memory from tag UID %s", sprintUID(NULL, uid));
|
||||||
|
@ -712,26 +722,24 @@ int CmdHF15Dump(const char*Cmd) {
|
||||||
|
|
||||||
recv = resp.d.asBytes;
|
recv = resp.d.asBytes;
|
||||||
|
|
||||||
if ( ISO15_CRC_CHECK == Crc(recv, len-2) ) {
|
if ( ISO15_CRC_CHECK != Crc(recv, len) ) {
|
||||||
|
PrintAndLog("crc fail");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(recv[0] & ISO15_RES_ERROR)) {
|
if (recv[0] & ISO15_RES_ERROR) {
|
||||||
|
PrintAndLog("\nTag returned Error %i: %s", recv[1], TagErrorStr(recv[1]) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
mem[blocknum].lock = resp.d.asBytes[0];
|
mem[blocknum].lock = resp.d.asBytes[0];
|
||||||
memcpy(mem[blocknum].block, resp.d.asBytes + 1, 4);
|
memcpy(mem[blocknum].block, resp.d.asBytes + 1, 4);
|
||||||
|
|
||||||
memcpy(data + (blocknum * 4), resp.d.asBytes + 1, 4);
|
memcpy(data + (blocknum * 4), resp.d.asBytes + 1, 4);
|
||||||
|
|
||||||
retry = 0;
|
retry = 0;
|
||||||
blocknum++;
|
blocknum++;
|
||||||
|
|
||||||
printf("."); fflush(stdout);
|
printf("."); fflush(stdout);
|
||||||
} else {
|
|
||||||
PrintAndLog("\nTag returned Error %i: %s", recv[1], TagErrorStr(recv[1]) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PrintAndLog("crc fail");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -741,10 +749,9 @@ int CmdHF15Dump(const char*Cmd) {
|
||||||
for (int i = 0; i < blocknum; i++) {
|
for (int i = 0; i < blocknum; i++) {
|
||||||
PrintAndLog("%3d/0x%02X | %s | %d | %s", i, i, sprint_hex(mem[i].block, 4 ), mem[i].lock, sprint_ascii(mem[i].block, 4) );
|
PrintAndLog("%3d/0x%02X | %s | %d | %s", i, i, sprint_hex(mem[i].block, 4 ), mem[i].lock, sprint_ascii(mem[i].block, 4) );
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
size_t datalen = blocknum*4;
|
size_t datalen = blocknum * 4;
|
||||||
saveFileEML(filename, "eml", data, datalen, 4);
|
saveFileEML(filename, "eml", data, datalen, 4);
|
||||||
saveFile(filename, "bin", data, datalen);
|
saveFile(filename, "bin", data, datalen);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -996,7 +1003,7 @@ int CmdHF15Readmulti(const char *Cmd) {
|
||||||
|
|
||||||
recv = resp.d.asBytes;
|
recv = resp.d.asBytes;
|
||||||
|
|
||||||
if (ISO15_CRC_CHECK == Crc(recv, status-2)) {
|
if (ISO15_CRC_CHECK == Crc(recv, status)) {
|
||||||
PrintAndLog("CRC failed");
|
PrintAndLog("CRC failed");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1083,7 @@ int CmdHF15Read(const char *Cmd) {
|
||||||
|
|
||||||
recv = resp.d.asBytes;
|
recv = resp.d.asBytes;
|
||||||
|
|
||||||
if (ISO15_CRC_CHECK == Crc(recv, status-2)) {
|
if (ISO15_CRC_CHECK == Crc(recv, status)) {
|
||||||
PrintAndLog("CRC failed");
|
PrintAndLog("CRC failed");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1167,7 @@ int CmdHF15Write(const char *Cmd) {
|
||||||
|
|
||||||
recv = resp.d.asBytes;
|
recv = resp.d.asBytes;
|
||||||
|
|
||||||
if (ISO15_CRC_CHECK == Crc(recv, status-2)) {
|
if (ISO15_CRC_CHECK == Crc(recv, status)) {
|
||||||
PrintAndLog("CRC failed");
|
PrintAndLog("CRC failed");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue