Merge pull request #3739 from Ryan4n6/feat/mfulc-prng-backstop
feat(hf mfu): weak-PRNG backstop for Ultralight C fingerprint
This commit is contained in:
2 files changed
+66
No files matched your search
@@ -16,6 +16,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
|
||||
- Fixed `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix)
|
||||
- Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu and CodeQL skip the slow Azure apt mirror (@matrix)
|
||||
- Fixed `recovery.bin` on the AT91 platforms - the bootrom is padded to 0x102000 again, so the OS image is at its load address (@matrix)
|
||||
- Added `hf mfu info` weak-PRNG backstop - detects counterfeit ULC via RndB collision (@Ryan4n6)
|
||||
- Updated `/Getting_Started_With_PM5.md` (@innocentbystanderproxmark)
|
||||
- Fixed `hf seos pacs`/`write` - 2K3DES GET/UPDATE DATA no longer fails silently with exit 236; print APDU exchange errors, check DES-CMAC, decode SELECT `85` at its real length, and use short-form `85` when the cryptogram is under 128 bytes
|
||||
- Fixed client build with `-march=x86-64-v3` (CentOS/RHEL 10 default) - false `-Wstringop-overflow` in the EMV AID list table (@r3wretrhy)
|
||||
|
||||
@@ -2028,6 +2028,69 @@ int mfu_get_version_uid(uint8_t *version, uint8_t *uid) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// Weak-PRNG backstop: RndB collision => counterfeit LFSR
|
||||
#define MFULC_PRNG_SAMPLES 40
|
||||
#define MFULC_PRNG_CLEAR 39
|
||||
|
||||
static int mfulc_prng_test(uint32_t samples) {
|
||||
if (samples < 2) {
|
||||
samples = 2;
|
||||
}
|
||||
if (samples > 64) {
|
||||
samples = 64;
|
||||
}
|
||||
|
||||
uint8_t rndb[64][8];
|
||||
uint32_t got = 0;
|
||||
|
||||
for (uint32_t i = 0; i < samples; i++) {
|
||||
iso14a_card_select_t card;
|
||||
if (ul_select(&card) == false) {
|
||||
continue;
|
||||
}
|
||||
uint8_t nonce[11] = {0x00};
|
||||
int rl = ulc_requestAuthentication(nonce, sizeof(nonce));
|
||||
DropField();
|
||||
// response is AF || ek(RndB)[8] || CRC[2]; compare the 8-byte ek(RndB)
|
||||
if (rl < 9 || nonce[0] != 0xAF) {
|
||||
continue;
|
||||
}
|
||||
memcpy(rndb[got], &nonce[1], 8);
|
||||
got++;
|
||||
}
|
||||
|
||||
if (got < 2) {
|
||||
PrintAndLogEx(INFO, "PRNG......... could not collect nonces (got %u)", got);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
uint32_t first_dup = 0;
|
||||
uint32_t dups = 0;
|
||||
for (uint32_t i = 0; i < got; i++) {
|
||||
for (uint32_t j = 0; j < i; j++) {
|
||||
if (memcmp(rndb[i], rndb[j], 8) == 0) {
|
||||
if (first_dup == 0) {
|
||||
first_dup = i + 1; // 1-based draw index
|
||||
}
|
||||
dups++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dups > 0) {
|
||||
PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("Weak") " (RndB collision at %u)", first_dup);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
if (got >= MFULC_PRNG_CLEAR) {
|
||||
PrintAndLogEx(SUCCESS, "PRNG......... " _GREEN_("Genuine"));
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "PRNG......... inconclusive (%u/%u nonces)", got, (uint32_t)MFULC_PRNG_CLEAR);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int mfulc_fingerprint(void) {
|
||||
iso14a_card_select_t card;
|
||||
PacketResponseNG resp;
|
||||
@@ -2139,6 +2202,8 @@ static int mfulc_fingerprint(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// weak-PRNG backstop
|
||||
mfulc_prng_test(MFULC_PRNG_SAMPLES);
|
||||
PrintAndLogEx(INFO, "likely MF0ICU2");
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
|
||||
Reference in new issue
Block a user