X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/bc7846f4376472abdc9ced23436dfe3b6dd20e7f..3e5b5bb2da079dae34dc42ff3947e2d9384f1992:/client/cmdhfmf.c?ds=inline

diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c
index ea73bf95..0ea171af 100644
--- a/client/cmdhfmf.c
+++ b/client/cmdhfmf.c
@@ -214,14 +214,14 @@ start:
 		}
 	}	
 	printf("\n");
+	// error
+	if (isOK != 1) return 1;
 	
-	// par == 0,  and -4
-	if (isOK == -4 && par_list == 0) {
+	if (par_list == 0 && ks_list != 0) {
 		// this special attack when parities is zero, uses checkkeys. Which now with block/keytype option also needs. 
 		// but it uses 0|1 instead of 0x60|0x61...
 		if (nonce2key_ex(blockNo, keytype - 0x60 , uid, nt, nr, ks_list, &r_key) ){
-			PrintAndLog("Key not found (lfsr_common_prefix list is null).");	
-			PrintAndLog("Failing is expected to happen in 25%% of all cases. Trying again with a different reader nonce...");
+			PrintAndLog("Trying again with a different reader nonce...");
 			c.arg[0] = false;
 			goto start;
 		} else {
@@ -229,10 +229,7 @@ start:
 			goto END;
 		}
 	}
-	
-	// error
-	if (isOK != 1) return 1;
-	
+
 	// execute original function from util nonce2key
 	if (nonce2key(uid, nt, nr, par_list, ks_list, &r_key)) {
 		isOK = 2;
@@ -248,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);
@@ -1060,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) {
@@ -1365,7 +1363,7 @@ int CmdHF14AMfChk(const char *Cmd) {
 #define ATTACK_KEY_COUNT 8
 sector *k_sector = NULL;
 uint8_t k_sectorsCount = 16;
-void readerAttack(nonces_t data[], bool setEmulatorMem, bool showMaths) {
+void readerAttack(nonces_t data[], bool setEmulatorMem, bool verbose) {
 
 	// initialize storage for found keys
 	if (k_sector == NULL)
@@ -1389,7 +1387,7 @@ void readerAttack(nonces_t data[], bool setEmulatorMem, bool showMaths) {
 
 			// We can probably skip this, mfkey32v2 is more reliable.
 #ifdef HFMF_TRYMFK32
-			if (tryMfk32(data[i], &key)) {
+			if (tryMfk32(data[i], &key, verbose)) {
 				PrintAndLog("Found Key%s for sector %02d: [%012"llx"]"
 					, (data[i].keytype) ? "B" : "A"
 					, data[i].sector
@@ -1414,7 +1412,7 @@ void readerAttack(nonces_t data[], bool setEmulatorMem, bool showMaths) {
 			}
 #endif
 			//moebius attack			
-			if (tryMfk32_moebius(data[i+ATTACK_KEY_COUNT], &key, showMaths)) {
+			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;
 
@@ -1456,7 +1454,7 @@ int CmdHF14AMf1kSim(const char *Cmd) {
 	bool errors = false;
 
 	// If set to true, we should show our workings when doing NR_AR_ATTACK.
-	bool showMaths = false;
+	bool verbose = false;
 
 	while(param_getchar(Cmd, cmdp) != 0x00) {
 		switch(param_getchar(Cmd, cmdp)) {
@@ -1491,7 +1489,7 @@ int CmdHF14AMf1kSim(const char *Cmd) {
 			break;
 		case 'v':
 		case 'V':
-			showMaths = true;
+			verbose = true;
 			cmdp++;
 			break;
 		case 'x':
@@ -1533,7 +1531,7 @@ int CmdHF14AMf1kSim(const char *Cmd) {
 			if ( (resp.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD ) break;
 
 			memcpy( data, resp.d.asBytes, sizeof(data) );			
-			readerAttack(data, setEmulatorMem, showMaths);
+			readerAttack(data, setEmulatorMem, verbose);
 		}
 		
 		if (k_sector != NULL) {