X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/60c33f7aa863403d6b7055c625898af3c499005f..7e735c1398b9c3643d292614db10c7e58c58db85:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 7114945d..6b944df3 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -245,7 +245,7 @@ start: uint64_t key64 = 0; int res = mfCheckKeys(blockNo, keytype - 0x60 , false, 1, keyblock, &key64); if ( res > 0 ) { - PrintAndLog("Candidate Key found (%012"llx") - Test authentication failed. Starting over darkside attack", r_key); + PrintAndLog("Candidate Key found (%012"llx") - Test authentication failed. [%d] Restarting darkside attack", r_key, res); goto start; } PrintAndLog("Found valid key: %012"llx" \n", r_key); @@ -1057,7 +1057,8 @@ int CmdHF14AMfNestedHard(const char *Cmd) { slow ? "Yes" : "No", tests); - int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key ? trgkey : NULL, nonce_file_read, nonce_file_write, slow, tests); + uint64_t foundkey = 0; + int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key ? trgkey : NULL, nonce_file_read, nonce_file_write, slow, tests, &foundkey); if (isOK) { switch (isOK) { @@ -1382,62 +1383,64 @@ void readerAttack(nonces_t data[], bool setEmulatorMem, bool verbose) { printf("enter reader attack\n"); for (uint8_t i = 0; i < ATTACK_KEY_COUNT; ++i) { - if (data[i].ar2 > 0) { + + // if no-collected data + if (data[i].ar2 == 0) continue; - // We can probably skip this, mfkey32v2 is more reliable. + // We can probably skip this, mfkey32v2 is more reliable. #ifdef HFMF_TRYMFK32 - if (tryMfk32(data[i], &key, verbose)) { - PrintAndLog("Found Key%s for sector %02d: [%012"llx"]" - , (data[i].keytype) ? "B" : "A" - , data[i].sector - , key - ); - - k_sector[i].Key[data[i].keytype] = key; - k_sector[i].foundKey[data[i].keytype] = TRUE; - - //set emulator memory for keys - if (setEmulatorMem) { - uint8_t memBlock[16] = {0,0,0,0,0,0, 0xff, 0x0F, 0x80, 0x69, 0,0,0,0,0,0}; - num_to_bytes( k_sector[i].Key[0], 6, memBlock); - num_to_bytes( k_sector[i].Key[1], 6, memBlock+10); - PrintAndLog("Setting Emulator Memory Block %02d: [%s]" - , ((data[i].sector)*4) + 3 - , sprint_hex( memBlock, sizeof(memBlock)) - ); - mfEmlSetMem( memBlock, ((data[i].sector)*4) + 3, 1); - } - continue; + if (tryMfk32(data[i], &key, verbose)) { + PrintAndLog("Found Key%s for sector %02d: [%012"llx"]" + , (data[i].keytype) ? "B" : "A" + , data[i].sector + , key + ); + + k_sector[i].Key[data[i].keytype] = key; + k_sector[i].foundKey[data[i].keytype] = TRUE; + + //set emulator memory for keys + if (setEmulatorMem) { + uint8_t memBlock[16] = {0,0,0,0,0,0, 0xff, 0x0F, 0x80, 0x69, 0,0,0,0,0,0}; + num_to_bytes( k_sector[i].Key[0], 6, memBlock); + num_to_bytes( k_sector[i].Key[1], 6, memBlock+10); + PrintAndLog("Setting Emulator Memory Block %02d: [%s]" + , ((data[i].sector)*4) + 3 + , sprint_hex( memBlock, sizeof(memBlock)) + ); + mfEmlSetMem( memBlock, ((data[i].sector)*4) + 3, 1); } + continue; + } #endif - //moebius attack - if (tryMfk32_moebius(data[i+ATTACK_KEY_COUNT], &key, verbose)) { - uint8_t sectorNum = data[i+ATTACK_KEY_COUNT].sector; - uint8_t keyType = data[i+ATTACK_KEY_COUNT].keytype; - - PrintAndLog("M-Found Key%s for sector %02d: [%012"llx"]" - , keyType ? "B" : "A" - , sectorNum - , key - ); - - k_sector[sectorNum].Key[keyType] = key; - k_sector[sectorNum].foundKey[keyType] = TRUE; - - //set emulator memory for keys - if (setEmulatorMem) { - uint8_t memBlock[16] = {0,0,0,0,0,0, 0xff, 0x0F, 0x80, 0x69, 0,0,0,0,0,0}; - num_to_bytes( k_sector[sectorNum].Key[0], 6, memBlock); - num_to_bytes( k_sector[sectorNum].Key[1], 6, memBlock+10); - PrintAndLog("Setting Emulator Memory Block %02d: [%s]" - , (sectorNum*4) + 3 - , sprint_hex( memBlock, sizeof(memBlock)) - ); - mfEmlSetMem( memBlock, (sectorNum*4) + 3, 1); - } - continue; + + //moebius attack + if (tryMfk32_moebius(data[i+ATTACK_KEY_COUNT], &key, verbose)) { + uint8_t sectorNum = data[i+ATTACK_KEY_COUNT].sector; + uint8_t keyType = data[i+ATTACK_KEY_COUNT].keytype; + + PrintAndLog("Found Key%s for sector %02d: [%012"llx"]" + , keyType ? "B" : "A" + , sectorNum + , key + ); + + k_sector[sectorNum].Key[keyType] = key; + k_sector[sectorNum].foundKey[keyType] = TRUE; + + //set emulator memory for keys + if (setEmulatorMem) { + uint8_t memBlock[16] = {0,0,0,0,0,0, 0xff, 0x0F, 0x80, 0x69, 0,0,0,0,0,0}; + num_to_bytes( k_sector[sectorNum].Key[0], 6, memBlock); + num_to_bytes( k_sector[sectorNum].Key[1], 6, memBlock+10); + //iceman, guessing this will not work so well for 4K tags. + PrintAndLog("Setting Emulator Memory Block %02d: [%s]" + , (sectorNum*4) + 3 + , sprint_hex( memBlock, sizeof(memBlock)) + ); + mfEmlSetMem( memBlock, (sectorNum*4) + 3, 1); } - + continue; } } }