started to add touch nd go keygen algo from metrodroid

This commit is contained in:
iceman1001 2021-02-04 22:02:07 +01:00
parent 2a17cb5545
commit 63739b25d3
3 changed files with 25 additions and 1 deletions

View file

@ -13,6 +13,7 @@
#include <string.h>
#include <ctype.h> // tolower
#include <math.h>
#include <inttypes.h> // PRIx64 macro
#include "commonutil.h" // reflect...
#include "comms.h" // clearCommandBuffer
#include "cmdparser.h" // command_t
@ -550,6 +551,13 @@ static int CmdAnalyseA(const char *Cmd) {
PrintAndLogEx(FAILED, "Error parsing bytes");
return PM3_EINVARG;
}
uint64_t key = 0;
res = mfc_algo_touch_one(data, 0, 0, &key);
if (res == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "KEY A | %012" PRIx64, key);
}
CLIParserFree(ctx);
return PM3_SUCCESS;

View file

@ -465,7 +465,6 @@ int mfdes_kdf_input_gallagher(uint8_t *uid, uint8_t uidLen, uint8_t keyNo, uint3
return PM3_SUCCESS;
}
int mfc_generate4b_nuid(uint8_t *uid, uint8_t *nuid) {
uint16_t crc;
uint8_t b1, b2;
@ -481,6 +480,21 @@ int mfc_generate4b_nuid(uint8_t *uid, uint8_t *nuid) {
return PM3_SUCCESS;
}
int mfc_algo_touch_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key) {
if (uid == NULL) return PM3_EINVARG;
if (key == NULL) return PM3_EINVARG;
*key = (
(uint64_t)(uid[1] ^ uid[2] ^ uid[3]) << 40 |
(uint64_t)uid[1] << 32 |
(uint64_t)uid[2] << 24 |
(uint64_t)(((uid[0] + uid[1] + uid[2] + uid[3]) % 0x100) ^ uid[3]) << 16 |
(uint64_t)0 << 8 |
(uint64_t)0
);
return PM3_SUCCESS;
}
//------------------------------------
// Self tests
//------------------------------------

View file

@ -43,6 +43,8 @@ int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys);
int mfc_generate4b_nuid(uint8_t *uid, uint8_t *nuid);
int mfc_algo_touch_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
uint32_t lf_t55xx_white_pwdgen(uint32_t id);
int mfdes_kdf_input_gallagher(uint8_t *uid, uint8_t uidLen, uint8_t keyNo, uint32_t aid, uint8_t *kdfInputOut, uint8_t *kdfInputLen);