mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-19 21:03:23 -07:00
Adds random nonce (r) option to hf mf sim
.
This makes the PM3 generate pseudo-random nonces rather than sequential nonces, to make it act a bit more like a "real" MFC card. A reader would otherwise be able to detect the PM3 probing based on the predictable nonces and throw different authentication challenges (or refuse to authenticate at all). The code includes an implementation of a rand-like function (prand), similar to the one from libc, which is seeded automatically based on the time it takes between the PM3 starting up and the first call to the RNG. This isn't cryptographically random, but should be "good enough" to be able to evade basic detection.
This commit is contained in:
parent
910ad5470d
commit
f9c1dcd9f6
5 changed files with 42 additions and 2 deletions
|
@ -431,3 +431,19 @@ uint32_t RAMFUNC GetCountSspClk(){
|
|||
}
|
||||
}
|
||||
|
||||
static uint64_t next_random = 1;
|
||||
|
||||
/* Generates a (non-cryptographically secure) 32-bit random number.
|
||||
*
|
||||
* We don't have an implementation of the "rand" function or a clock to seed it
|
||||
* with, so we just call GetTickCount the first time to seed ourselves.
|
||||
*/
|
||||
uint32_t prand() {
|
||||
if (next_random == 1) {
|
||||
next_random = GetTickCount();
|
||||
}
|
||||
|
||||
next_random = next_random * 6364136223846793005 + 1;
|
||||
return (uint32_t)(next_random >> 32) % 0xffffffff;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue