Comments (4)
Hi,
I encountered the same error.
I don't know why this happens but I do know what happens and how you can circumvent it:
Have a look at the following code (and ignore the printf statements I jammed in there for debugging):
file: src/mfoc.c
// Try A key, auth() + read()
memcpy(mp.mpa.abtKey, t.sectors[i].KeyA, sizeof(t.sectors[i].KeyA));
int res;
fprintf(stdout, "Trying key A\n");
if ((res = nfc_initiator_mifare_cmd(r.pdi, MC_AUTH_A, block, &mp)) < 0) {
fprintf(stdout, "authfail\n");
if (res != NFC_EMFCAUTHFAIL) {
nfc_perror(r.pdi, "nfc_initiator_mifare_cmd");
goto error;
}
mf_configure(r.pdi);
mf_anticollision(t, r);
} else { // and Read
fprintf(stdout, "and read\n");
if ((res = nfc_initiator_mifare_cmd(r.pdi, MC_READ, block, &mp)) >= 0) {
fprintf(stdout, "read A ok\n");
fprintf(stdout, "Block %02d, type %c, key %012llx :", block, 'A', bytes_to_num(t.sectors[i].KeyA, 6));
print_hex(mp.mpd.abtData, 16);
mf_configure(r.pdi);
mf_select_tag(r.pdi, &(t.nt));
failure = false;
} else {
fprintf(stdout, "read A failed with err %d\n", res);
// Error, now try read() with B key
if (res != NFC_ERFTRANS) {
nfc_perror(r.pdi, "nfc_initiator_mifare_cmd");
//goto error; <------ COMMENT THIS LINE <------------
}
mf_configure(r.pdi);
mf_anticollision(t, r);
memcpy(mp.mpa.abtKey, t.sectors[i].KeyB, sizeof(t.sectors[i].KeyB));
fprintf(stdout, "Trying key B\n");
Basically it first attempts to authenticate with KEY A. which succeeds, it then tries to read with KEY A. Which fails with an AUTH error.
For some odd reason it does not fail with an auth error in the first check. Which trips up the application because it does not expect an auth error after that point.
Because of this it does not try with KEY B, which would have worked.
The solution that worked for me was to simply comment out the goto error;
, recompile, and everything worked perfectly.
Hope this helps someone else
from mfoc.
It's no odd because KEY A has no read right.
ACs bits are 4b 44 bb, so it behaves correctly. KEYA can auth but will not read the block 12/13.
from mfoc.
Regardless. It makes no sense that the tool just errors out and quits instead of trying the second key, which would just work... This fixes that.
from mfoc.
Hi,
I encountered the same error. I don't know why this happens but I do know what happens and how you can circumvent it:
Have a look at the following code (and ignore the printf statements I jammed in there for debugging): file: src/mfoc.c
// Try A key, auth() + read() memcpy(mp.mpa.abtKey, t.sectors[i].KeyA, sizeof(t.sectors[i].KeyA)); int res; fprintf(stdout, "Trying key A\n"); if ((res = nfc_initiator_mifare_cmd(r.pdi, MC_AUTH_A, block, &mp)) < 0) { fprintf(stdout, "authfail\n"); if (res != NFC_EMFCAUTHFAIL) { nfc_perror(r.pdi, "nfc_initiator_mifare_cmd"); goto error; } mf_configure(r.pdi); mf_anticollision(t, r); } else { // and Read fprintf(stdout, "and read\n"); if ((res = nfc_initiator_mifare_cmd(r.pdi, MC_READ, block, &mp)) >= 0) { fprintf(stdout, "read A ok\n"); fprintf(stdout, "Block %02d, type %c, key %012llx :", block, 'A', bytes_to_num(t.sectors[i].KeyA, 6)); print_hex(mp.mpd.abtData, 16); mf_configure(r.pdi); mf_select_tag(r.pdi, &(t.nt)); failure = false; } else { fprintf(stdout, "read A failed with err %d\n", res); // Error, now try read() with B key if (res != NFC_ERFTRANS) { nfc_perror(r.pdi, "nfc_initiator_mifare_cmd"); //goto error; <------ COMMENT THIS LINE <------------ } mf_configure(r.pdi); mf_anticollision(t, r); memcpy(mp.mpa.abtKey, t.sectors[i].KeyB, sizeof(t.sectors[i].KeyB)); fprintf(stdout, "Trying key B\n");
Basically it first attempts to authenticate with KEY A. which succeeds, it then tries to read with KEY A. Which fails with an AUTH error.
For some odd reason it does not fail with an auth error in the first check. Which trips up the application because it does not expect an auth error after that point.
Because of this it does not try with KEY B, which would have worked.
The solution that worked for me was to simply comment out the
goto error;
, recompile, and everything worked perfectly.Hope this helps someone else
I confirm this works on my practical case
Big Thanks
@pollev pollev
from mfoc.
Related Issues (20)
- Error UID: ad11fca0 (ATQA:0004/SAK:08)
- Task failed successfully *Windows XP sound* HOT 3
- Cracking with cheap hardware?
- ACR122U Authentication Failed
- Can't dump content of ISO14443B
- Submit new release
- Does not work with MiFare Classic 1k emulation card with SAK=28, both mfoc and mfoc-hardnested HOT 2
- Is this project maintained? HOT 1
- Screen output does not include keys
- Feature: Colorize output HOT 1
- Android NFC build HOT 1
- mfoc: ERROR: only Mifare Classic is supported
- ISO14443A card -> mfoc: ERROR: only Mifare Classic is supported HOT 2
- Feature: Import card details from text file?
- Stuck on the same distance 65439 HOT 10
- Static Nonce implementation? HOT 2
- ERROR: only Mifare Classic is supported HOT 2
- Unable to read 2 Sectors on MiFare Classic 1k
- Error Mifare 1 K MFCUK MFOC
- Hi HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mfoc.