partial fix of nfc-mfclassic which only writes first sector of each block and not sector 1,2,3 unles 'unlocked' write - debuggers still in!
This commit is contained in:
parent
4b7791f845
commit
a28a537610
1 changed files with 8 additions and 3 deletions
|
@ -426,7 +426,8 @@ write_card(int write_block_zero)
|
||||||
|
|
||||||
printf("Writing %d blocks |", uiBlocks + 1);
|
printf("Writing %d blocks |", uiBlocks + 1);
|
||||||
// Completely write the card, end to start, but skipping block 0
|
// Completely write the card, end to start, but skipping block 0
|
||||||
for (uiBlock = 4; uiBlock <= uiBlocks; uiBlock++) {
|
for (uiBlock = 0; uiBlock <= uiBlocks; uiBlock++) {
|
||||||
|
printf("{%d}",uiBlock);
|
||||||
// Authenticate everytime we reach the first sector of a new block
|
// Authenticate everytime we reach the first sector of a new block
|
||||||
if (is_first_block(uiBlock)) {
|
if (is_first_block(uiBlock)) {
|
||||||
if (bFailure) {
|
if (bFailure) {
|
||||||
|
@ -438,6 +439,7 @@ write_card(int write_block_zero)
|
||||||
bFailure = false;
|
bFailure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("[%d]",uiBlock);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
// Try to authenticate for the current sector
|
// Try to authenticate for the current sector
|
||||||
|
@ -450,8 +452,10 @@ write_card(int write_block_zero)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_trailer_block(uiBlock)) {
|
if (is_trailer_block(uiBlock)) {
|
||||||
|
printf("t");
|
||||||
if (bFormatCard) {
|
if (bFormatCard) {
|
||||||
// Copy the default key and reset the access bits
|
// Copy the default key and reset the access bits
|
||||||
memcpy(mp.mpt.abtKeyA, default_key, sizeof(mp.mpt.abtKeyA));
|
memcpy(mp.mpt.abtKeyA, default_key, sizeof(mp.mpt.abtKeyA));
|
||||||
|
@ -471,7 +475,7 @@ write_card(int write_block_zero)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The first block 0x00 is read only, skip this
|
// The first block 0x00 is read only, skip this
|
||||||
if (uiBlock == 0 && !write_block_zero && !magic2)
|
if (uiBlock == 0 && !write_block_zero && !magic2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Make sure a earlier write did not fail
|
// Make sure a earlier write did not fail
|
||||||
|
@ -482,6 +486,7 @@ write_card(int write_block_zero)
|
||||||
memset(mp.mpd.abtData, 0x00, sizeof(mp.mpd.abtData));
|
memset(mp.mpd.abtData, 0x00, sizeof(mp.mpd.abtData));
|
||||||
else
|
else
|
||||||
memcpy(mp.mpd.abtData, mtDump.amb[uiBlock].mbd.abtData, sizeof(mp.mpd.abtData));
|
memcpy(mp.mpd.abtData, mtDump.amb[uiBlock].mbd.abtData, sizeof(mp.mpd.abtData));
|
||||||
|
printf("(%d)%d",uiBlock,sizeof(mp.mpd.abtData));
|
||||||
// do not write a block 0 with incorrect BCC - card will be made invalid!
|
// do not write a block 0 with incorrect BCC - card will be made invalid!
|
||||||
if (uiBlock == 0) {
|
if (uiBlock == 0) {
|
||||||
if ((mp.mpd.abtData[0] ^ mp.mpd.abtData[1] ^ mp.mpd.abtData[2] ^ mp.mpd.abtData[3] ^ mp.mpd.abtData[4]) != 0x00 && !magic2) {
|
if ((mp.mpd.abtData[0] ^ mp.mpd.abtData[1] ^ mp.mpd.abtData[2] ^ mp.mpd.abtData[3] ^ mp.mpd.abtData[4]) != 0x00 && !magic2) {
|
||||||
|
@ -499,7 +504,7 @@ write_card(int write_block_zero)
|
||||||
printf("Failure during write process.\n");
|
printf("Failure during write process.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
// Show if the write went well for each block
|
// Show if the write went well for each block
|
||||||
print_success_or_failure(bFailure, &uiWriteBlocks);
|
print_success_or_failure(bFailure, &uiWriteBlocks);
|
||||||
if ((! bTolerateFailures) && bFailure)
|
if ((! bTolerateFailures) && bFailure)
|
||||||
|
|
Loading…
Reference in a new issue