Merge 9e61b956407ea20c3f0bb0026829ec8d916994a4 into 48156f9bf0c1ffca8c4c3421090e65acb4f794e2
This commit is contained in:
commit
ba5b0dd030
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,4 +20,5 @@ src/Makefile.in
|
|||||||
src/mfoc
|
src/mfoc
|
||||||
src/mfoc.exe
|
src/mfoc.exe
|
||||||
stamp-h1
|
stamp-h1
|
||||||
|
*.bak
|
||||||
|
|
||||||
|
|||||||
27
src/mfoc.c
27
src/mfoc.c
@ -54,7 +54,6 @@
|
|||||||
|
|
||||||
//SLRE
|
//SLRE
|
||||||
#include "slre.h"
|
#include "slre.h"
|
||||||
#include "slre.c"
|
|
||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
|
|
||||||
@ -120,9 +119,7 @@ int main(int argc, char *const argv[])
|
|||||||
|
|
||||||
//File pointers for the keyfile
|
//File pointers for the keyfile
|
||||||
FILE * fp;
|
FILE * fp;
|
||||||
char * line = NULL;
|
char line[20];
|
||||||
size_t len = 0;
|
|
||||||
ssize_t read;
|
|
||||||
|
|
||||||
//Regexp declarations
|
//Regexp declarations
|
||||||
static const char *regex = "([0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])";
|
static const char *regex = "([0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])";
|
||||||
@ -155,7 +152,7 @@ int main(int argc, char *const argv[])
|
|||||||
fprintf(stderr, "Cannot open keyfile: %s, exiting\n", optarg);
|
fprintf(stderr, "Cannot open keyfile: %s, exiting\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
while ((read = getline(&line, &len, fp)) != -1) {
|
while ( fgets(line, 20, fp)) {
|
||||||
int i, j = 0, str_len = strlen(line);
|
int i, j = 0, str_len = strlen(line);
|
||||||
|
|
||||||
while (j < str_len &&
|
while (j < str_len &&
|
||||||
@ -339,6 +336,8 @@ int main(int argc, char *const argv[])
|
|||||||
i = 0; // Sector counter
|
i = 0; // Sector counter
|
||||||
// Iterate over every block, where we haven't found a key yet
|
// Iterate over every block, where we haven't found a key yet
|
||||||
for (block = 0; block <= t.num_blocks; ++block) {
|
for (block = 0; block <= t.num_blocks; ++block) {
|
||||||
|
bool rightKeyA=false;
|
||||||
|
bool rightKeyB=false;
|
||||||
if (trailer_block(block)) {
|
if (trailer_block(block)) {
|
||||||
if (!t.sectors[i].foundKeyA) {
|
if (!t.sectors[i].foundKeyA) {
|
||||||
mc = MC_AUTH_A;
|
mc = MC_AUTH_A;
|
||||||
@ -353,6 +352,7 @@ int main(int argc, char *const argv[])
|
|||||||
// Save all information about successfull keyA authentization
|
// Save all information about successfull keyA authentization
|
||||||
memcpy(t.sectors[i].KeyA, mp.mpa.abtKey, sizeof(mp.mpa.abtKey));
|
memcpy(t.sectors[i].KeyA, mp.mpa.abtKey, sizeof(mp.mpa.abtKey));
|
||||||
t.sectors[i].foundKeyA = true;
|
t.sectors[i].foundKeyA = true;
|
||||||
|
rightKeyA=true;
|
||||||
// Although KeyA can never be directly read from the data sector, KeyB can, so
|
// Although KeyA can never be directly read from the data sector, KeyB can, so
|
||||||
// if we need KeyB for this sector, it should be revealed by a data read with KeyA
|
// if we need KeyB for this sector, it should be revealed by a data read with KeyA
|
||||||
// todo - check for duplicates in cracked key list (do we care? will not be huge overhead)
|
// todo - check for duplicates in cracked key list (do we care? will not be huge overhead)
|
||||||
@ -400,13 +400,14 @@ int main(int argc, char *const argv[])
|
|||||||
} else {
|
} else {
|
||||||
memcpy(t.sectors[i].KeyB, mp.mpa.abtKey, sizeof(mp.mpa.abtKey));
|
memcpy(t.sectors[i].KeyB, mp.mpa.abtKey, sizeof(mp.mpa.abtKey));
|
||||||
t.sectors[i].foundKeyB = true;
|
t.sectors[i].foundKeyB = true;
|
||||||
|
rightKeyB=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((t.sectors[i].foundKeyA) && (t.sectors[i].foundKeyB)) {
|
if ( rightKeyA && rightKeyB) {
|
||||||
fprintf(stdout, "x");
|
fprintf(stdout, "x");
|
||||||
} else if (t.sectors[i].foundKeyA) {
|
} else if ( rightKeyA ) {
|
||||||
fprintf(stdout, "/");
|
fprintf(stdout, "/");
|
||||||
} else if (t.sectors[i].foundKeyB) {
|
} else if ( rightKeyB) {
|
||||||
fprintf(stdout, "\\");
|
fprintf(stdout, "\\");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stdout, ".");
|
fprintf(stdout, ".");
|
||||||
@ -611,11 +612,10 @@ int main(int argc, char *const argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (succeed) {
|
if (succeed) {
|
||||||
i = t.num_sectors; // Sector counter
|
i = 0; // Sector counter
|
||||||
fprintf(stdout, "Auth with all sectors succeeded, dumping keys to a file!\n");
|
fprintf(stdout, "Auth with all sectors succeeded, dumping keys to a file!\n");
|
||||||
// Read all blocks
|
// Read all blocks
|
||||||
for (block = t.num_blocks; block >= 0; block--) {
|
for (block = 0; block <= t.num_blocks; block++) {
|
||||||
trailer_block(block) ? i-- : i;
|
|
||||||
failure = true;
|
failure = true;
|
||||||
|
|
||||||
// Try A key, auth() + read()
|
// Try A key, auth() + read()
|
||||||
@ -674,7 +674,10 @@ int main(int argc, char *const argv[])
|
|||||||
// Copy the keys over from our key dump and store the retrieved access bits
|
// Copy the keys over from our key dump and store the retrieved access bits
|
||||||
memcpy(mtDump.amb[block].mbt.abtKeyA, t.sectors[i].KeyA, 6);
|
memcpy(mtDump.amb[block].mbt.abtKeyA, t.sectors[i].KeyA, 6);
|
||||||
memcpy(mtDump.amb[block].mbt.abtKeyB, t.sectors[i].KeyB, 6);
|
memcpy(mtDump.amb[block].mbt.abtKeyB, t.sectors[i].KeyB, 6);
|
||||||
if (!failure) memcpy(mtDump.amb[block].mbt.abtAccessBits, mp.mpd.abtData + 6, 4);
|
if (!failure) {
|
||||||
|
memcpy(mtDump.amb[block].mbt.abtAccessBits, mp.mpd.abtData + 6, 4);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
} else if (!failure) memcpy(mtDump.amb[block].mbd.abtData, mp.mpd.abtData, 16);
|
} else if (!failure) memcpy(mtDump.amb[block].mbd.abtData, mp.mpd.abtData, 16);
|
||||||
memcpy(mp.mpa.abtAuthUid, t.nt.nti.nai.abtUid + t.nt.nti.nai.szUidLen - 4, sizeof(mp.mpa.abtAuthUid));
|
memcpy(mp.mpa.abtAuthUid, t.nt.nti.nai.abtUid + t.nt.nti.nai.szUidLen - 4, sizeof(mp.mpa.abtAuthUid));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user