Skip to content

Commit

Permalink
Merge branch 'RfidResearchGroup:master' into feature/staticnested
Browse files Browse the repository at this point in the history
  • Loading branch information
solletichino999 authored Oct 23, 2024
2 parents f1614b4 + d2e29b2 commit a1ca2fe
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 158 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
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...

## [unreleased][unreleased]
- Changed `hf iclass info` - now checks for cards silicon version (@antiklesys)
- Changed `hf iclass legrec` - updated script implementation to ensure functionality (@antiklesys)
- Added recovered iclass custom key to dictionary (@antiklesys)
- Added support for all Hitag S response protocol mode (@douniwan5788)
- Fixed 'hf_young.c' - flags declaration was missing a semicolon (@jakkpotts)
- Changed `hf mf sim` - add option to allow key b to be used even if readable (@doegox)
Expand Down
18 changes: 9 additions & 9 deletions armsrc/hitagS.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,12 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {

while ((BUTTON_PRESS() == false) && (data_available() == false)) {

if (payload->page_count == 0) {
if (page_addr > tag.max_page) break;
} else if (page_addr > 255 || page_addr >= payload->page + payload->page_count) {
break;
}

WDT_HIT();

size_t rxlen = 0;
Expand All @@ -1289,7 +1295,7 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {

if (rxlen != 32 + (protocol_mode == HITAGS_UID_REQ_STD ? 0 : 8)) {
DBG Dbprintf("Read page failed!");
card.pages_reason[page_index] = -4;
card.pages_reason[page_index] = -11;
// status = PM3_ERFTRANS;
// goto read_end;
page_addr++;
Expand Down Expand Up @@ -1339,18 +1345,12 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {
//if the authentication is done with a challenge the key and password are unknown
DBG Dbprintf("Page[ 2]: __ __ __ __");
DBG Dbprintf("Page[ 3]: __ __ __ __");
card.pages_reason[page_index++] = -4;
card.pages_reason[page_index++] = -4;
card.pages_reason[page_index++] = -11;
card.pages_reason[page_index++] = -11;
}
// since page 2+3 are not accessible when LKP == 1 and AUT == 1 fastforward to next readable page
page_addr = 4;
}

if (payload->page_count == 0) {
if (page_addr > tag.max_page) break;
} else if (page_addr > 255 || page_addr >= payload->page + payload->page_count) {
break;
}
}

read_end:
Expand Down
351 changes: 209 additions & 142 deletions armsrc/iclass.c

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion armsrc/iclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,5 @@ bool authenticate_iclass_tag(iclass_auth_req_t *payload, picopass_hdr_t *hdr, ui
uint8_t get_pagemap(const picopass_hdr_t *hdr);
void iclass_send_as_reader(uint8_t *frame, int len, uint32_t *start_time, uint32_t *end_time, bool shallow_mod);

void generate_single_key_block_inverted(const uint8_t *startingKey, uint32_t index, uint8_t *keyBlock);
void iClass_Recover(iclass_recover_req_t *msg);
#endif
2 changes: 2 additions & 0 deletions client/dictionaries/iclass_default_keys.dic
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ C1B74D7478053AE2
#
# default iCLASS RFIDeas
6B65797374726B72
# Retrieved from Custom Keyed Systems
E9924C13F4BFA82C
11 changes: 7 additions & 4 deletions client/src/cmdhf14b.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ static bool HF14B_ask_ct_reader(bool verbose) {
return false;
}

static bool HF14B_picopass_reader(bool verbose) {
bool HF14B_picopass_reader(bool verbose, bool info) {

iso14b_raw_cmd_t packet = {
.flags = (ISO14B_CONNECT | ISO14B_SELECT_PICOPASS | ISO14B_DISCONNECT),
Expand All @@ -1437,8 +1437,10 @@ static bool HF14B_picopass_reader(bool verbose) {
return false;
}
memcpy(card, resp.data.asBytes, sizeof(picopass_hdr_t));
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "iCLASS / Picopass CSN: " _GREEN_("%s"), sprint_hex(card->csn, sizeof(card->csn)));
if(info){
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "iCLASS / Picopass CSN: " _GREEN_("%s"), sprint_hex(card->csn, sizeof(card->csn)));
}
free(card);
return true;
}
Expand Down Expand Up @@ -3034,6 +3036,7 @@ int infoHF14B(bool verbose, bool do_aid_search) {
// get and print general info about all known 14b chips
int readHF14B(bool loop, bool verbose, bool read_plot) {
bool found = false;
bool info = true;
int res = PM3_SUCCESS;
do {
found = false;
Expand All @@ -3049,7 +3052,7 @@ int readHF14B(bool loop, bool verbose, bool read_plot) {
goto plot;

// Picopass
found |= HF14B_picopass_reader(verbose);
found |= HF14B_picopass_reader(verbose, info);
if (found)
goto plot;

Expand Down
2 changes: 2 additions & 0 deletions client/src/cmdhf14b.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ int select_card_14443b_4(bool disconnect, iso14b_card_select_t *card);

int infoHF14B(bool verbose, bool do_aid_search);
int readHF14B(bool loop, bool verbose, bool read_plot);
bool HF14B_picopass_reader(bool verbose, bool info);

#endif
6 changes: 6 additions & 0 deletions client/src/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "crypto/asn1utils.h" // ASN1 decoder
#include "preferences.h"
#include "generator.h"
#include "cmdhf14b.h"


#define NUM_CSNS 9
Expand Down Expand Up @@ -5379,6 +5380,11 @@ int info_iclass(bool shallow_mod) {
uint8_t cardtype = get_mem_config(hdr);
PrintAndLogEx(SUCCESS, " Card type.... " _GREEN_("%s"), card_types[cardtype]);

if(HF14B_picopass_reader(false, false)){
PrintAndLogEx(SUCCESS, " Card chip.... "_YELLOW_("Old Silicon (14b support)"));
}else{
PrintAndLogEx(SUCCESS, " Card chip.... "_YELLOW_("NEW Silicon (No 14b support)"));
}
if (legacy) {

int res = PM3_ESOFT;
Expand Down
9 changes: 7 additions & 2 deletions client/src/cmdlfhitaghts.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ static void print_error(int8_t reason) {
case -10:
PrintAndLogEx(FAILED, "Write to page failed!");
break;
case -11:
PrintAndLogEx(FAILED, "Read page failed!");
break;
default:
// PM3_REASON_UNKNOWN
PrintAndLogEx(DEBUG, "DEBUG: Error - Hitag S failed");
Expand Down Expand Up @@ -427,8 +430,10 @@ static int CmdLFHitagSRead(const char *Cmd) {
PrintAndLogEx(NORMAL, "Key");
} else
PrintAndLogEx(NORMAL, "Data");
} else
PrintAndLogEx(INFO, "%02u | -- -- -- -- | read failed reason: " _YELLOW_("%d"), page_addr, card->pages_reason[i]);
} else {
PrintAndLogEx(INFO, "% 3u | -- -- -- -- | .... | N/A | " NOLF, page_addr);
print_error(card->pages_reason[i]);
}
}

PrintAndLogEx(INFO, "----+-------------+-------+------+------");
Expand Down

0 comments on commit a1ca2fe

Please sign in to comment.