Skip to content

Commit 70581e3

Browse files
committed
modified iclass chk to load the default dictionary file. hf iclass chk -> use iclass_default_keys and hf iclass chk --elite -> use iclass_elite_keys`.. a bit simple
1 parent 0c2ef9d commit 70581e3

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
33
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
44

55
## [unreleased][unreleased]
6+
- Changed `hf iclass chk` - now loads dictionary file by default (@iceman1001)
67
- Added an Makefile variable `DONT_BUILD_NATIVE` in mfd_aes_brute Makefile to easify downstream package
78
- Auto detect whether compile option `march=native` is supported for mfd_aes_brute Makefile
89
- Changed `hf mf sim` - support data-first and nested reader attacks (@doegox)

client/src/cmdhficlass.c

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#define ICLASS_AUTH_RETRY 10
4949
#define ICLASS_CFG_BLK_SR_BIT 0xA0 // indicates SIO present when set in block6[0] (legacy tags)
5050
#define ICLASS_DECRYPTION_BIN "iclass_decryptionkey.bin"
51+
#define ICLASS_DEFAULT_KEY_DIC "iclass_default_keys.dic"
52+
#define ICLASS_DEFAULT_KEY_ELITE_DIC "iclass_elite_keys.dic"
5153

5254
static void print_picopass_info(const picopass_hdr_t *hdr);
5355
void print_picopass_header(const picopass_hdr_t *hdr);
@@ -3611,7 +3613,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
36113613
arg_lit0(NULL, "vb6kdf", "use the VB6 elite KDF instead of a file"),
36123614
arg_param_end
36133615
};
3614-
CLIExecWithReturn(ctx, Cmd, argtable, false);
3616+
CLIExecWithReturn(ctx, Cmd, argtable, true);
36153617

36163618
int fnlen = 0;
36173619
char filename[FILE_PATH_SIZE] = {0};
@@ -3632,20 +3634,26 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
36323634
uint8_t CSN[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
36333635
uint8_t CCNR[12] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
36343636

3637+
// no filename and don't use algorithm for elite
3638+
// just add the default dictionary
3639+
if ((strlen(filename) == 0) && (use_vb6kdf == false)) {
3640+
3641+
if (use_elite) {
3642+
PrintAndLogEx(INFO,"Using default elite dictionary");
3643+
snprintf(filename, sizeof(filename), ICLASS_DEFAULT_KEY_ELITE_DIC);
3644+
} else {
3645+
PrintAndLogEx(INFO,"Using default dictionary");
3646+
snprintf(filename, sizeof(filename), ICLASS_DEFAULT_KEY_DIC);
3647+
}
3648+
}
3649+
36353650
uint64_t t1 = msclock();
36363651

36373652
// load keys
36383653
uint8_t *keyBlock = NULL;
36393654
uint32_t keycount = 0;
36403655

3641-
if (!use_vb6kdf) {
3642-
// Load keys
3643-
int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
3644-
if (res != PM3_SUCCESS || keycount == 0) {
3645-
free(keyBlock);
3646-
return res;
3647-
}
3648-
} else {
3656+
if (use_vb6kdf) {
36493657
// Generate 5000 keys using VB6 KDF
36503658
keycount = 5000;
36513659
keyBlock = calloc(1, keycount * 8);
@@ -3657,6 +3665,13 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
36573665
for (uint32_t i = 0; i < keycount; i++) {
36583666
picopass_elite_nextKey(keyBlock + (i * 8));
36593667
}
3668+
} else {
3669+
// Load keys
3670+
int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
3671+
if (res != PM3_SUCCESS || keycount == 0) {
3672+
free(keyBlock);
3673+
return res;
3674+
}
36603675
}
36613676

36623677
// limit size of keys that can be held in memory
@@ -3696,8 +3711,10 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
36963711
PrintAndLogEx(SUCCESS, " CCNR: " _GREEN_("%s"), sprint_hex(CCNR, sizeof(CCNR)));
36973712

36983713
PrintAndLogEx(INFO, "Generating diversified keys %s", (use_elite || use_raw) ? NOLF : "");
3714+
36993715
if (use_elite)
37003716
PrintAndLogEx(NORMAL, "using " _YELLOW_("elite algo"));
3717+
37013718
if (use_raw)
37023719
PrintAndLogEx(NORMAL, "using " _YELLOW_("raw mode"));
37033720

@@ -4080,7 +4097,6 @@ static int CmdHFiClassLegRecLookUp(const char *Cmd) {
40804097
return PM3_SUCCESS;
40814098
}
40824099

4083-
40844100
static int CmdHFiClassLegacyRecover(const char *Cmd) {
40854101

40864102
CLIParserContext *ctx;
@@ -5268,15 +5284,19 @@ int info_iclass(bool shallow_mod) {
52685284
// if CSN starts with E012FFF (big endian), it's inside HID CSN range.
52695285
bool is_hid_range = (hdr->csn[4] & 0xF0) == 0xF0 && (memcmp(hdr->csn + 5, "\xFF\x12\xE0", 3) == 0);
52705286

5271-
if (is_hid_range) {
5272-
bool legacy = (memcmp(aia, "\xff\xff\xff\xff\xff\xff\xff\xff", 8) == 0);
5273-
bool se_enabled = (memcmp(aia, "\xff\xff\xff\x00\x06\xff\xff\xff", 8) == 0);
5287+
bool legacy = (memcmp(aia, "\xff\xff\xff\xff\xff\xff\xff\xff", 8) == 0);
5288+
bool se_enabled = (memcmp(aia, "\xff\xff\xff\x00\x06\xff\xff\xff", 8) == 0);
52745289

5290+
if (is_hid_range) {
52755291
PrintAndLogEx(SUCCESS, " CSN.......... " _YELLOW_("HID range"));
5276-
if (legacy)
5292+
5293+
if (legacy) {
52775294
PrintAndLogEx(SUCCESS, " Credential... " _GREEN_("iCLASS legacy"));
5278-
if (se_enabled)
5295+
}
5296+
5297+
if (se_enabled) {
52795298
PrintAndLogEx(SUCCESS, " Credential... " _GREEN_("iCLASS SE"));
5299+
}
52805300
} else {
52815301
PrintAndLogEx(SUCCESS, " CSN.......... " _YELLOW_("outside HID range"));
52825302
}

0 commit comments

Comments
 (0)