X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/5ff9150e3bfecdeee84fcabcc712ef595c33d2d6..3d77fdfab52f8837dbd704f5d9efe4bafa057285:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index ed3394e5..9bfa055b 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -330,7 +330,6 @@ int CmdHF14AMfDump1k(const char *Cmd) for (i=0 ; i<16 ; i++) { for (j=0 ; j<4 ; j++) { - if (j == 3){ UsbCommand c = {CMD_MIFARE_READBL, {i*4 + j, 0, 0}}; memcpy(c.d.asBytes, keyA[i], 6); @@ -358,6 +357,20 @@ int CmdHF14AMfDump1k(const char *Cmd) if (resp != NULL) { uint8_t isOK = resp->arg[0] & 0xff; uint8_t *data = resp->d.asBytes; + if (j == 3) { + data[0] = (keyA[i][0]); + data[1] = (keyA[i][1]); + data[2] = (keyA[i][2]); + data[3] = (keyA[i][3]); + data[4] = (keyA[i][4]); + data[5] = (keyA[i][5]); + data[10] = (keyB[i][0]); + data[11] = (keyB[i][1]); + data[12] = (keyB[i][2]); + data[13] = (keyB[i][3]); + data[14] = (keyB[i][4]); + data[15] = (keyB[i][5]); + } if (isOK) { fwrite ( data, 1, 16, fout ); } @@ -467,6 +480,8 @@ int CmdHF14AMfNested(const char *Cmd) int createDumpFile = 0; FILE *fkeys; + uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + uint8_t tempkey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; char cmdp, ctmp; @@ -519,10 +534,12 @@ int CmdHF14AMfNested(const char *Cmd) } ctmp = param_getchar(Cmd, 4); - if (ctmp == 't' || ctmp == 'T') transferToEml = 1; + if (ctmp == 't' || ctmp == 'T') transferToEml = 1; + else if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1; + ctmp = param_getchar(Cmd, 6); transferToEml |= (ctmp == 't' || ctmp == 'T'); - createDumpFile |= (ctmp == 'd' || ctmp == 'D'); + transferToEml |= (ctmp == 'd' || ctmp == 'D'); PrintAndLog("--block no:%02x key type:%02x key:%s etrans:%d", blockNo, keyType, sprint_hex(key, 6), transferToEml); if (cmdp == 'o') @@ -558,8 +575,8 @@ int CmdHF14AMfNested(const char *Cmd) } else { PrintAndLog("No valid key found"); } - } else // ------------------------------------ multiple sectors working - { + } + else { // ------------------------------------ multiple sectors working blDiff = blockNo % 4; PrintAndLog("Block shift=%d", blDiff); e_sector = calloc(SectorsCnt, sizeof(sector)); @@ -587,7 +604,6 @@ int CmdHF14AMfNested(const char *Cmd) } } - // nested sectors iterations = 0; PrintAndLog("nested..."); @@ -634,17 +650,31 @@ int CmdHF14AMfNested(const char *Cmd) } } + // Create dump file if (createDumpFile) { if ((fkeys = fopen("dumpkeys.bin","wb")) == NULL) { PrintAndLog("Could not create file keys.bin"); free(e_sector); return 1; } + PrintAndLog("Printing keys to bynary file dumpkeys.bin..."); for(i=0; i<16; i++) { - fwrite ( e_sector[i].Key, sizeof(e_sector[i].Key[0]), 1, fkeys ); + if (e_sector[i].foundKey[0]){ + num_to_bytes(e_sector[i].Key[0], 6, tempkey); + fwrite ( tempkey, 1, 6, fkeys ); + } + else{ + fwrite ( &standart, 1, 6, fkeys ); + } } for(i=0; i<16; i++) { - fwrite ( e_sector[i].Key, sizeof(e_sector[i].Key[1]), 1, fkeys ); + if (e_sector[i].foundKey[1]){ + num_to_bytes(e_sector[i].Key[1], 6, tempkey); + fwrite ( tempkey, 1, 6, fkeys ); + } + else{ + fwrite ( &standart, 1, 6, fkeys ); + } } fclose(fkeys); }