From 856da9a1c081abedef9af96220723eb1031f49e2 Mon Sep 17 00:00:00 2001 From: Oleg Moiseenko Date: Sun, 11 Feb 2018 00:44:24 +0200 Subject: [PATCH] added cipherstream recovery --- client/cmdhflist.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/cmdhflist.c b/client/cmdhflist.c index 1701c13a..64ffed5c 100644 --- a/client/cmdhflist.c +++ b/client/cmdhflist.c @@ -295,6 +295,7 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m // check last used key if (mfLastKey) { if (NestedCheckKey(mfLastKey, &AuthData, cmd, cmdsize)) { + traceCrypto1 = lfsr_recovery64(AuthData.ks2, AuthData.ks3); }; } @@ -302,7 +303,7 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, bool isResponse, uint8_t *m if (!traceCrypto1) { for (int defaultKeyCounter = 0; defaultKeyCounter < MifareDefaultKeysSize; defaultKeyCounter++){ if (NestedCheckKey(MifareDefaultKeys[defaultKeyCounter], &AuthData, cmd, cmdsize)) { - + traceCrypto1 = lfsr_recovery64(AuthData.ks2, AuthData.ks3); break; }; } @@ -409,5 +410,11 @@ bool NestedCheckKey(uint64_t key, TAuthData *ad, uint8_t *cmd, uint8_t cmdsize) crypto1_destroy(pcs); - return CheckCrc14443(CRC_14443_A, buf, cmdsize); + if(CheckCrc14443(CRC_14443_A, buf, cmdsize)) { + AuthData.ks2 = AuthData.ar_enc ^ ar; + AuthData.ks3 = AuthData.at_enc ^ at; + return true; + } else { + return false; + } } \ No newline at end of file