lf noralsy: refuse CN above 9999999 and years outside 1961-2060

clone and sim encoded only 7 BCD digits of the CN and the last two
digits of the year, which the demod maps to 1961-2060, so
--cn 12345678 wrote card 2345678 and --year 1950 the year 2050.
Both values were also cut to 32 and 16 bits first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gabriele GristinaandClaude Opus 5.5 committed 2026-11-08 17:47:43 +01:00
1 parent 3810eee3e0
commit 5fb4d6b250
2 files changed
+21 -4

No files matched your search

+20 -4
View File
@@ -173,8 +173,8 @@ static int CmdNoralsyClone(const char *Cmd) {
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
uint32_t id = arg_get_u32_def(ctx, 1, 0);
uint16_t year = arg_get_u32_def(ctx, 2, 2000);
uint64_t cn_arg = arg_get_u64_def(ctx, 1, 0);
uint64_t year_arg = arg_get_u64_def(ctx, 2, 2000);
bool q5 = arg_get_lit(ctx, 3);
bool em = arg_get_lit(ctx, 4);
CLIParserFree(ctx);
@@ -184,6 +184,14 @@ static int CmdNoralsyClone(const char *Cmd) {
return PM3_EINVARG;
}
// the frame carries 7 BCD digits of cn and the last 2 of the year, read back as 1961-2060
if (cn_arg > 9999999 || year_arg < 1961 || year_arg > 2060) {
PrintAndLogEx(FAILED, "CN has a max value of 9999999 and year must be 1961-2060");
return PM3_EINVARG;
}
uint32_t id = (uint32_t)cn_arg;
uint16_t year = (uint16_t)year_arg;
uint32_t blocks[4] = {T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | T55x7_ST_TERMINATOR | 3 << T55x7_MAXBLOCK_SHIFT, 0, 0};
char cardtype[16] = {"T55x7"};
//Q5
@@ -246,10 +254,18 @@ static int CmdNoralsySim(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
uint32_t id = arg_get_u32_def(ctx, 1, 0);
uint16_t year = arg_get_u32_def(ctx, 2, 2000);
uint64_t cn_arg = arg_get_u64_def(ctx, 1, 0);
uint64_t year_arg = arg_get_u64_def(ctx, 2, 2000);
CLIParserFree(ctx);
// the frame carries 7 BCD digits of cn and the last 2 of the year, read back as 1961-2060
if (cn_arg > 9999999 || year_arg < 1961 || year_arg > 2060) {
PrintAndLogEx(FAILED, "CN has a max value of 9999999 and year must be 1961-2060");
return PM3_EINVARG;
}
uint32_t id = (uint32_t)cn_arg;
uint16_t year = (uint16_t)year_arg;
uint8_t bs[96];
memset(bs, 0, sizeof(bs));