profiler: mask-match IMSI/ICCID contents on 'Profile from card'

When generating a ruleset from the card, capture EF.IMSI (6F07) and
EF.ICCID (2FE2) contents as a mask matching only the first 4 bytes
(e.g. 08290591??????????), the rest are '?' wildcards.

Add profilerMaskPrefix4 helper + PROFILER_MASK_PREFIX4_FIDS map + tests.
SW cache v44.
This commit is contained in:
2026-09-09 23:06:48 +03:00
parent dd18a24062
commit 9879675df2
3 changed files with 27 additions and 3 deletions
+19 -1
View File
@@ -6672,6 +6672,13 @@ const PROFILER_IGNORE_FILES = [
{ fid: '6F43', name: 'EF.SMSS' },
];
// Files where contents are captured as a mask matching only the first 4 bytes
// (the rest are '?' wildcards). Keyed by FID; display name is the pySim name.
const PROFILER_MASK_PREFIX4_FIDS = {
'6F07': 'EF.IMSI',
'2FE2': 'EF.ICCID',
};
function profilerLoad() {
try {
const d = localStorage.getItem('otaman_profiles');
@@ -6717,6 +6724,13 @@ function profilerMatchMin(mode, expected, actual) {
return profilerMatch(mode, e.slice(0, n), a.slice(0, n));
}
// Keep the first 4 bytes (8 hex chars) exact and mask the rest with '?'.
function profilerMaskPrefix4(hex) {
const h = profilerNormHex(hex);
if (h.length <= 8) return h;
return h.slice(0, 8) + '?'.repeat(h.length - 8);
}
function profilerValidateProfile(obj) {
if (!obj || typeof obj !== 'object') return 'Not an object';
if (!obj.name) return 'Missing name';
@@ -6896,7 +6910,11 @@ async function profilerBuildFileRule(path, c, ignoreFids) {
records: rd.records.map(r => ({ num: r.num, data: r.data })),
};
} else if (rd.data) {
rule.content = { mode: 'exact', kind: 'transparent', expected: rd.data };
if (PROFILER_MASK_PREFIX4_FIDS[fid]) {
rule.content = { mode: 'mask', kind: 'transparent', expected: profilerMaskPrefix4(rd.data) };
} else {
rule.content = { mode: 'exact', kind: 'transparent', expected: rd.data };
}
}
}
} catch (e) {}