mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
style
This commit is contained in:
parent
2fc36d73c9
commit
0be35a8e7e
33 changed files with 448 additions and 448 deletions
|
@ -1068,11 +1068,11 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
|
|
||||||
#ifdef WITH_LEGICRF
|
#ifdef WITH_LEGICRF
|
||||||
case CMD_HF_LEGIC_SIMULATE: {
|
case CMD_HF_LEGIC_SIMULATE: {
|
||||||
struct p {
|
struct p {
|
||||||
uint8_t tagtype;
|
uint8_t tagtype;
|
||||||
bool send_reply;
|
bool send_reply;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct p *payload = (struct p *) packet->data.asBytes;
|
struct p *payload = (struct p *) packet->data.asBytes;
|
||||||
LegicRfSimulate(payload->tagtype, payload->send_reply);
|
LegicRfSimulate(payload->tagtype, payload->send_reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
16
armsrc/epa.c
16
armsrc/epa.c
|
@ -229,7 +229,7 @@ int EPA_Read_CardAccess(uint8_t *buffer, size_t max_length) {
|
||||||
sizeof(apdu_select_binary_cardaccess),
|
sizeof(apdu_select_binary_cardaccess),
|
||||||
response_apdu,
|
response_apdu,
|
||||||
sizeof(response_apdu)
|
sizeof(response_apdu)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rapdu_length < 6
|
if (rapdu_length < 6
|
||||||
|| response_apdu[rapdu_length - 4] != 0x90
|
|| response_apdu[rapdu_length - 4] != 0x90
|
||||||
|
@ -243,7 +243,7 @@ int EPA_Read_CardAccess(uint8_t *buffer, size_t max_length) {
|
||||||
sizeof(apdu_read_binary),
|
sizeof(apdu_read_binary),
|
||||||
response_apdu,
|
response_apdu,
|
||||||
sizeof(response_apdu)
|
sizeof(response_apdu)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rapdu_length <= 6
|
if (rapdu_length <= 6
|
||||||
|| response_apdu[rapdu_length - 4] != 0x90
|
|| response_apdu[rapdu_length - 4] != 0x90
|
||||||
|
@ -325,11 +325,11 @@ void EPA_PACE_Collect_Nonce(PacketCommandNG *c) {
|
||||||
|
|
||||||
// now get the nonce
|
// now get the nonce
|
||||||
uint8_t nonce[256] = {0};
|
uint8_t nonce[256] = {0};
|
||||||
|
|
||||||
struct p {
|
struct p {
|
||||||
uint32_t m;
|
uint32_t m;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct p *packet = (struct p*)c->data.asBytes;
|
struct p *packet = (struct p *)c->data.asBytes;
|
||||||
|
|
||||||
func_return = EPA_PACE_Get_Nonce(packet->m, nonce);
|
func_return = EPA_PACE_Get_Nonce(packet->m, nonce);
|
||||||
// check if the command succeeded
|
// check if the command succeeded
|
||||||
|
@ -359,7 +359,7 @@ int EPA_PACE_Get_Nonce(uint8_t requested_length, uint8_t *nonce) {
|
||||||
|
|
||||||
// copy the constant part
|
// copy the constant part
|
||||||
memcpy(apdu, apdu_general_authenticate_pace_get_nonce, sizeof(apdu_general_authenticate_pace_get_nonce));
|
memcpy(apdu, apdu_general_authenticate_pace_get_nonce, sizeof(apdu_general_authenticate_pace_get_nonce));
|
||||||
|
|
||||||
// append Le (requested length + 2 due to tag/length taking 2 bytes) in RAPDU
|
// append Le (requested length + 2 due to tag/length taking 2 bytes) in RAPDU
|
||||||
apdu[sizeof(apdu_general_authenticate_pace_get_nonce)] = requested_length + 4;
|
apdu[sizeof(apdu_general_authenticate_pace_get_nonce)] = requested_length + 4;
|
||||||
|
|
||||||
|
@ -444,8 +444,8 @@ int EPA_PACE_MSE_Set_AT(pace_version_info_t pace_version_info, uint8_t password)
|
||||||
// check if the command succeeded
|
// check if the command succeeded
|
||||||
if (send_return != 6)
|
if (send_return != 6)
|
||||||
// && response_apdu[send_return - 4] != 0x90
|
// && response_apdu[send_return - 4] != 0x90
|
||||||
// || response_apdu[send_return - 3] != 0x00)
|
// || response_apdu[send_return - 3] != 0x00)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -500,7 +500,7 @@ void EPA_PACE_Replay(PacketCommandNG *c) {
|
||||||
apdu_lengths_replay[i],
|
apdu_lengths_replay[i],
|
||||||
response_apdu,
|
response_apdu,
|
||||||
sizeof(response_apdu)
|
sizeof(response_apdu)
|
||||||
);
|
);
|
||||||
timings[i] = GetCountUS();
|
timings[i] = GetCountUS();
|
||||||
// every step but the last one should succeed
|
// every step but the last one should succeed
|
||||||
if (i < ARRAYLEN(apdu_lengths_replay) - 1
|
if (i < ARRAYLEN(apdu_lengths_replay) - 1
|
||||||
|
|
|
@ -133,10 +133,10 @@ static hf14a_config hf14aconfig = { 0, 0, 0, 0 } ;
|
||||||
|
|
||||||
void printHf14aConfig(void) {
|
void printHf14aConfig(void) {
|
||||||
DbpString(_CYAN_("HF 14a config"));
|
DbpString(_CYAN_("HF 14a config"));
|
||||||
Dbprintf("[a] Anticol override......%s%s%s", (hf14aconfig.forceanticol==0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forceanticol==1) ? _RED_("Yes: Always do anticol") : "", (hf14aconfig.forceanticol==2) ? _RED_("Yes: Always skip anticol") : "");
|
Dbprintf("[a] Anticol override......%s%s%s", (hf14aconfig.forceanticol == 0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forceanticol == 1) ? _RED_("Yes: Always do anticol") : "", (hf14aconfig.forceanticol == 2) ? _RED_("Yes: Always skip anticol") : "");
|
||||||
Dbprintf("[b] BCC override..........%s%s%s", (hf14aconfig.forcebcc==0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forcebcc==1) ? _RED_("Yes: Always do CL2") : "", (hf14aconfig.forcebcc==2) ? _RED_("Yes: Always use card BCC") : "");
|
Dbprintf("[b] BCC override..........%s%s%s", (hf14aconfig.forcebcc == 0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forcebcc == 1) ? _RED_("Yes: Always do CL2") : "", (hf14aconfig.forcebcc == 2) ? _RED_("Yes: Always use card BCC") : "");
|
||||||
Dbprintf("[2] CL2 override..........%s%s%s", (hf14aconfig.forcecl2==0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forcecl2==1) ? _RED_("Yes: Always do CL2") : "", (hf14aconfig.forcecl2==2) ? _RED_("Yes: Always skip CL2") : "");
|
Dbprintf("[2] CL2 override..........%s%s%s", (hf14aconfig.forcecl2 == 0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forcecl2 == 1) ? _RED_("Yes: Always do CL2") : "", (hf14aconfig.forcecl2 == 2) ? _RED_("Yes: Always skip CL2") : "");
|
||||||
Dbprintf("[3] CL3 override..........%s%s%s", (hf14aconfig.forcecl3==0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forcecl3==1) ? _RED_("Yes: Always do CL3") : "", (hf14aconfig.forcecl3==2) ? _RED_("Yes: Always skip CL3") : "");
|
Dbprintf("[3] CL3 override..........%s%s%s", (hf14aconfig.forcecl3 == 0) ? _GREEN_("No") " (follow standard)" : "", (hf14aconfig.forcecl3 == 1) ? _RED_("Yes: Always do CL3") : "", (hf14aconfig.forcecl3 == 2) ? _RED_("Yes: Always skip CL3") : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2401,10 +2401,10 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
||||||
memset(uid_ptr, 0, 10);
|
memset(uid_ptr, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hf14aconfig.forceanticol == 0 ) {
|
if (hf14aconfig.forceanticol == 0) {
|
||||||
// check for proprietary anticollision:
|
// check for proprietary anticollision:
|
||||||
if ((resp[0] & 0x1F) == 0) return 3;
|
if ((resp[0] & 0x1F) == 0) return 3;
|
||||||
} else if ( hf14aconfig.forceanticol == 2 ) {
|
} else if (hf14aconfig.forceanticol == 2) {
|
||||||
return 3; // force skipping anticol
|
return 3; // force skipping anticol
|
||||||
} // else force executing
|
} // else force executing
|
||||||
|
|
||||||
|
@ -2479,10 +2479,10 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
||||||
uint8_t bcc = sel_uid[2] ^ sel_uid[3] ^ sel_uid[4] ^ sel_uid[5]; // calculate BCC
|
uint8_t bcc = sel_uid[2] ^ sel_uid[3] ^ sel_uid[4] ^ sel_uid[5]; // calculate BCC
|
||||||
if (sel_uid[6] != bcc) {
|
if (sel_uid[6] != bcc) {
|
||||||
Dbprintf("BCC%d incorrect, got 0x%02x, expected 0x%02x", cascade_level, sel_uid[6], bcc);
|
Dbprintf("BCC%d incorrect, got 0x%02x, expected 0x%02x", cascade_level, sel_uid[6], bcc);
|
||||||
if (hf14aconfig.forcebcc==0) {
|
if (hf14aconfig.forcebcc == 0) {
|
||||||
Dbprintf("Aborting");
|
Dbprintf("Aborting");
|
||||||
return 0;
|
return 0;
|
||||||
} else if (hf14aconfig.forcebcc==1) {
|
} else if (hf14aconfig.forcebcc == 1) {
|
||||||
sel_uid[6] = bcc;
|
sel_uid[6] = bcc;
|
||||||
} // else use card BCC
|
} // else use card BCC
|
||||||
Dbprintf("Using BCC=" _YELLOW_("0x%02x") " to perform anticollision", sel_uid[6]);
|
Dbprintf("Using BCC=" _YELLOW_("0x%02x") " to perform anticollision", sel_uid[6]);
|
||||||
|
@ -2504,16 +2504,16 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
||||||
|
|
||||||
// Test if more parts of the uid are coming
|
// Test if more parts of the uid are coming
|
||||||
do_cascade = (((sak & 0x04) /* && uid_resp[0] == 0x88 */) > 0);
|
do_cascade = (((sak & 0x04) /* && uid_resp[0] == 0x88 */) > 0);
|
||||||
if (cascade_level==0) {
|
if (cascade_level == 0) {
|
||||||
if (hf14aconfig.forcecl2==2) {
|
if (hf14aconfig.forcecl2 == 2) {
|
||||||
do_cascade = false;
|
do_cascade = false;
|
||||||
} else if (hf14aconfig.forcecl2==1) {
|
} else if (hf14aconfig.forcecl2 == 1) {
|
||||||
do_cascade = true;
|
do_cascade = true;
|
||||||
} // else 0==auto
|
} // else 0==auto
|
||||||
} else if (cascade_level==1) {
|
} else if (cascade_level == 1) {
|
||||||
if (hf14aconfig.forcecl3==2) {
|
if (hf14aconfig.forcecl3 == 2) {
|
||||||
do_cascade = false;
|
do_cascade = false;
|
||||||
} else if (hf14aconfig.forcecl3==1) {
|
} else if (hf14aconfig.forcecl3 == 1) {
|
||||||
do_cascade = true;
|
do_cascade = true;
|
||||||
} // else 0==auto
|
} // else 0==auto
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@
|
||||||
# define FWT_TIMEOUT_14B 35312
|
# define FWT_TIMEOUT_14B 35312
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 330/848kHz = 1558us / 4 == 400us,
|
// 330/848kHz = 1558us / 4 == 400us,
|
||||||
#define ISO14443B_READER_TIMEOUT 1700 //330
|
#define ISO14443B_READER_TIMEOUT 1700 //330
|
||||||
|
|
||||||
// 1024/3.39MHz = 302.1us between end of tag response and next reader cmd
|
// 1024/3.39MHz = 302.1us between end of tag response and next reader cmd
|
||||||
#define DELAY_ISO14443B_VICC_TO_VCD_READER 600 // 1024
|
#define DELAY_ISO14443B_VICC_TO_VCD_READER 600 // 1024
|
||||||
#define DELAY_ISO14443B_VCD_TO_VICC_READER 600// 1056
|
#define DELAY_ISO14443B_VCD_TO_VICC_READER 600// 1056
|
||||||
|
|
||||||
#ifndef RECEIVE_MASK
|
#ifndef RECEIVE_MASK
|
||||||
# define RECEIVE_MASK (DMA_BUFFER_SIZE - 1)
|
# define RECEIVE_MASK (DMA_BUFFER_SIZE - 1)
|
||||||
|
@ -740,7 +740,7 @@ void SimulateIso14443bTag(uint32_t pupi) {
|
||||||
*/
|
*/
|
||||||
static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) {
|
static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) {
|
||||||
|
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
// The soft decision on the bit uses an estimate of just the
|
// The soft decision on the bit uses an estimate of just the
|
||||||
// quadrant of the reference angle, not the exact angle.
|
// quadrant of the reference angle, not the exact angle.
|
||||||
|
@ -761,137 +761,137 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) {
|
||||||
// Subcarrier amplitude v = sqrt(ci^2 + cq^2), approximated here by max(abs(ci),abs(cq)) + 1/2*min(abs(ci),abs(cq)))
|
// Subcarrier amplitude v = sqrt(ci^2 + cq^2), approximated here by max(abs(ci),abs(cq)) + 1/2*min(abs(ci),abs(cq)))
|
||||||
#define AMPLITUDE(ci,cq) (MAX(ABS(ci),ABS(cq)) + (MIN(ABS(ci),ABS(cq))/2))
|
#define AMPLITUDE(ci,cq) (MAX(ABS(ci),ABS(cq)) + (MIN(ABS(ci),ABS(cq))/2))
|
||||||
|
|
||||||
switch(Demod.state) {
|
switch (Demod.state) {
|
||||||
|
|
||||||
case DEMOD_UNSYNCD: {
|
case DEMOD_UNSYNCD: {
|
||||||
if (AMPLITUDE(ci, cq) > SUBCARRIER_DETECT_THRESHOLD) { // subcarrier detected
|
if (AMPLITUDE(ci, cq) > SUBCARRIER_DETECT_THRESHOLD) { // subcarrier detected
|
||||||
Demod.state = DEMOD_PHASE_REF_TRAINING;
|
Demod.state = DEMOD_PHASE_REF_TRAINING;
|
||||||
Demod.sumI = ci;
|
Demod.sumI = ci;
|
||||||
Demod.sumQ = cq;
|
Demod.sumQ = cq;
|
||||||
Demod.posCount = 1;
|
Demod.posCount = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEMOD_PHASE_REF_TRAINING: {
|
case DEMOD_PHASE_REF_TRAINING: {
|
||||||
if (Demod.posCount < 8) {
|
if (Demod.posCount < 8) {
|
||||||
if (AMPLITUDE(ci, cq) > SUBCARRIER_DETECT_THRESHOLD) {
|
if (AMPLITUDE(ci, cq) > SUBCARRIER_DETECT_THRESHOLD) {
|
||||||
// set the reference phase (will code a logic '1') by averaging over 32 1/fs.
|
// set the reference phase (will code a logic '1') by averaging over 32 1/fs.
|
||||||
// note: synchronization time > 80 1/fs
|
// note: synchronization time > 80 1/fs
|
||||||
Demod.sumI += ci;
|
Demod.sumI += ci;
|
||||||
Demod.sumQ += cq;
|
Demod.sumQ += cq;
|
||||||
Demod.posCount++;
|
Demod.posCount++;
|
||||||
} else {
|
} else {
|
||||||
// subcarrier lost
|
// subcarrier lost
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Demod.state = DEMOD_AWAITING_FALLING_EDGE_OF_SOF;
|
Demod.state = DEMOD_AWAITING_FALLING_EDGE_OF_SOF;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEMOD_AWAITING_FALLING_EDGE_OF_SOF: {
|
case DEMOD_AWAITING_FALLING_EDGE_OF_SOF: {
|
||||||
|
|
||||||
MAKE_SOFT_DECISION();
|
MAKE_SOFT_DECISION();
|
||||||
|
|
||||||
if (v < 0) { // logic '0' detected
|
if (v < 0) { // logic '0' detected
|
||||||
Demod.state = DEMOD_GOT_FALLING_EDGE_OF_SOF;
|
Demod.state = DEMOD_GOT_FALLING_EDGE_OF_SOF;
|
||||||
Demod.posCount = 0; // start of SOF sequence
|
Demod.posCount = 0; // start of SOF sequence
|
||||||
} else {
|
} else {
|
||||||
if (Demod.posCount > 200 / 4) { // maximum length of TR1 = 200 1/fs
|
if (Demod.posCount > 200 / 4) { // maximum length of TR1 = 200 1/fs
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Demod.posCount++;
|
Demod.posCount++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEMOD_GOT_FALLING_EDGE_OF_SOF: {
|
case DEMOD_GOT_FALLING_EDGE_OF_SOF: {
|
||||||
|
|
||||||
Demod.posCount++;
|
Demod.posCount++;
|
||||||
MAKE_SOFT_DECISION();
|
MAKE_SOFT_DECISION();
|
||||||
|
|
||||||
if (v > 0) {
|
if (v > 0) {
|
||||||
if (Demod.posCount < 9 * 2) { // low phase of SOF too short (< 9 etu). Note: spec is >= 10, but FPGA tends to "smear" edges
|
if (Demod.posCount < 9 * 2) { // low phase of SOF too short (< 9 etu). Note: spec is >= 10, but FPGA tends to "smear" edges
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
} else {
|
} else {
|
||||||
LED_C_ON(); // Got SOF
|
LED_C_ON(); // Got SOF
|
||||||
Demod.posCount = 0;
|
Demod.posCount = 0;
|
||||||
Demod.bitCount = 0;
|
Demod.bitCount = 0;
|
||||||
Demod.len = 0;
|
Demod.len = 0;
|
||||||
Demod.state = DEMOD_AWAITING_START_BIT;
|
Demod.state = DEMOD_AWAITING_START_BIT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Demod.posCount > 14 * 2) { // low phase of SOF too long (> 12 etu)
|
if (Demod.posCount > 14 * 2) { // low phase of SOF too long (> 12 etu)
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEMOD_AWAITING_START_BIT: {
|
case DEMOD_AWAITING_START_BIT: {
|
||||||
Demod.posCount++;
|
Demod.posCount++;
|
||||||
MAKE_SOFT_DECISION();
|
MAKE_SOFT_DECISION();
|
||||||
if (v > 0) {
|
if (v > 0) {
|
||||||
if (Demod.posCount > 6 * 2) { // max 19us between characters = 16 1/fs, max 3 etu after low phase of SOF = 24 1/fs
|
if (Demod.posCount > 6 * 2) { // max 19us between characters = 16 1/fs, max 3 etu after low phase of SOF = 24 1/fs
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
if (Demod.bitCount == 0 && Demod.len == 0) { // received SOF only, this is valid for iClass/Picopass
|
if (Demod.bitCount == 0 && Demod.len == 0) { // received SOF only, this is valid for iClass/Picopass
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // start bit detected
|
} else { // start bit detected
|
||||||
Demod.posCount = 1; // this was the first half
|
Demod.posCount = 1; // this was the first half
|
||||||
Demod.thisBit = v;
|
Demod.thisBit = v;
|
||||||
Demod.shiftReg = 0;
|
Demod.shiftReg = 0;
|
||||||
Demod.state = DEMOD_RECEIVING_DATA;
|
Demod.state = DEMOD_RECEIVING_DATA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEMOD_RECEIVING_DATA: {
|
case DEMOD_RECEIVING_DATA: {
|
||||||
|
|
||||||
MAKE_SOFT_DECISION();
|
MAKE_SOFT_DECISION();
|
||||||
|
|
||||||
if (Demod.posCount == 0) { // first half of bit
|
if (Demod.posCount == 0) { // first half of bit
|
||||||
Demod.thisBit = v;
|
Demod.thisBit = v;
|
||||||
Demod.posCount = 1;
|
Demod.posCount = 1;
|
||||||
} else { // second half of bit
|
} else { // second half of bit
|
||||||
Demod.thisBit += v;
|
Demod.thisBit += v;
|
||||||
|
|
||||||
Demod.shiftReg >>= 1;
|
Demod.shiftReg >>= 1;
|
||||||
if (Demod.thisBit > 0) { // logic '1'
|
if (Demod.thisBit > 0) { // logic '1'
|
||||||
Demod.shiftReg |= 0x200;
|
Demod.shiftReg |= 0x200;
|
||||||
}
|
}
|
||||||
|
|
||||||
Demod.bitCount++;
|
Demod.bitCount++;
|
||||||
if (Demod.bitCount == 10) {
|
if (Demod.bitCount == 10) {
|
||||||
|
|
||||||
uint16_t s = Demod.shiftReg;
|
uint16_t s = Demod.shiftReg;
|
||||||
|
|
||||||
if ((s & 0x200) && !(s & 0x001)) { // stop bit == '1', start bit == '0'
|
if ((s & 0x200) && !(s & 0x001)) { // stop bit == '1', start bit == '0'
|
||||||
Demod.output[Demod.len] = (s >> 1);
|
Demod.output[Demod.len] = (s >> 1);
|
||||||
Demod.len++;
|
Demod.len++;
|
||||||
Demod.bitCount = 0;
|
Demod.bitCount = 0;
|
||||||
Demod.state = DEMOD_AWAITING_START_BIT;
|
Demod.state = DEMOD_AWAITING_START_BIT;
|
||||||
} else {
|
} else {
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
if (s == 0x000) {
|
if (s == 0x000) {
|
||||||
// This is EOF (start, stop and all data bits == '0'
|
// This is EOF (start, stop and all data bits == '0'
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Demod.posCount = 0;
|
Demod.posCount = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
Demod.state = DEMOD_UNSYNCD;
|
Demod.state = DEMOD_UNSYNCD;
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -938,9 +938,9 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, int timeo
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile int8_t ci = *upTo >> 8;
|
volatile int8_t ci = *upTo >> 8;
|
||||||
volatile int8_t cq = *upTo;
|
volatile int8_t cq = *upTo;
|
||||||
upTo++;
|
upTo++;
|
||||||
|
|
||||||
// we have read all of the DMA buffer content.
|
// we have read all of the DMA buffer content.
|
||||||
if (upTo >= dma->buf + DMA_BUFFER_SIZE) {
|
if (upTo >= dma->buf + DMA_BUFFER_SIZE) {
|
||||||
|
|
||||||
|
@ -960,7 +960,7 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, int timeo
|
||||||
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dma->buf;
|
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dma->buf;
|
||||||
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
DbpString("stopped");
|
DbpString("stopped");
|
||||||
|
@ -993,9 +993,9 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, int timeo
|
||||||
|
|
||||||
if (Demod.len > 0) {
|
if (Demod.len > 0) {
|
||||||
uint32_t sof_time = *eof_time
|
uint32_t sof_time = *eof_time
|
||||||
- (Demod.len * 8 * 8 * 16) // time for byte transfers
|
- (Demod.len * 8 * 8 * 16) // time for byte transfers
|
||||||
- (32 * 16) // time for SOF transfer
|
- (32 * 16) // time for SOF transfer
|
||||||
- 0; // time for EOF transfer
|
- 0; // time for EOF transfer
|
||||||
LogTrace(Demod.output, Demod.len, (sof_time * 4), (*eof_time * 4), NULL, false);
|
LogTrace(Demod.output, Demod.len, (sof_time * 4), (*eof_time * 4), NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,9 +1006,9 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, int timeo
|
||||||
// Transmit the command (to the tag) that was placed in ToSend[].
|
// Transmit the command (to the tag) that was placed in ToSend[].
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static void TransmitFor14443b_AsReader(uint32_t *start_time) {
|
static void TransmitFor14443b_AsReader(uint32_t *start_time) {
|
||||||
|
|
||||||
tosend_t *ts = get_tosend();
|
tosend_t *ts = get_tosend();
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SEND_SHALLOW_MOD);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SEND_SHALLOW_MOD);
|
||||||
|
|
||||||
if (*start_time < DELAY_ARM_TO_TAG) {
|
if (*start_time < DELAY_ARM_TO_TAG) {
|
||||||
|
@ -1016,7 +1016,7 @@ static void TransmitFor14443b_AsReader(uint32_t *start_time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*start_time = (*start_time - DELAY_ARM_TO_TAG) & 0xfffffff0;
|
*start_time = (*start_time - DELAY_ARM_TO_TAG) & 0xfffffff0;
|
||||||
|
|
||||||
if (GetCountSspClk() > *start_time) { // we may miss the intended time
|
if (GetCountSspClk() > *start_time) { // we may miss the intended time
|
||||||
*start_time = (GetCountSspClk() + 16) & 0xfffffff0; // next possible time
|
*start_time = (GetCountSspClk() + 16) & 0xfffffff0; // next possible time
|
||||||
}
|
}
|
||||||
|
@ -1132,7 +1132,7 @@ static void CodeAndTransmit14443bAsReader(const uint8_t *cmd, int len, uint32_t
|
||||||
tosend_t *ts = get_tosend();
|
tosend_t *ts = get_tosend();
|
||||||
CodeIso14443bAsReader(cmd, len);
|
CodeIso14443bAsReader(cmd, len);
|
||||||
TransmitFor14443b_AsReader(start_time);
|
TransmitFor14443b_AsReader(start_time);
|
||||||
*eof_time = *start_time + (32 * (8 * ts->max));
|
*eof_time = *start_time + (32 * (8 * ts->max));
|
||||||
LogTrace(cmd, len, *start_time, *eof_time, NULL, true);
|
LogTrace(cmd, len, *start_time, *eof_time, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1152,12 +1152,12 @@ uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *r
|
||||||
memcpy(message_frame + 2, message, message_length);
|
memcpy(message_frame + 2, message, message_length);
|
||||||
// EDC (CRC)
|
// EDC (CRC)
|
||||||
AddCrc14B(message_frame, message_length + 2);
|
AddCrc14B(message_frame, message_length + 2);
|
||||||
|
|
||||||
// send
|
// send
|
||||||
uint32_t start_time = 0;
|
uint32_t start_time = 0;
|
||||||
uint32_t eof_time = 0;
|
uint32_t eof_time = 0;
|
||||||
CodeAndTransmit14443bAsReader(message_frame, sizeof(message_frame), &start_time, &eof_time);
|
CodeAndTransmit14443bAsReader(message_frame, sizeof(message_frame), &start_time, &eof_time);
|
||||||
|
|
||||||
// get response
|
// get response
|
||||||
if (response == NULL) {
|
if (response == NULL) {
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
|
@ -1191,7 +1191,7 @@ static uint8_t iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
uint8_t r_init[3] = {0x0};
|
uint8_t r_init[3] = {0x0};
|
||||||
uint8_t r_select[3] = {0x0};
|
uint8_t r_select[3] = {0x0};
|
||||||
uint8_t r_papid[10] = {0x0};
|
uint8_t r_papid[10] = {0x0};
|
||||||
|
|
||||||
uint32_t start_time = 0;
|
uint32_t start_time = 0;
|
||||||
uint32_t eof_time = 0;
|
uint32_t eof_time = 0;
|
||||||
CodeAndTransmit14443bAsReader(init_srx, sizeof(init_srx), &start_time, &eof_time);
|
CodeAndTransmit14443bAsReader(init_srx, sizeof(init_srx), &start_time, &eof_time);
|
||||||
|
@ -1211,7 +1211,7 @@ static uint8_t iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
// SELECT command (with space for CRC)
|
// SELECT command (with space for CRC)
|
||||||
uint8_t select_srx[] = { ISO14443B_SELECT, 0x00, 0x00, 0x00};
|
uint8_t select_srx[] = { ISO14443B_SELECT, 0x00, 0x00, 0x00};
|
||||||
select_srx[1] = r_init[0];
|
select_srx[1] = r_init[0];
|
||||||
|
|
||||||
AddCrc14B(select_srx, 2);
|
AddCrc14B(select_srx, 2);
|
||||||
|
|
||||||
start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER;
|
start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER;
|
||||||
|
@ -1242,7 +1242,7 @@ static uint8_t iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
|
|
||||||
start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER;
|
start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER;
|
||||||
CodeAndTransmit14443bAsReader(select_srx, 3, &start_time, &eof_time); // Only first three bytes for this one
|
CodeAndTransmit14443bAsReader(select_srx, 3, &start_time, &eof_time); // Only first three bytes for this one
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER;
|
eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r_papid, sizeof(r_papid), ISO14443B_READER_TIMEOUT, &eof_time);
|
retlen = Get14443bAnswerFromTag(r_papid, sizeof(r_papid), ISO14443B_READER_TIMEOUT, &eof_time);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
@ -1255,7 +1255,7 @@ static uint8_t iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
if (!check_crc(CRC_14443_B, r_papid, retlen)) {
|
if (!check_crc(CRC_14443_B, r_papid, retlen)) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card) {
|
if (card) {
|
||||||
card->uidlen = 8;
|
card->uidlen = 8;
|
||||||
memcpy(card->uid, r_papid, 8);
|
memcpy(card->uid, r_papid, 8);
|
||||||
|
@ -1312,7 +1312,7 @@ int iso14443b_select_card(iso14b_card_select_t *card) {
|
||||||
AddCrc14B(attrib, 9);
|
AddCrc14B(attrib, 9);
|
||||||
start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER;
|
start_time = eof_time + DELAY_ISO14443B_VICC_TO_VCD_READER;
|
||||||
CodeAndTransmit14443bAsReader(attrib, sizeof(attrib), &start_time, &eof_time);
|
CodeAndTransmit14443bAsReader(attrib, sizeof(attrib), &start_time, &eof_time);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER;
|
eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r_attrib, sizeof(r_attrib), ISO14443B_READER_TIMEOUT, &eof_time);
|
retlen = Get14443bAnswerFromTag(r_attrib, sizeof(r_attrib), ISO14443B_READER_TIMEOUT, &eof_time);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
@ -1423,10 +1423,10 @@ static bool ReadSTBlock(uint8_t blocknr, uint8_t *block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Dbprintf("Address=%02x, Contents=%08x, CRC=%04x",
|
Dbprintf("Address=%02x, Contents=%08x, CRC=%04x",
|
||||||
blocknr,
|
blocknr,
|
||||||
(r_block[3] << 24) + (r_block[2] << 16) + (r_block[1] << 8) + r_block[0],
|
(r_block[3] << 24) + (r_block[2] << 16) + (r_block[1] << 8) + r_block[0],
|
||||||
(r_block[4] << 8) + r_block[5]);
|
(r_block[4] << 8) + r_block[5]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1434,7 +1434,7 @@ void ReadSTMemoryIso14443b(uint16_t numofblocks) {
|
||||||
|
|
||||||
iso14443b_setup();
|
iso14443b_setup();
|
||||||
|
|
||||||
uint8_t *mem = BigBuf_malloc((numofblocks + 1) * 4 );
|
uint8_t *mem = BigBuf_malloc((numofblocks + 1) * 4);
|
||||||
|
|
||||||
iso14b_card_select_t card;
|
iso14b_card_select_t card;
|
||||||
uint8_t res = iso14443b_select_srx_card(&card);
|
uint8_t res = iso14443b_select_srx_card(&card);
|
||||||
|
@ -1450,15 +1450,15 @@ void ReadSTMemoryIso14443b(uint16_t numofblocks) {
|
||||||
|
|
||||||
for (uint8_t i = 0; i < numofblocks; i++) {
|
for (uint8_t i = 0; i < numofblocks; i++) {
|
||||||
|
|
||||||
if (ReadSTBlock(i, mem + ( i * 4)) == false) {
|
if (ReadSTBlock(i, mem + (i * 4)) == false) {
|
||||||
isOK = PM3_ETIMEOUT;
|
isOK = PM3_ETIMEOUT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// System area block (0xFF)
|
// System area block (0xFF)
|
||||||
if (ReadSTBlock(0xFF, mem + (numofblocks * 4)) == false)
|
if (ReadSTBlock(0xFF, mem + (numofblocks * 4)) == false)
|
||||||
isOK = PM3_ETIMEOUT;
|
isOK = PM3_ETIMEOUT;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
@ -1535,7 +1535,7 @@ void SniffIso14443b(void) {
|
||||||
bool reader_is_active = false;
|
bool reader_is_active = false;
|
||||||
bool expect_tag_answer = false;
|
bool expect_tag_answer = false;
|
||||||
int dma_start_time = 0;
|
int dma_start_time = 0;
|
||||||
|
|
||||||
// Count of samples received so far, so that we can include timing
|
// Count of samples received so far, so that we can include timing
|
||||||
int samples = 0;
|
int samples = 0;
|
||||||
|
|
||||||
|
@ -1544,7 +1544,7 @@ void SniffIso14443b(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
volatile int behind_by = ((uint16_t *)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
|
volatile int behind_by = ((uint16_t *)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
|
||||||
if (behind_by < 1) continue;
|
if (behind_by < 1) continue;
|
||||||
|
|
||||||
samples++;
|
samples++;
|
||||||
if (samples == 1) {
|
if (samples == 1) {
|
||||||
|
@ -1554,7 +1554,7 @@ void SniffIso14443b(void) {
|
||||||
|
|
||||||
volatile int8_t ci = *upTo >> 8;
|
volatile int8_t ci = *upTo >> 8;
|
||||||
volatile int8_t cq = *upTo;
|
volatile int8_t cq = *upTo;
|
||||||
upTo++;
|
upTo++;
|
||||||
|
|
||||||
// we have read all of the DMA buffer content.
|
// we have read all of the DMA buffer content.
|
||||||
if (upTo >= dma->buf + DMA_BUFFER_SIZE) {
|
if (upTo >= dma->buf + DMA_BUFFER_SIZE) {
|
||||||
|
@ -1575,7 +1575,7 @@ void SniffIso14443b(void) {
|
||||||
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dma->buf;
|
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dma->buf;
|
||||||
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
DbpString("Sniff stopped");
|
DbpString("Sniff stopped");
|
||||||
|
@ -1600,7 +1600,7 @@ void SniffIso14443b(void) {
|
||||||
Uart14bReset();
|
Uart14bReset();
|
||||||
Demod14bReset();
|
Demod14bReset();
|
||||||
reader_is_active = false;
|
reader_is_active = false;
|
||||||
expect_tag_answer = true;
|
expect_tag_answer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Handle14443bSampleFromReader(cq & 0x01)) {
|
if (Handle14443bSampleFromReader(cq & 0x01)) {
|
||||||
|
@ -1619,20 +1619,20 @@ void SniffIso14443b(void) {
|
||||||
reader_is_active = false;
|
reader_is_active = false;
|
||||||
expect_tag_answer = true;
|
expect_tag_answer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader_is_active = (Uart.state > STATE_14B_GOT_FALLING_EDGE_OF_SOF);
|
reader_is_active = (Uart.state > STATE_14B_GOT_FALLING_EDGE_OF_SOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to try decoding tag data if the reader is sending - and we cannot afford the time
|
// no need to try decoding tag data if the reader is sending - and we cannot afford the time
|
||||||
if (reader_is_active == false && expect_tag_answer) {
|
if (reader_is_active == false && expect_tag_answer) {
|
||||||
|
|
||||||
if (Handle14443bSamplesFromTag((ci >> 1), (cq >> 1))) {
|
if (Handle14443bSamplesFromTag((ci >> 1), (cq >> 1))) {
|
||||||
|
|
||||||
uint32_t eof_time = dma_start_time + (samples * 16); // - DELAY_TAG_TO_ARM_SNIFF; // end of EOF
|
uint32_t eof_time = dma_start_time + (samples * 16); // - DELAY_TAG_TO_ARM_SNIFF; // end of EOF
|
||||||
uint32_t sof_time = eof_time
|
uint32_t sof_time = eof_time
|
||||||
- Demod.len * 8 * 8 * 16 // time for byte transfers
|
- Demod.len * 8 * 8 * 16 // time for byte transfers
|
||||||
- (32 * 16) // time for SOF transfer
|
- (32 * 16) // time for SOF transfer
|
||||||
- 0; // time for EOF transfer
|
- 0; // time for EOF transfer
|
||||||
|
|
||||||
LogTrace(Demod.output, Demod.len, (sof_time * 4), (eof_time * 4), NULL, false);
|
LogTrace(Demod.output, Demod.len, (sof_time * 4), (eof_time * 4), NULL, false);
|
||||||
// And ready to receive another response.
|
// And ready to receive another response.
|
||||||
|
@ -1657,7 +1657,7 @@ void SniffIso14443b(void) {
|
||||||
Dbprintf(" DecodeTag posCount.....%d", Demod.posCount);
|
Dbprintf(" DecodeTag posCount.....%d", Demod.posCount);
|
||||||
Dbprintf(" DecodeReader State.....%d", Uart.state);
|
Dbprintf(" DecodeReader State.....%d", Uart.state);
|
||||||
Dbprintf(" DecodeReader byteCnt...%d", Uart.byteCnt);
|
Dbprintf(" DecodeReader byteCnt...%d", Uart.byteCnt);
|
||||||
Dbprintf(" DecodeReader posCount..%d", Uart.posCnt);
|
Dbprintf(" DecodeReader posCount..%d", Uart.posCnt);
|
||||||
Dbprintf(" Trace length..........." _YELLOW_("%d"), BigBuf_get_traceLen());
|
Dbprintf(" Trace length..........." _YELLOW_("%d"), BigBuf_get_traceLen());
|
||||||
DbpString("");
|
DbpString("");
|
||||||
}
|
}
|
||||||
|
@ -1703,17 +1703,17 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||||
int status;
|
int status;
|
||||||
uint32_t sendlen = sizeof(iso14b_card_select_t);
|
uint32_t sendlen = sizeof(iso14b_card_select_t);
|
||||||
iso14b_card_select_t card;
|
iso14b_card_select_t card;
|
||||||
|
|
||||||
if ((param & ISO14B_SELECT_STD) == ISO14B_SELECT_STD) {
|
if ((param & ISO14B_SELECT_STD) == ISO14B_SELECT_STD) {
|
||||||
status = iso14443b_select_card(&card);
|
status = iso14443b_select_card(&card);
|
||||||
reply_mix(CMD_HF_ISO14443B_COMMAND, status, sendlen, 0, (uint8_t*)&card, sendlen);
|
reply_mix(CMD_HF_ISO14443B_COMMAND, status, sendlen, 0, (uint8_t *)&card, sendlen);
|
||||||
// 0: OK -1: attrib fail, -2:crc fail,
|
// 0: OK -1: attrib fail, -2:crc fail,
|
||||||
if (status != 0) goto out;
|
if (status != 0) goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((param & ISO14B_SELECT_SR) == ISO14B_SELECT_SR) {
|
if ((param & ISO14B_SELECT_SR) == ISO14B_SELECT_SR) {
|
||||||
status = iso14443b_select_srx_card(&card);
|
status = iso14443b_select_srx_card(&card);
|
||||||
reply_mix(CMD_HF_ISO14443B_COMMAND, status, sendlen, 0, (uint8_t*)&card, sendlen);
|
reply_mix(CMD_HF_ISO14443B_COMMAND, status, sendlen, 0, (uint8_t *)&card, sendlen);
|
||||||
// 0: OK 2: demod fail, 3:crc fail,
|
// 0: OK 2: demod fail, 3:crc fail,
|
||||||
if (status > 0) goto out;
|
if (status > 0) goto out;
|
||||||
}
|
}
|
||||||
|
@ -1730,10 +1730,10 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||||
len += 2;
|
len += 2;
|
||||||
}
|
}
|
||||||
uint8_t buf[100] = {0};
|
uint8_t buf[100] = {0};
|
||||||
|
|
||||||
uint32_t start_time = 0;
|
uint32_t start_time = 0;
|
||||||
uint32_t eof_time = 0;
|
uint32_t eof_time = 0;
|
||||||
CodeAndTransmit14443bAsReader(cmd, len, &start_time, &eof_time);
|
CodeAndTransmit14443bAsReader(cmd, len, &start_time, &eof_time);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER;
|
eof_time += DELAY_ISO14443B_VCD_TO_VICC_READER;
|
||||||
status = Get14443bAnswerFromTag(buf, sizeof(buf), 5 * ISO14443B_READER_TIMEOUT, &eof_time); // raw
|
status = Get14443bAnswerFromTag(buf, sizeof(buf), 5 * ISO14443B_READER_TIMEOUT, &eof_time); // raw
|
||||||
|
|
|
@ -101,27 +101,27 @@ static uint16_t rx_frame_from_fpga(void) {
|
||||||
//
|
//
|
||||||
// Note: inlining this function would fail with -Os
|
// Note: inlining this function would fail with -Os
|
||||||
static bool rx_bit(void) {
|
static bool rx_bit(void) {
|
||||||
int32_t sum_cq = 0;
|
int32_t sum_cq = 0;
|
||||||
int32_t sum_ci = 0;
|
int32_t sum_ci = 0;
|
||||||
|
|
||||||
// skip first 5 I/Q pairs
|
// skip first 5 I/Q pairs
|
||||||
for(size_t i = 0; i<5; ++i) {
|
for (size_t i = 0; i < 5; ++i) {
|
||||||
(void)rx_frame_from_fpga();
|
(void)rx_frame_from_fpga();
|
||||||
}
|
}
|
||||||
|
|
||||||
// sample next 8 I/Q pairs
|
// sample next 8 I/Q pairs
|
||||||
for (uint8_t i = 0; i < 8; ++i) {
|
for (uint8_t i = 0; i < 8; ++i) {
|
||||||
uint16_t iq = rx_frame_from_fpga();
|
uint16_t iq = rx_frame_from_fpga();
|
||||||
int8_t ci = (int8_t)(iq >> 8);
|
int8_t ci = (int8_t)(iq >> 8);
|
||||||
int8_t cq = (int8_t)(iq & 0xff);
|
int8_t cq = (int8_t)(iq & 0xff);
|
||||||
sum_ci += ci;
|
sum_ci += ci;
|
||||||
sum_cq += cq;
|
sum_cq += cq;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate power
|
// calculate power
|
||||||
int32_t power = (MAX(ABS(sum_ci), ABS(sum_cq)) + (MIN(ABS(sum_ci), ABS(sum_cq)) >> 1));
|
int32_t power = (MAX(ABS(sum_ci), ABS(sum_cq)) + (MIN(ABS(sum_ci), ABS(sum_cq)) >> 1));
|
||||||
|
|
||||||
// compare average (power / 8) to threshold
|
// compare average (power / 8) to threshold
|
||||||
return ((power >> 3) > INPUT_THRESHOLD);
|
return ((power >> 3) > INPUT_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,12 +136,12 @@ static bool rx_bit(void) {
|
||||||
|
|
||||||
static void tx_bit(bool bit) {
|
static void tx_bit(bool bit) {
|
||||||
// insert pause
|
// insert pause
|
||||||
HIGH(GPIO_SSC_DOUT);
|
HIGH(GPIO_SSC_DOUT);
|
||||||
last_frame_end += RWD_TIME_PAUSE;
|
last_frame_end += RWD_TIME_PAUSE;
|
||||||
while (GET_TICKS < last_frame_end) { };
|
while (GET_TICKS < last_frame_end) { };
|
||||||
|
|
||||||
// return to carrier on, wait for bit periode to end
|
// return to carrier on, wait for bit periode to end
|
||||||
LOW(GPIO_SSC_DOUT);
|
LOW(GPIO_SSC_DOUT);
|
||||||
last_frame_end += (bit ? RWD_TIME_1 : RWD_TIME_0) - RWD_TIME_PAUSE;
|
last_frame_end += (bit ? RWD_TIME_1 : RWD_TIME_0) - RWD_TIME_PAUSE;
|
||||||
while (GET_TICKS < last_frame_end) { };
|
while (GET_TICKS < last_frame_end) { };
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,30 +459,30 @@ void LegicRfSimulate(uint8_t tagtype, bool send_reply) {
|
||||||
// configure ARM and FPGA
|
// configure ARM and FPGA
|
||||||
init_tag();
|
init_tag();
|
||||||
|
|
||||||
int res = PM3_SUCCESS;
|
int res = PM3_SUCCESS;
|
||||||
// verify command line input
|
// verify command line input
|
||||||
if (init_card(tagtype, &card) != PM3_SUCCESS) {
|
if (init_card(tagtype, &card) != PM3_SUCCESS) {
|
||||||
DbpString("Unknown tagtype to simulate");
|
DbpString("Unknown tagtype to simulate");
|
||||||
res = PM3_ESOFT;
|
res = PM3_ESOFT;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t counter = 0;
|
uint16_t counter = 0;
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
|
||||||
Dbprintf("Legic Prime, simulating uid: %02X%02X%02X%02X", legic_mem[0], legic_mem[1], legic_mem[2], legic_mem[3]);
|
Dbprintf("Legic Prime, simulating uid: %02X%02X%02X%02X", legic_mem[0], legic_mem[1], legic_mem[2], legic_mem[3]);
|
||||||
|
|
||||||
while (BUTTON_PRESS() == false) {
|
while (BUTTON_PRESS() == false) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
if (counter >= 2000) {
|
if (counter >= 2000) {
|
||||||
if (data_available()) {
|
if (data_available()) {
|
||||||
res = PM3_EOPABORTED;
|
res = PM3_EOPABORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
// wait for carrier, restart after timeout
|
// wait for carrier, restart after timeout
|
||||||
if (wait_for(RWD_PULSE, GetCountSspClk() + TAG_BIT_PERIOD) == false) {
|
if (wait_for(RWD_PULSE, GetCountSspClk() + TAG_BIT_PERIOD) == false) {
|
||||||
|
@ -511,9 +511,9 @@ OUT:
|
||||||
|
|
||||||
switch_off();
|
switch_off();
|
||||||
StopTicks();
|
StopTicks();
|
||||||
|
|
||||||
if (send_reply)
|
if (send_reply)
|
||||||
reply_ng(CMD_HF_LEGIC_SIMULATE, res, NULL, 0);
|
reply_ng(CMD_HF_LEGIC_SIMULATE, res, NULL, 0);
|
||||||
|
|
||||||
BigBuf_free_keep_EM();
|
BigBuf_free_keep_EM();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2084,7 +2084,7 @@ void T55xx_ChkPwds(uint8_t flags) {
|
||||||
baseline_faulty >>= 5;
|
baseline_faulty >>= 5;
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_DEBUG)
|
if (DBGLEVEL >= DBG_DEBUG)
|
||||||
Dbprintf("Baseline " _YELLOW_("%llu"), baseline_faulty);
|
Dbprintf("Baseline " _YELLOW_("%llu"), baseline_faulty);
|
||||||
|
|
||||||
uint8_t *pwds = BigBuf_get_EM_addr();
|
uint8_t *pwds = BigBuf_get_EM_addr();
|
||||||
uint16_t pwd_count = 0;
|
uint16_t pwd_count = 0;
|
||||||
|
@ -2147,7 +2147,7 @@ void T55xx_ChkPwds(uint8_t flags) {
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_DEBUG)
|
if (DBGLEVEL >= DBG_DEBUG)
|
||||||
Dbprintf("%08x has distance " _YELLOW_("%llu"), pwd, curr);
|
Dbprintf("%08x has distance " _YELLOW_("%llu"), pwd, curr);
|
||||||
|
|
||||||
if (curr > prev) {
|
if (curr > prev) {
|
||||||
idx = i;
|
idx = i;
|
||||||
prev = curr;
|
prev = curr;
|
||||||
|
@ -2165,7 +2165,7 @@ OUT:
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
reply_ng(CMD_LF_T55XX_CHK_PWDS, PM3_SUCCESS, (uint8_t*)&payload, sizeof(payload));
|
reply_ng(CMD_LF_T55XX_CHK_PWDS, PM3_SUCCESS, (uint8_t *)&payload, sizeof(payload));
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2509,7 +2509,7 @@ void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) {
|
||||||
WaitMS(20);
|
WaitMS(20);
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
|
||||||
// clear buffer now so it does not interfere with timing later
|
// clear buffer now so it does not interfere with timing later
|
||||||
BigBuf_Clear_ext(false);
|
BigBuf_Clear_ext(false);
|
||||||
|
|
||||||
|
@ -2530,7 +2530,7 @@ void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) {
|
||||||
WaitUS(400);
|
WaitUS(400);
|
||||||
|
|
||||||
DoPartialAcquisition(20, false, 6000, 1000);
|
DoPartialAcquisition(20, false, 6000, 1000);
|
||||||
|
|
||||||
StopTicks();
|
StopTicks();
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
reply_ng(CMD_LF_EM4X_READWORD, PM3_SUCCESS, NULL, 0);
|
reply_ng(CMD_LF_EM4X_READWORD, PM3_SUCCESS, NULL, 0);
|
||||||
|
@ -2565,7 +2565,7 @@ void EM4xWriteWord(uint8_t addr, uint32_t data, uint32_t pwd, uint8_t usepwd) {
|
||||||
|
|
||||||
// Wait 20ms for write to complete?
|
// Wait 20ms for write to complete?
|
||||||
WaitMS(7);
|
WaitMS(7);
|
||||||
|
|
||||||
DoPartialAcquisition(20, false, 6000, 1000);
|
DoPartialAcquisition(20, false, 6000, 1000);
|
||||||
|
|
||||||
StopTicks();
|
StopTicks();
|
||||||
|
@ -2626,19 +2626,19 @@ void Cotag(uint32_t arg0) {
|
||||||
|
|
||||||
// send COTAG start pulse
|
// send COTAG start pulse
|
||||||
// http://www.proxmark.org/forum/viewtopic.php?id=4455
|
// http://www.proxmark.org/forum/viewtopic.php?id=4455
|
||||||
/*
|
/*
|
||||||
ON(740) OFF(2035)
|
ON(740) OFF(2035)
|
||||||
ON(3330) OFF(2035)
|
ON(3330) OFF(2035)
|
||||||
ON(740) OFF(2035)
|
ON(740) OFF(2035)
|
||||||
ON(2000)
|
ON(2000)
|
||||||
*/
|
*/
|
||||||
ON(800) OFF(2200)
|
ON(800) OFF(2200)
|
||||||
ON(3600) OFF(2200)
|
ON(3600) OFF(2200)
|
||||||
ON(800) OFF(2200)
|
ON(800) OFF(2200)
|
||||||
ON(2000) // ON(3400)
|
ON(2000) // ON(3400)
|
||||||
|
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, LF_FREQ2DIV(66)); // 66kHz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, LF_FREQ2DIV(66)); // 66kHz
|
||||||
|
|
||||||
switch (rawsignal) {
|
switch (rawsignal) {
|
||||||
case 0: {
|
case 0: {
|
||||||
doCotagAcquisition();
|
doCotagAcquisition();
|
||||||
|
|
|
@ -303,14 +303,14 @@ uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, in
|
||||||
|
|
||||||
// threshold either high or low values 128 = center 0. if trigger = 178
|
// threshold either high or low values 128 = center 0. if trigger = 178
|
||||||
if (trigger_hit == false) {
|
if (trigger_hit == false) {
|
||||||
if ((trigger_threshold > 0) && (sample < (trigger_threshold + 128)) && (sample > (128 - trigger_threshold))) {
|
if ((trigger_threshold > 0) && (sample < (trigger_threshold + 128)) && (sample > (128 - trigger_threshold))) {
|
||||||
if (cancel_after > 0) {
|
if (cancel_after > 0) {
|
||||||
cancel_counter++;
|
cancel_counter++;
|
||||||
if (cancel_after == cancel_counter)
|
if (cancel_after == cancel_counter)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger_hit = true;
|
trigger_hit = true;
|
||||||
|
@ -539,12 +539,12 @@ void doCotagAcquisition(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
if (sample > COTAG_ONE_THRESHOLD) {
|
if (sample > COTAG_ONE_THRESHOLD) {
|
||||||
dest[i] = 255;
|
dest[i] = 255;
|
||||||
} else if (sample < COTAG_ZERO_THRESHOLD) {
|
} else if (sample < COTAG_ZERO_THRESHOLD) {
|
||||||
dest[i] = 0;
|
dest[i] = 0;
|
||||||
} else {
|
} else {
|
||||||
dest[i] = dest[i - 1];
|
dest[i] = dest[i - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ uint16_t doCotagAcquisitionManchester(uint8_t *dest, uint16_t destlen) {
|
||||||
|
|
||||||
if (dest == NULL)
|
if (dest == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dest[0] = 0;
|
dest[0] = 0;
|
||||||
|
|
||||||
bool firsthigh = false, firstlow = false;
|
bool firsthigh = false, firstlow = false;
|
||||||
|
|
|
@ -1708,10 +1708,10 @@ void MifareChkKeys(uint8_t *datain, uint8_t reserved_mem) {
|
||||||
|
|
||||||
uint16_t key_mem_available;
|
uint16_t key_mem_available;
|
||||||
if (reserved_mem)
|
if (reserved_mem)
|
||||||
key_mem_available = key_count * 6;
|
key_mem_available = key_count * 6;
|
||||||
else
|
else
|
||||||
key_mem_available = MIN((PM3_CMD_DATA_SIZE - 5), key_count * 6);
|
key_mem_available = MIN((PM3_CMD_DATA_SIZE - 5), key_count * 6);
|
||||||
|
|
||||||
key_count = key_mem_available / 6;
|
key_count = key_mem_available / 6;
|
||||||
|
|
||||||
datain += 5;
|
datain += 5;
|
||||||
|
@ -1965,7 +1965,7 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) {
|
||||||
for (uint8_t blockNo = 0; blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
|
for (uint8_t blockNo = 0; blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
|
||||||
if (mifare_classic_readblock(pcs, cuid, FirstBlockOfSector(sectorNo) + blockNo, dataoutbuf)) {
|
if (mifare_classic_readblock(pcs, cuid, FirstBlockOfSector(sectorNo) + blockNo, dataoutbuf)) {
|
||||||
retval = PM3_EPARTIAL;
|
retval = PM3_EPARTIAL;
|
||||||
|
|
||||||
if (DBGLEVEL > DBG_ERROR) Dbprintf("Error reading sector %2d block %2d", sectorNo, blockNo);
|
if (DBGLEVEL > DBG_ERROR) Dbprintf("Error reading sector %2d block %2d", sectorNo, blockNo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2062,12 +2062,12 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) {
|
||||||
errormsg = MAGIC_WIPE;
|
errormsg = MAGIC_WIPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t old_timeout = iso14a_get_timeout();
|
uint32_t old_timeout = iso14a_get_timeout();
|
||||||
|
|
||||||
// 2000 ms timeout
|
// 2000 ms timeout
|
||||||
// 13560000 / 1000 / (8 * 16) * timeout
|
// 13560000 / 1000 / (8 * 16) * timeout
|
||||||
iso14a_set_timeout(21190);
|
iso14a_set_timeout(21190);
|
||||||
|
|
||||||
ReaderTransmit(wipeC, sizeof(wipeC), NULL);
|
ReaderTransmit(wipeC, sizeof(wipeC), NULL);
|
||||||
if (!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
|
if (!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
|
||||||
|
@ -2075,7 +2075,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) {
|
||||||
errormsg = MAGIC_WIPE;
|
errormsg = MAGIC_WIPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iso14a_set_timeout(old_timeout);
|
iso14a_set_timeout(old_timeout);
|
||||||
|
|
||||||
mifare_classic_halt_ex(NULL);
|
mifare_classic_halt_ex(NULL);
|
||||||
}
|
}
|
||||||
|
@ -2255,12 +2255,12 @@ void MifareCIdent(void) {
|
||||||
if (memcmp(buf, "\x0D\x78\x00\x71\x02\x88\x49\xA1\x30\x20\x15\x06\x08\x56\x3D", 15) == 0) {
|
if (memcmp(buf, "\x0D\x78\x00\x71\x02\x88\x49\xA1\x30\x20\x15\x06\x08\x56\x3D", 15) == 0) {
|
||||||
isGen = MAGIC_GEN_2;
|
isGen = MAGIC_GEN_2;
|
||||||
}
|
}
|
||||||
// test for Ultralight magic gen2
|
// test for Ultralight magic gen2
|
||||||
if (memcmp(buf, "\x0A\x78\x00\x81\x02\xDB\xA0\xC1\x19\x40\x2A\xB5", 12) == 0) {
|
if (memcmp(buf, "\x0A\x78\x00\x81\x02\xDB\xA0\xC1\x19\x40\x2A\xB5", 12) == 0) {
|
||||||
isGen = MAGIC_GEN_2;
|
isGen = MAGIC_GEN_2;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
// test for Ultralight EV1 magic gen2
|
// test for Ultralight EV1 magic gen2
|
||||||
if (memcmp(buf, "\x85\x00\x00\xA0\x00\x00\x0A\xC3\x00\x04\x03\x01\x01\x00\x0B\x03\x41\xDF", 18) == 0) {
|
if (memcmp(buf, "\x85\x00\x00\xA0\x00\x00\x0A\xC3\x00\x04\x03\x01\x01\x00\x0B\x03\x41\xDF", 18) == 0) {
|
||||||
isGen = MAGIC_GEN_2;
|
isGen = MAGIC_GEN_2;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
|
|
|
@ -482,16 +482,16 @@ int rdv40_spiffs_read_as_symlink(char *filename, uint8_t *dst, uint32_t size, RD
|
||||||
sprintf(linkfilename, "%s.lnk", filename);
|
sprintf(linkfilename, "%s.lnk", filename);
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_DEBUG)
|
if (DBGLEVEL >= DBG_DEBUG)
|
||||||
Dbprintf("Linkk real filename is : " _YELLOW_("%s"), linkfilename);
|
Dbprintf("Linkk real filename is : " _YELLOW_("%s"), linkfilename);
|
||||||
|
|
||||||
read_from_spiffs((char *)linkfilename, (uint8_t *)linkdest, SPIFFS_OBJ_NAME_LEN);
|
read_from_spiffs((char *)linkfilename, (uint8_t *)linkdest, SPIFFS_OBJ_NAME_LEN);
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_DEBUG)
|
if (DBGLEVEL >= DBG_DEBUG)
|
||||||
Dbprintf("Symlink destination is : " _YELLOW_("%s"), linkdest);
|
Dbprintf("Symlink destination is : " _YELLOW_("%s"), linkdest);
|
||||||
|
|
||||||
read_from_spiffs((char *)linkdest, (uint8_t *)dst, size);
|
read_from_spiffs((char *)linkdest, (uint8_t *)dst, size);
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BEWARE ! This function is DESTRUCTIVE as it will UPDATE an existing symlink
|
// BEWARE ! This function is DESTRUCTIVE as it will UPDATE an existing symlink
|
||||||
// Since it creates a .lnk extension file it may be minor to mistake the order of arguments
|
// Since it creates a .lnk extension file it may be minor to mistake the order of arguments
|
||||||
|
@ -522,18 +522,18 @@ int rdv40_spiffs_make_symlink(char *linkdest, char *filename, RDV40SpiFFSSafetyL
|
||||||
int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level) {
|
int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level) {
|
||||||
RDV40_SPIFFS_SAFE_FUNCTION(
|
RDV40_SPIFFS_SAFE_FUNCTION(
|
||||||
RDV40SpiFFSFileType filetype = filetype_in_spiffs((char *)filename);
|
RDV40SpiFFSFileType filetype = filetype_in_spiffs((char *)filename);
|
||||||
switch (filetype) {
|
switch (filetype) {
|
||||||
case RDV40_SPIFFS_FILETYPE_REAL:
|
case RDV40_SPIFFS_FILETYPE_REAL:
|
||||||
rdv40_spiffs_read((char *)filename, (uint8_t *)dst, size, level);
|
rdv40_spiffs_read((char *)filename, (uint8_t *)dst, size, level);
|
||||||
break;
|
break;
|
||||||
case RDV40_SPIFFS_FILETYPE_SYMLINK:
|
case RDV40_SPIFFS_FILETYPE_SYMLINK:
|
||||||
rdv40_spiffs_read_as_symlink((char *)filename, (uint8_t *)dst, size, level);
|
rdv40_spiffs_read_as_symlink((char *)filename, (uint8_t *)dst, size, level);
|
||||||
break;
|
break;
|
||||||
case RDV40_SPIFFS_FILETYPE_BOTH:
|
case RDV40_SPIFFS_FILETYPE_BOTH:
|
||||||
case RDV40_SPIFFS_FILETYPE_UNKNOWN:
|
case RDV40_SPIFFS_FILETYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,16 +166,16 @@ int CmdHFSearch(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PROMPT_CLEARLINE;
|
PROMPT_CLEARLINE;
|
||||||
PrintAndLogEx(INPLACE, " Searching for FeliCa tag...");
|
PrintAndLogEx(INPLACE, " Searching for FeliCa tag...");
|
||||||
if (IfPm3Felica()) {
|
if (IfPm3Felica()) {
|
||||||
if (readFelicaUid(false) == PM3_SUCCESS) {
|
if (readFelicaUid(false) == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(NORMAL, "\nValid " _GREEN_("ISO18092 / FeliCa tag") " found\n");
|
PrintAndLogEx(NORMAL, "\nValid " _GREEN_("ISO18092 / FeliCa tag") " found\n");
|
||||||
res = PM3_SUCCESS;
|
res = PM3_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
PROMPT_CLEARLINE;
|
PROMPT_CLEARLINE;
|
||||||
PrintAndLogEx(INPLACE, " Searching for CryptoRF tag...");
|
PrintAndLogEx(INPLACE, " Searching for CryptoRF tag...");
|
||||||
|
|
|
@ -114,7 +114,7 @@ static int usage_hf_14b_dump(void) {
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
_YELLOW_("\thf 14b dump f\n")
|
_YELLOW_("\thf 14b dump f\n")
|
||||||
_YELLOW_("\thf 14b dump 2 f mydump")
|
_YELLOW_("\thf 14b dump 2 f mydump")
|
||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ static int CmdHF14BReadSri(const char *Cmd) {
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_SRI_READ, blocks, 0, 0, NULL, 0);
|
SendCommandMIX(CMD_HF_SRI_READ, blocks, 0, 0, NULL, 0);
|
||||||
|
|
||||||
// iceman: should download read data and print in client.
|
// iceman: should download read data and print in client.
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
||||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
bool is_valid = false;
|
bool is_valid = false;
|
||||||
for (i = 0; i < ARRAYLEN(nxp_15693_public_keys); i++) {
|
for (i = 0; i < ARRAYLEN(nxp_15693_public_keys); i++) {
|
||||||
|
@ -526,7 +526,7 @@ static bool getUID(bool loop, uint8_t *buf) {
|
||||||
|
|
||||||
int resplen = resp.oldarg[0];
|
int resplen = resp.oldarg[0];
|
||||||
if (resplen >= 12 && CheckCrc15(resp.data.asBytes, 12)) {
|
if (resplen >= 12 && CheckCrc15(resp.data.asBytes, 12)) {
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
memcpy(buf, resp.data.asBytes + 2, 8);
|
memcpy(buf, resp.data.asBytes + 2, 8);
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ static int CmdHF15Sniff(const char *Cmd) {
|
||||||
SendCommandNG(CMD_HF_ISO15693_SNIFF, NULL, 0);
|
SendCommandNG(CMD_HF_ISO15693_SNIFF, NULL, 0);
|
||||||
|
|
||||||
WaitForResponse(CMD_HF_ISO15693_SNIFF, &resp);
|
WaitForResponse(CMD_HF_ISO15693_SNIFF, &resp);
|
||||||
|
|
||||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf 15 list") "` to view captured tracelog");
|
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf 15 list") "` to view captured tracelog");
|
||||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("trace save h") "` to save tracelog for later analysing");
|
PrintAndLogEx(HINT, "Try `" _YELLOW_("trace save h") "` to save tracelog for later analysing");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -1024,7 +1024,7 @@ static int CmdHF15Sim(const char *Cmd) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_ISO15693_SIMULATE, (uint8_t*)&payload, sizeof(payload));
|
SendCommandNG(CMD_HF_ISO15693_SIMULATE, (uint8_t *)&payload, sizeof(payload));
|
||||||
WaitForResponse(CMD_HF_ISO15693_SIMULATE, &resp);
|
WaitForResponse(CMD_HF_ISO15693_SIMULATE, &resp);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1358,7 @@ static int CmdHF15Raw(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_ISO15693_COMMAND, datalen, fast, reply, data, datalen);
|
SendCommandMIX(CMD_HF_ISO15693_COMMAND, datalen, fast, reply, data, datalen);
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
@ -1442,7 +1442,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *data = resp.data.asBytes;
|
uint8_t *data = resp.data.asBytes;
|
||||||
|
|
||||||
if (CheckCrc15(data, status) == false) {
|
if (CheckCrc15(data, status) == false) {
|
||||||
PrintAndLogEx(FAILED, "crc (" _RED_("fail") ")");
|
PrintAndLogEx(FAILED, "crc (" _RED_("fail") ")");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
@ -1741,7 +1741,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
PrintAndLogEx(INFO, "done");
|
PrintAndLogEx(INFO, "done");
|
||||||
PrintAndLogEx(HINT, "try `" _YELLOW_("hf 15 dump") "` to read your card to verify" );
|
PrintAndLogEx(HINT, "try `" _YELLOW_("hf 15 dump") "` to read your card to verify");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1779,10 +1779,10 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "updating tag uid...");
|
PrintAndLogEx(INFO, "updating tag uid...");
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_ISO15693_CSETUID, (uint8_t*)&payload, sizeof(payload));
|
SendCommandNG(CMD_HF_ISO15693_CSETUID, (uint8_t *)&payload, sizeof(payload));
|
||||||
|
|
||||||
if (WaitForResponseTimeout(CMD_HF_ISO15693_CSETUID, &resp, 2000) == false) {
|
if (WaitForResponseTimeout(CMD_HF_ISO15693_CSETUID, &resp, 2000) == false) {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply");
|
PrintAndLogEx(WARNING, "timeout while waiting for reply");
|
||||||
|
@ -1799,10 +1799,10 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
uint8_t revuid[8] = {0};
|
uint8_t revuid[8] = {0};
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
while (i < sizeof(revuid)) {
|
while (i < sizeof(revuid)) {
|
||||||
revuid[i] = carduid[7-i];
|
revuid[i] = carduid[7 - i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(revuid, payload.uid, 8) != 0) {
|
if (memcmp(revuid, payload.uid, 8) != 0) {
|
||||||
PrintAndLogEx(FAILED, "setting new UID (" _RED_("failed") ")");
|
PrintAndLogEx(FAILED, "setting new UID (" _RED_("failed") ")");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
|
|
@ -59,7 +59,7 @@ static int usage_hf_cryptorf_sniff(void) {
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_sim(void) {
|
static int usage_hf_cryptorf_sim(void) {
|
||||||
PrintAndLogEx(NORMAL, "Emulating CryptoRF tag with emulator memory\n"
|
PrintAndLogEx(NORMAL, "Emulating CryptoRF tag with emulator memory\n"
|
||||||
"Usage: hf cryptorf sim [h] \n"
|
"Usage: hf cryptorf sim [h] \n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
@ -26,16 +26,16 @@ static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static int usage_epa_collect(void) {
|
static int usage_epa_collect(void) {
|
||||||
PrintAndLogEx(NORMAL, "Tries to collect nonces when doing part of PACE protocol.\n"
|
PrintAndLogEx(NORMAL, "Tries to collect nonces when doing part of PACE protocol.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: hf epa cnonces <m> <n> <d>\n"
|
"Usage: hf epa cnonces <m> <n> <d>\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t<m> nonce size\n"
|
"\t<m> nonce size\n"
|
||||||
"\t<n> number of nonces to collect\n"
|
"\t<n> number of nonces to collect\n"
|
||||||
"\t<d> delay between\n"
|
"\t<d> delay between\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
_YELLOW_("\thf epa cnonces 4 4 1")
|
_YELLOW_("\thf epa cnonces 4 4 1")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,18 +60,18 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Collecting %u %u byte nonces", n, m);
|
PrintAndLogEx(SUCCESS, "Collecting %u %u byte nonces", n, m);
|
||||||
PrintAndLogEx(SUCCESS, "Start: %" PRIu64, msclock() / 1000);
|
PrintAndLogEx(SUCCESS, "Start: %" PRIu64, msclock() / 1000);
|
||||||
|
|
||||||
struct p {
|
struct p {
|
||||||
uint32_t m;
|
uint32_t m;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
payload.m = m;
|
payload.m = m;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < n; i++) {
|
for (uint32_t i = 0; i < n; i++) {
|
||||||
// execute PACE
|
// execute PACE
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_EPA_COLLECT_NONCE, (uint8_t*)&payload, sizeof(payload));
|
SendCommandNG(CMD_HF_EPA_COLLECT_NONCE, (uint8_t *)&payload, sizeof(payload));
|
||||||
|
|
||||||
WaitForResponse(CMD_HF_EPA_COLLECT_NONCE, &resp);
|
WaitForResponse(CMD_HF_EPA_COLLECT_NONCE, &resp);
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
|
||||||
sleep(d);
|
sleep(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "End: %" PRIu64, msclock() / 1000);
|
PrintAndLogEx(SUCCESS, "End: %" PRIu64, msclock() / 1000);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ static int cmp_uint32(const void *a, const void *b) {
|
||||||
return mx > my;
|
return mx > my;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_known_default(uint8_t *csn, uint8_t *epurse, uint8_t* rmac, uint8_t* tmac, uint8_t* key) {
|
bool check_known_default(uint8_t *csn, uint8_t *epurse, uint8_t *rmac, uint8_t *tmac, uint8_t *key) {
|
||||||
|
|
||||||
iclass_prekey_t *prekey = calloc(ICLASS_KEYS_MAX, sizeof(iclass_prekey_t));
|
iclass_prekey_t *prekey = calloc(ICLASS_KEYS_MAX, sizeof(iclass_prekey_t));
|
||||||
if (prekey == false) {
|
if (prekey == false) {
|
||||||
|
@ -399,14 +399,14 @@ bool check_known_default(uint8_t *csn, uint8_t *epurse, uint8_t* rmac, uint8_t*
|
||||||
memcpy(ccnr, epurse, 8);
|
memcpy(ccnr, epurse, 8);
|
||||||
memcpy(ccnr + 8, rmac, 4);
|
memcpy(ccnr + 8, rmac, 4);
|
||||||
|
|
||||||
GenerateMacKeyFrom(csn, ccnr, false, false, (uint8_t*)iClass_Key_Table, ICLASS_KEYS_MAX, prekey);
|
GenerateMacKeyFrom(csn, ccnr, false, false, (uint8_t *)iClass_Key_Table, ICLASS_KEYS_MAX, prekey);
|
||||||
qsort(prekey, ICLASS_KEYS_MAX, sizeof(iclass_prekey_t), cmp_uint32);
|
qsort(prekey, ICLASS_KEYS_MAX, sizeof(iclass_prekey_t), cmp_uint32);
|
||||||
|
|
||||||
iclass_prekey_t lookup;
|
iclass_prekey_t lookup;
|
||||||
memcpy(lookup.mac, tmac, 4);
|
memcpy(lookup.mac, tmac, 4);
|
||||||
|
|
||||||
// binsearch
|
// binsearch
|
||||||
iclass_prekey_t * item = (iclass_prekey_t *) bsearch(&lookup, prekey, ICLASS_KEYS_MAX, sizeof(iclass_prekey_t), cmp_uint32);
|
iclass_prekey_t *item = (iclass_prekey_t *) bsearch(&lookup, prekey, ICLASS_KEYS_MAX, sizeof(iclass_prekey_t), cmp_uint32);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
memcpy(key, item->key, 8);
|
memcpy(key, item->key, 8);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1268,7 +1268,7 @@ static int CmdHFiClassEView(const char *Cmd) {
|
||||||
free(dump);
|
free(dump);
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
print_picopass_header((picopass_hdr *) dump);
|
print_picopass_header((picopass_hdr *) dump);
|
||||||
print_picopass_info((picopass_hdr *) dump);
|
print_picopass_info((picopass_hdr *) dump);
|
||||||
|
@ -1279,18 +1279,18 @@ static int CmdHFiClassEView(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "------+----+-------------------------+----------");
|
PrintAndLogEx(INFO, "------+----+-------------------------+----------");
|
||||||
PrintAndLogEx(INFO, " CSN |0x00| " _GREEN_("%s") "|", sprint_hex(csn, 8));
|
PrintAndLogEx(INFO, " CSN |0x00| " _GREEN_("%s") "|", sprint_hex(csn, 8));
|
||||||
printIclassDumpContents(dump, 1, blocks, bytes);
|
printIclassDumpContents(dump, 1, blocks, bytes);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "----+-------------------------+---------");
|
PrintAndLogEx(INFO, "----+-------------------------+---------");
|
||||||
PrintAndLogEx(INFO, "blk | data | ascii");
|
PrintAndLogEx(INFO, "blk | data | ascii");
|
||||||
PrintAndLogEx(INFO, "----+-------------------------+---------");
|
PrintAndLogEx(INFO, "----+-------------------------+---------");
|
||||||
for (uint16_t i = 0; i < blocks; i++){
|
for (uint16_t i = 0; i < blocks; i++){
|
||||||
PrintAndLogEx(INFO, "%03d | %s ", i, sprint_hex_ascii(dump + (i * 8) , 8) );
|
PrintAndLogEx(INFO, "%03d | %s ", i, sprint_hex_ascii(dump + (i * 8) , 8) );
|
||||||
}
|
}
|
||||||
PrintAndLogEx(INFO, "----+-------------------------+---------");
|
PrintAndLogEx(INFO, "----+-------------------------+---------");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
*/
|
*/
|
||||||
free(dump);
|
free(dump);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2247,7 +2247,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||||
|
|
||||||
if (startblock < 5) {
|
if (startblock < 5) {
|
||||||
PrintAndLogEx(WARNING, "you cannot write key blocks this way. yet... make your start block > 4");
|
PrintAndLogEx(WARNING, "you cannot write key blocks this way. yet... make your start block > 4");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
int total_bytes = (((endblock - startblock) + 1) * 12);
|
int total_bytes = (((endblock - startblock) + 1) * 12);
|
||||||
|
|
|
@ -41,5 +41,5 @@ void PrintPreCalcMac(uint8_t *keys, uint32_t keycnt, iclass_premac_t *pre_list);
|
||||||
void PrintPreCalc(iclass_prekey_t *list, uint32_t itemcnt);
|
void PrintPreCalc(iclass_prekey_t *list, uint32_t itemcnt);
|
||||||
|
|
||||||
uint8_t get_pagemap(const picopass_hdr *hdr);
|
uint8_t get_pagemap(const picopass_hdr *hdr);
|
||||||
bool check_known_default(uint8_t *csn, uint8_t *epurse, uint8_t* rmac, uint8_t* tmac, uint8_t* key);
|
bool check_known_default(uint8_t *csn, uint8_t *epurse, uint8_t *rmac, uint8_t *tmac, uint8_t *key);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -590,13 +590,13 @@ static int CmdLegicSim(const char *Cmd) {
|
||||||
uint8_t tagtype;
|
uint8_t tagtype;
|
||||||
bool send_reply;
|
bool send_reply;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
|
|
||||||
payload.send_reply = true;
|
payload.send_reply = true;
|
||||||
payload.tagtype = param_get8ex(Cmd, 0, 1, 10);
|
payload.tagtype = param_get8ex(Cmd, 0, 1, 10);
|
||||||
if (payload.tagtype > 2 ) {
|
if (payload.tagtype > 2) {
|
||||||
return usage_legic_sim();
|
return usage_legic_sim();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_LEGIC_SIMULATE, (uint8_t *)&payload, sizeof(payload));
|
SendCommandNG(CMD_HF_LEGIC_SIMULATE, (uint8_t *)&payload, sizeof(payload));
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
@ -605,15 +605,15 @@ static int CmdLegicSim(const char *Cmd) {
|
||||||
bool keypress = kbd_enter_pressed();
|
bool keypress = kbd_enter_pressed();
|
||||||
while (keypress == false) {
|
while (keypress == false) {
|
||||||
keypress = kbd_enter_pressed();
|
keypress = kbd_enter_pressed();
|
||||||
|
|
||||||
if (WaitForResponseTimeout(CMD_HF_LEGIC_SIMULATE, &resp, 1500)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (WaitForResponseTimeout(CMD_HF_LEGIC_SIMULATE, &resp, 1500)) {
|
||||||
if (keypress)
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (keypress)
|
||||||
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
|
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Done");
|
PrintAndLogEx(INFO, "Done");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ void annotateIclass(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool
|
||||||
static uint8_t rmac[4];
|
static uint8_t rmac[4];
|
||||||
static uint8_t tmac[4];
|
static uint8_t tmac[4];
|
||||||
|
|
||||||
if ( isResponse == false ) {
|
if (isResponse == false) {
|
||||||
uint8_t c = cmd[0] & 0x0F;
|
uint8_t c = cmd[0] & 0x0F;
|
||||||
uint8_t parity = 0;
|
uint8_t parity = 0;
|
||||||
for (uint8_t i = 0; i < 7; i++) {
|
for (uint8_t i = 0; i < 7; i++) {
|
||||||
|
@ -409,17 +409,17 @@ void annotateIclass(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (curr_state == PICO_SELECT) {
|
if (curr_state == PICO_SELECT) {
|
||||||
memcpy(csn, cmd, 8);
|
memcpy(csn, cmd, 8);
|
||||||
curr_state = PICO_NONE;
|
curr_state = PICO_NONE;
|
||||||
} else if (curr_state == PICO_AUTH_EPURSE) {
|
} else if (curr_state == PICO_AUTH_EPURSE) {
|
||||||
memcpy(epurse, cmd, 8);
|
memcpy(epurse, cmd, 8);
|
||||||
} else if ( curr_state == PICO_AUTH_MACS) {
|
} else if (curr_state == PICO_AUTH_MACS) {
|
||||||
|
|
||||||
uint8_t key[8];
|
uint8_t key[8];
|
||||||
if (check_known_default(csn, epurse, rmac, tmac, key)) {
|
if (check_known_default(csn, epurse, rmac, tmac, key)) {
|
||||||
snprintf(exp, size, "( " _GREEN_("%s") ")", sprint_hex(key, 8) );
|
snprintf(exp, size, "( " _GREEN_("%s") ")", sprint_hex(key, 8));
|
||||||
}
|
}
|
||||||
curr_state = PICO_NONE;
|
curr_state = PICO_NONE;
|
||||||
}
|
}
|
||||||
|
@ -438,11 +438,11 @@ void annotateIso15693(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
snprintf(exp, size, "STAY_QUIET");
|
snprintf(exp, size, "STAY_QUIET");
|
||||||
return;
|
return;
|
||||||
case ISO15693_READBLOCK: {
|
case ISO15693_READBLOCK: {
|
||||||
|
|
||||||
uint8_t block = 0;
|
uint8_t block = 0;
|
||||||
if (cmdsize == 13)
|
if (cmdsize == 13)
|
||||||
block = cmd[10];
|
block = cmd[10];
|
||||||
|
|
||||||
snprintf(exp, size, "READBLOCK(%d)", block);
|
snprintf(exp, size, "READBLOCK(%d)", block);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ void annotateIso15693(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
|
|
||||||
if (cmd[1] > ISO15693_STAYQUIET && cmd[1] < ISO15693_READBLOCK) snprintf(exp, size, "Mandatory RFU");
|
if (cmd[1] > ISO15693_STAYQUIET && cmd[1] < ISO15693_READBLOCK) snprintf(exp, size, "Mandatory RFU");
|
||||||
else if (cmd[1] > ISO15693_READ_MULTI_SECSTATUS && cmd[1] <= 0x9F) snprintf(exp, size, "Optional RFU");
|
else if (cmd[1] > ISO15693_READ_MULTI_SECSTATUS && cmd[1] <= 0x9F) snprintf(exp, size, "Optional RFU");
|
||||||
// else if (cmd[1] >= 0xA0 && cmd[1] <= 0xDF) snprintf(exp, size, "Cust IC MFG dependent");
|
// else if (cmd[1] >= 0xA0 && cmd[1] <= 0xDF) snprintf(exp, size, "Cust IC MFG dependent");
|
||||||
else if (cmd[1] > ISO15693_READ_SIGNATURE && cmd[1] <= 0xDF) snprintf(exp, size, "Cust IC MFG dependent");
|
else if (cmd[1] > ISO15693_READ_SIGNATURE && cmd[1] <= 0xDF) snprintf(exp, size, "Cust IC MFG dependent");
|
||||||
else if (cmd[1] >= 0xE0) snprintf(exp, size, "Proprietary IC MFG dependent");
|
else if (cmd[1] >= 0xE0) snprintf(exp, size, "Proprietary IC MFG dependent");
|
||||||
else
|
else
|
||||||
|
@ -612,8 +612,8 @@ void annotateTopaz(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
// iso 7816-3
|
// iso 7816-3
|
||||||
void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
|
|
||||||
if (cmdsize < 2)
|
if (cmdsize < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// S-block
|
// S-block
|
||||||
if ((cmd[0] & 0xC0) && (cmdsize == 3)) {
|
if ((cmd[0] & 0xC0) && (cmdsize == 3)) {
|
||||||
|
@ -999,13 +999,13 @@ void annotateCryptoRF(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
break;
|
break;
|
||||||
case CRYPTORF_DESELECT:
|
case CRYPTORF_DESELECT:
|
||||||
snprintf(exp, size, "DESELECT");
|
snprintf(exp, size, "DESELECT");
|
||||||
break;
|
break;
|
||||||
case CRYPTORF_IDLE:
|
case CRYPTORF_IDLE:
|
||||||
snprintf(exp, size, "IDLE");
|
snprintf(exp, size, "IDLE");
|
||||||
break;
|
break;
|
||||||
case CRYPTORF_CHECK_PASSWORD:
|
case CRYPTORF_CHECK_PASSWORD:
|
||||||
snprintf(exp, size, "CHECK PWD");
|
snprintf(exp, size, "CHECK PWD");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snprintf(exp, size, "?");
|
snprintf(exp, size, "?");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -594,9 +594,9 @@ static int32_t initSectorTable(sector_t **src, int32_t items) {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode_print_st(uint16_t blockno, uint8_t* data) {
|
static void decode_print_st(uint16_t blockno, uint8_t *data) {
|
||||||
if (mfIsSectorTrailer(blockno)) {
|
if (mfIsSectorTrailer(blockno)) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Sector trailer decoded:");
|
PrintAndLogEx(NORMAL, "Sector trailer decoded:");
|
||||||
PrintAndLogEx(NORMAL, "----------------------------------------------");
|
PrintAndLogEx(NORMAL, "----------------------------------------------");
|
||||||
PrintAndLogEx(NORMAL, "Key A " _GREEN_("%s"), sprint_hex_inrow(data, 6));
|
PrintAndLogEx(NORMAL, "Key A " _GREEN_("%s"), sprint_hex_inrow(data, 6));
|
||||||
|
@ -756,7 +756,7 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data[6] || data[7] || data[8])) {
|
if ((data[6] || data[7] || data[8])) {
|
||||||
decode_print_st(blockNo, data);
|
decode_print_st(blockNo, data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -811,7 +811,7 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||||
if (isOK) {
|
if (isOK) {
|
||||||
|
|
||||||
uint8_t blocks = 4;
|
uint8_t blocks = 4;
|
||||||
uint8_t start = sectorNo * 4;
|
uint8_t start = sectorNo * 4;
|
||||||
if (sectorNo > 32) {
|
if (sectorNo > 32) {
|
||||||
|
@ -819,9 +819,9 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
|
||||||
start = 128 + (sectorNo - 32) * 16;
|
start = 128 + (sectorNo - 32) * 16;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < blocks; i++) {
|
for (int i = 0; i < blocks; i++) {
|
||||||
PrintAndLogEx(NORMAL, "%3d | %s", start + i, sprint_hex(data + (i * 16) , 16));
|
PrintAndLogEx(NORMAL, "%3d | %s", start + i, sprint_hex(data + (i * 16), 16));
|
||||||
}
|
}
|
||||||
decode_print_st(start + blocks - 1, data + ((blocks - 1) * 16) );
|
decode_print_st(start + blocks - 1, data + ((blocks - 1) * 16));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||||
|
@ -914,10 +914,10 @@ static int FastDumpWithEcFill(uint8_t numsectors) {
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp.status != PM3_SUCCESS) {
|
if (resp.status != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(INFO, "fast dump reported back failure w KEY A, swapping to KEY B");
|
PrintAndLogEx(INFO, "fast dump reported back failure w KEY A, swapping to KEY B");
|
||||||
|
|
||||||
// ecfill key B
|
// ecfill key B
|
||||||
payload.keytype = 1;
|
payload.keytype = 1;
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ static int FastDumpWithEcFill(uint8_t numsectors) {
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp.status != PM3_SUCCESS) {
|
if (resp.status != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(INFO, "fast dump reported back failure w KEY B");
|
PrintAndLogEx(INFO, "fast dump reported back failure w KEY B");
|
||||||
PrintAndLogEx(INFO, "Dump file is " _RED_("PARTIAL") " complete");
|
PrintAndLogEx(INFO, "Dump file is " _RED_("PARTIAL") " complete");
|
||||||
|
@ -2127,7 +2127,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
return prng_type;
|
return prng_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if tag doesn't have static nonce
|
// check if tag doesn't have static nonce
|
||||||
has_staticnonce = detect_classic_static_nonce();
|
has_staticnonce = detect_classic_static_nonce();
|
||||||
|
|
||||||
|
@ -2471,13 +2471,13 @@ noValidKeyFound:
|
||||||
} else {
|
} else {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(WARNING, "unknown B key: sector: %3d key type: %c",
|
PrintAndLogEx(WARNING, "unknown B key: sector: %3d key type: %c",
|
||||||
current_sector_i,
|
current_sector_i,
|
||||||
current_key_type_i ? 'B' : 'A'
|
current_key_type_i ? 'B' : 'A'
|
||||||
);
|
);
|
||||||
PrintAndLogEx(INFO, " -- reading the B key was not possible, maybe due to access rights?");
|
PrintAndLogEx(INFO, " -- reading the B key was not possible, maybe due to access rights?");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP READ B KEY ATTACK") " =======================");
|
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP READ B KEY ATTACK") " =======================");
|
||||||
|
@ -2489,7 +2489,7 @@ noValidKeyFound:
|
||||||
skipReadBKey:
|
skipReadBKey:
|
||||||
if (e_sector[current_sector_i].foundKey[current_key_type_i] == 0) {
|
if (e_sector[current_sector_i].foundKey[current_key_type_i] == 0) {
|
||||||
|
|
||||||
if (has_staticnonce)
|
if (has_staticnonce)
|
||||||
goto tryStaticnested;
|
goto tryStaticnested;
|
||||||
|
|
||||||
if (prng_type && (nested_failed == false)) {
|
if (prng_type && (nested_failed == false)) {
|
||||||
|
@ -2502,7 +2502,7 @@ skipReadBKey:
|
||||||
}
|
}
|
||||||
tryNested:
|
tryNested:
|
||||||
isOK = mfnested(FirstBlockOfSector(blockNo), keyType, key, FirstBlockOfSector(current_sector_i), current_key_type_i, tmp_key, calibrate);
|
isOK = mfnested(FirstBlockOfSector(blockNo), keyType, key, FirstBlockOfSector(current_sector_i), current_key_type_i, tmp_key, calibrate);
|
||||||
|
|
||||||
switch (isOK) {
|
switch (isOK) {
|
||||||
case PM3_ETIMEOUT: {
|
case PM3_ETIMEOUT: {
|
||||||
PrintAndLogEx(ERR, "\nError: No response from Proxmark3.");
|
PrintAndLogEx(ERR, "\nError: No response from Proxmark3.");
|
||||||
|
@ -2543,7 +2543,7 @@ tryNested:
|
||||||
PrintAndLogEx(ERR, "unknown Error.\n");
|
PrintAndLogEx(ERR, "unknown Error.\n");
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP NESTED ATTACK") " =======================");
|
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP NESTED ATTACK") " =======================");
|
||||||
|
@ -2588,16 +2588,16 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack
|
||||||
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP HARDNESTED ATTACK") " =======================");
|
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP HARDNESTED ATTACK") " =======================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_staticnonce) {
|
if (has_staticnonce) {
|
||||||
tryStaticnested:
|
tryStaticnested:
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "======================= " _YELLOW_("START STATIC NESTED ATTACK") " =======================");
|
PrintAndLogEx(INFO, "======================= " _YELLOW_("START STATIC NESTED ATTACK") " =======================");
|
||||||
PrintAndLogEx(INFO, "sector no: %3d, target key type: %c",
|
PrintAndLogEx(INFO, "sector no: %3d, target key type: %c",
|
||||||
current_sector_i,
|
current_sector_i,
|
||||||
current_key_type_i ? 'B' : 'A');
|
current_key_type_i ? 'B' : 'A');
|
||||||
}
|
}
|
||||||
|
|
||||||
isOK = mfStaticNested(blockNo, keyType, key, FirstBlockOfSector(current_sector_i), current_key_type_i, tmp_key);
|
isOK = mfStaticNested(blockNo, keyType, key, FirstBlockOfSector(current_sector_i), current_key_type_i, tmp_key);
|
||||||
DropField();
|
DropField();
|
||||||
switch (isOK) {
|
switch (isOK) {
|
||||||
|
@ -2620,12 +2620,12 @@ tryStaticnested:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP STATIC NESTED ATTACK") " =======================");
|
PrintAndLogEx(INFO, "======================= " _YELLOW_("STOP STATIC NESTED ATTACK") " =======================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the key was found
|
// Check if the key was found
|
||||||
if (e_sector[current_sector_i].foundKey[current_key_type_i]) {
|
if (e_sector[current_sector_i].foundKey[current_key_type_i]) {
|
||||||
PrintAndLogEx(SUCCESS, "target sector:%3u key type: %c -- found valid key [" _YELLOW_("%s") "]",
|
PrintAndLogEx(SUCCESS, "target sector:%3u key type: %c -- found valid key [" _YELLOW_("%s") "]",
|
||||||
|
@ -2657,7 +2657,7 @@ all_found:
|
||||||
// clear emulator mem
|
// clear emulator mem
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_MIFARE_EML_MEMCLR, NULL, 0);
|
SendCommandNG(CMD_HF_MIFARE_EML_MEMCLR, NULL, 0);
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "transferring keys to simulator memory (Cmd Error: 04 can occur)");
|
PrintAndLogEx(SUCCESS, "transferring keys to simulator memory (Cmd Error: 04 can occur)");
|
||||||
|
|
||||||
for (current_sector_i = 0; current_sector_i < sectors_cnt; current_sector_i++) {
|
for (current_sector_i = 0; current_sector_i < sectors_cnt; current_sector_i++) {
|
||||||
|
@ -3876,13 +3876,13 @@ static int CmdHF14AMfEView(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||||
PrintAndLogEx(INFO, "blk | data | ascii");
|
PrintAndLogEx(INFO, "blk | data | ascii");
|
||||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||||
for (uint16_t i = 0; i < blocks; i++){
|
for (uint16_t i = 0; i < blocks; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
PrintAndLogEx(INFO, "%03d | " _RED_("%s"), i, sprint_hex_ascii(dump + (i * 16) , 16) );
|
PrintAndLogEx(INFO, "%03d | " _RED_("%s"), i, sprint_hex_ascii(dump + (i * 16), 16));
|
||||||
} else if (mfIsSectorTrailer(i)) {
|
} else if (mfIsSectorTrailer(i)) {
|
||||||
PrintAndLogEx(INFO, "%03d | " _YELLOW_("%s"), i, sprint_hex_ascii(dump + (i * 16) , 16) );
|
PrintAndLogEx(INFO, "%03d | " _YELLOW_("%s"), i, sprint_hex_ascii(dump + (i * 16), 16));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "%03d | %s ", i, sprint_hex_ascii(dump + (i * 16) , 16) );
|
PrintAndLogEx(INFO, "%03d | %s ", i, sprint_hex_ascii(dump + (i * 16), 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||||
|
@ -4462,11 +4462,11 @@ static int CmdHF14AMfCView(const char *Cmd) {
|
||||||
|
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
int flags;
|
int flags;
|
||||||
char ctmp = '1';
|
char ctmp = '1';
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
uint8_t numblocks = NumOfBlocks(ctmp);
|
uint8_t numblocks = NumOfBlocks(ctmp);
|
||||||
uint16_t bytes = numblocks * MFBLOCK_SIZE;
|
uint16_t bytes = numblocks * MFBLOCK_SIZE;
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
ctmp = tolower(param_getchar(Cmd, cmdp));
|
ctmp = tolower(param_getchar(Cmd, cmdp));
|
||||||
switch (ctmp) {
|
switch (ctmp) {
|
||||||
|
@ -4486,7 +4486,7 @@ static int CmdHF14AMfCView(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors) return usage_hf14_cview();
|
if (errors) return usage_hf14_cview();
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "View magic MIFARE " _GREEN_("%cK"), ctmp);
|
PrintAndLogEx(SUCCESS, "View magic MIFARE " _GREEN_("%cK"), ctmp);
|
||||||
|
@ -4540,14 +4540,14 @@ static int CmdHF14AMfCView(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||||
PrintAndLogEx(INFO, "blk | data | ascii");
|
PrintAndLogEx(INFO, "blk | data | ascii");
|
||||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||||
for (uint16_t i = 0; i < numblocks; i++){
|
for (uint16_t i = 0; i < numblocks; i++) {
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
PrintAndLogEx(INFO, "%03d | " _RED_("%s"), i, sprint_hex_ascii(dump + (i * 16) , 16) );
|
PrintAndLogEx(INFO, "%03d | " _RED_("%s"), i, sprint_hex_ascii(dump + (i * 16), 16));
|
||||||
} else if (mfIsSectorTrailer(i)) {
|
} else if (mfIsSectorTrailer(i)) {
|
||||||
PrintAndLogEx(INFO, "%03d | " _YELLOW_("%s"), i, sprint_hex_ascii(dump + (i * 16) , 16) );
|
PrintAndLogEx(INFO, "%03d | " _YELLOW_("%s"), i, sprint_hex_ascii(dump + (i * 16), 16));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "%03d | %s ", i, sprint_hex_ascii(dump + (i * 16) , 16) );
|
PrintAndLogEx(INFO, "%03d | %s ", i, sprint_hex_ascii(dump + (i * 16), 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||||
|
@ -5250,7 +5250,7 @@ static command_t CommandTable[] = {
|
||||||
{"gen3uid", CmdHf14AGen3UID, IfPm3Iso14443a, "Set UID without manufacturer block (magic gen3 card)"},
|
{"gen3uid", CmdHf14AGen3UID, IfPm3Iso14443a, "Set UID without manufacturer block (magic gen3 card)"},
|
||||||
{"gen3blk", CmdHf14AGen3Blk, IfPm3Iso14443a, "Overwrite full manufacturer block (magic gen 3 card)"},
|
{"gen3blk", CmdHf14AGen3Blk, IfPm3Iso14443a, "Overwrite full manufacturer block (magic gen 3 card)"},
|
||||||
{"gen3freez", CmdHf14AGen3Freez, IfPm3Iso14443a, "Lock further UID changes (magic gen 3 card)"},
|
{"gen3freez", CmdHf14AGen3Freez, IfPm3Iso14443a, "Lock further UID changes (magic gen 3 card)"},
|
||||||
|
|
||||||
{"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("i") " -----------------------"},
|
{"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("i") " -----------------------"},
|
||||||
{"ice", CmdHF14AMfice, IfPm3Iso14443a, "collect MIFARE Classic nonces to file"},
|
{"ice", CmdHF14AMfice, IfPm3Iso14443a, "collect MIFARE Classic nonces to file"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
|
|
|
@ -144,7 +144,7 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
||||||
return DESFIRE_EV2;
|
return DESFIRE_EV2;
|
||||||
|
|
||||||
// DESFire EV3
|
// DESFire EV3
|
||||||
if (major == 0x33 && minor == 0x00 )
|
if (major == 0x33 && minor == 0x00)
|
||||||
return DESFIRE_EV3;
|
return DESFIRE_EV3;
|
||||||
|
|
||||||
// DESFire Light
|
// DESFire Light
|
||||||
|
@ -1023,7 +1023,7 @@ static int MFPKeyCheck(uint8_t startSector, uint8_t endSector, uint8_t startKeyA
|
||||||
PrintAndLogEx(ERR, "\nExchange error. Aborted.");
|
PrintAndLogEx(ERR, "\nExchange error. Aborted.");
|
||||||
else
|
else
|
||||||
PrintAndLogEx(NORMAL, "E" NOLF);
|
PrintAndLogEx(NORMAL, "E" NOLF);
|
||||||
|
|
||||||
DropField();
|
DropField();
|
||||||
return PM3_ECARDEXCHANGE;
|
return PM3_ECARDEXCHANGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1096,7 +1096,7 @@ uint32_t GetHF14AMfU_Type(void) {
|
||||||
else if (memcmp(version, "\x00\x04\x03\x02\x01\x00\x0B", 7) == 0) { tagtype = UL_EV1_48; break; }
|
else if (memcmp(version, "\x00\x04\x03\x02\x01\x00\x0B", 7) == 0) { tagtype = UL_EV1_48; break; }
|
||||||
else if (memcmp(version, "\x00\x04\x03\x01\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; }
|
else if (memcmp(version, "\x00\x04\x03\x01\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; }
|
||||||
else if (memcmp(version, "\x00\x04\x03\x02\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; }
|
else if (memcmp(version, "\x00\x04\x03\x02\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; }
|
||||||
else if (memcmp(version, "\x00\x34\x21\x01\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; } // Mikron JSC Russia EV1 41 pages tag
|
else if (memcmp(version, "\x00\x34\x21\x01\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; } // Mikron JSC Russia EV1 41 pages tag
|
||||||
else if (memcmp(version, "\x00\x04\x04\x01\x01\x00\x0B", 7) == 0) { tagtype = NTAG_210; break; }
|
else if (memcmp(version, "\x00\x04\x04\x01\x01\x00\x0B", 7) == 0) { tagtype = NTAG_210; break; }
|
||||||
else if (memcmp(version, "\x00\x04\x04\x01\x01\x00\x0E", 7) == 0) { tagtype = NTAG_212; break; }
|
else if (memcmp(version, "\x00\x04\x04\x01\x01\x00\x0E", 7) == 0) { tagtype = NTAG_212; break; }
|
||||||
else if (memcmp(version, "\x00\x04\x04\x02\x01\x00\x0F", 7) == 0) { tagtype = NTAG_213; break; }
|
else if (memcmp(version, "\x00\x04\x04\x02\x01\x00\x0F", 7) == 0) { tagtype = NTAG_213; break; }
|
||||||
|
|
|
@ -92,7 +92,7 @@ static int CmdCOTAGRead(const char *Cmd) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_LF_COTAG_READ, (uint8_t*)&payload, sizeof(payload));
|
SendCommandNG(CMD_LF_COTAG_READ, (uint8_t *)&payload, sizeof(payload));
|
||||||
|
|
||||||
uint8_t timeout = 3;
|
uint8_t timeout = 3;
|
||||||
while (!WaitForResponseTimeout(CMD_LF_COTAG_READ, &resp, 2000)) {
|
while (!WaitForResponseTimeout(CMD_LF_COTAG_READ, &resp, 2000)) {
|
||||||
|
|
|
@ -630,7 +630,7 @@ static int CmdEM410xWrite(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Writing " _YELLOW_("%s") " tag with UID 0x%010" PRIx64 " (clock rate: %d)", (card==1) ? "T55x7" : "Q5/T5555", id, clock1);
|
PrintAndLogEx(SUCCESS, "Writing " _YELLOW_("%s") " tag with UID 0x%010" PRIx64 " (clock rate: %d)", (card == 1) ? "T55x7" : "Q5/T5555", id, clock1);
|
||||||
// NOTE: We really should pass the clock in as a separate argument, but to
|
// NOTE: We really should pass the clock in as a separate argument, but to
|
||||||
// provide for backwards-compatibility for older firmware, and to avoid
|
// provide for backwards-compatibility for older firmware, and to avoid
|
||||||
// having to add another argument to CMD_LF_EM410X_WRITE, we just store
|
// having to add another argument to CMD_LF_EM410X_WRITE, we just store
|
||||||
|
@ -875,7 +875,7 @@ static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t
|
||||||
PrintAndLogEx(WARNING, "(EM4x05ReadWord_ext) timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "(EM4x05ReadWord_ext) timeout while waiting for reply.");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downloadSamplesEM() == false) {
|
if (downloadSamplesEM() == false) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ static int CmdKeriClone(const char *Cmd) {
|
||||||
// Prepare and write to card
|
// Prepare and write to card
|
||||||
// 3 LSB is ONE
|
// 3 LSB is ONE
|
||||||
uint64_t data = ((uint64_t)internalid << 3) + 7;
|
uint64_t data = ((uint64_t)internalid << 3) + 7;
|
||||||
PrintAndLogEx(INFO, "Preparing to clone KERI to " _YELLOW_("%s") " with Internal Id " _YELLOW_("%" PRIx32), (q5) ? "Q5/T5555" : "T55x7",internalid);
|
PrintAndLogEx(INFO, "Preparing to clone KERI to " _YELLOW_("%s") " with Internal Id " _YELLOW_("%" PRIx32), (q5) ? "Q5/T5555" : "T55x7", internalid);
|
||||||
|
|
||||||
blocks[1] = data >> 32;
|
blocks[1] = data >> 32;
|
||||||
blocks[2] = data & 0xFFFFFFFF;
|
blocks[2] = data & 0xFFFFFFFF;
|
||||||
|
@ -366,7 +366,7 @@ int detectKeri(uint8_t *dest, size_t *size, bool *invert) {
|
||||||
uint8_t preamble[] = {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
|
uint8_t preamble[] = {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
|
||||||
|
|
||||||
// sanity check.
|
// sanity check.
|
||||||
if (*size < sizeof(preamble) ) return -1;
|
if (*size < sizeof(preamble)) return -1;
|
||||||
|
|
||||||
size_t startIdx = 0;
|
size_t startIdx = 0;
|
||||||
size_t found_size = *size;
|
size_t found_size = *size;
|
||||||
|
|
|
@ -404,7 +404,7 @@ static int CmdLfNedapGen(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||||
errors = true;
|
errors = true;
|
||||||
|
@ -467,13 +467,13 @@ static int CmdLFNedapClone(const char *Cmd) {
|
||||||
}
|
}
|
||||||
bool q5 = (strstr(Cmd, "q") != NULL);
|
bool q5 = (strstr(Cmd, "q") != NULL);
|
||||||
if (q5) {
|
if (q5) {
|
||||||
if (DemodBufferLen == 64) {
|
if (DemodBufferLen == 64) {
|
||||||
blocks[0] = T5555_FIXED | T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | T5555_SET_BITRATE(64) | 2 << T5555_MAXBLOCK_SHIFT;
|
blocks[0] = T5555_FIXED | T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | T5555_SET_BITRATE(64) | 2 << T5555_MAXBLOCK_SHIFT;
|
||||||
} else {
|
} else {
|
||||||
blocks[0] = T5555_FIXED | T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | T5555_SET_BITRATE(64) | 4 << T5555_MAXBLOCK_SHIFT;
|
blocks[0] = T5555_FIXED | T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | T5555_SET_BITRATE(64) | 4 << T5555_MAXBLOCK_SHIFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 1; i < max ; i++) {
|
for (uint8_t i = 1; i < max ; i++) {
|
||||||
blocks[i] = bytebits_to_byte(DemodBuffer + ((i - 1) * 32), 32);
|
blocks[i] = bytebits_to_byte(DemodBuffer + ((i - 1) * 32), 32);
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ static int CmdPyramidClone(const char *Cmd) {
|
||||||
|
|
||||||
free(bs);
|
free(bs);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Preparing to clone Farpointe/Pyramid to " _YELLOW_("%s") " with Facility Code: %u, Card Number: %u", (q5) ? "Q5/T5555" : "T55x7" , facilitycode, cardnumber);
|
PrintAndLogEx(INFO, "Preparing to clone Farpointe/Pyramid to " _YELLOW_("%s") " with Facility Code: %u, Card Number: %u", (q5) ? "Q5/T5555" : "T55x7", facilitycode, cardnumber);
|
||||||
print_blocks(blocks, ARRAYLEN(blocks));
|
print_blocks(blocks, ARRAYLEN(blocks));
|
||||||
|
|
||||||
int res = clone_t55xx_tag(blocks, ARRAYLEN(blocks));
|
int res = clone_t55xx_tag(blocks, ARRAYLEN(blocks));
|
||||||
|
|
|
@ -994,7 +994,7 @@ static int SanityOfflineCheck(bool useGraphBuffer) {
|
||||||
|
|
||||||
static void T55xx_Print_DownlinkMode(uint8_t downlink_mode) {
|
static void T55xx_Print_DownlinkMode(uint8_t downlink_mode) {
|
||||||
char msg[80];
|
char msg[80];
|
||||||
snprintf(msg, sizeof(msg) ,"Downlink Mode used : ");
|
snprintf(msg, sizeof(msg), "Downlink Mode used : ");
|
||||||
|
|
||||||
switch (downlink_mode) {
|
switch (downlink_mode) {
|
||||||
case 1 :
|
case 1 :
|
||||||
|
@ -1075,7 +1075,7 @@ static int CmdT55xxDetect(const char *Cmd) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2327,7 +2327,7 @@ static int CmdT55xxDump(const char *Cmd) {
|
||||||
strcpy(preferredName, "lf-t55xx");
|
strcpy(preferredName, "lf-t55xx");
|
||||||
for (uint8_t i = 1; i <= 7; i++) {
|
for (uint8_t i = 1; i <= 7; i++) {
|
||||||
if ((cardmem[i].blockdata != 0x00) && (cardmem[i].blockdata != 0xFFFFFFFF))
|
if ((cardmem[i].blockdata != 0x00) && (cardmem[i].blockdata != 0xFFFFFFFF))
|
||||||
snprintf(preferredName + strlen(preferredName), sizeof(preferredName) - strlen(preferredName) , "-%08X", cardmem[i].blockdata);
|
snprintf(preferredName + strlen(preferredName), sizeof(preferredName) - strlen(preferredName), "-%08X", cardmem[i].blockdata);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3052,7 +3052,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
||||||
bool found;
|
bool found;
|
||||||
uint32_t candidate;
|
uint32_t candidate;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct p* packet = (struct p*)resp.data.asBytes;
|
struct p *packet = (struct p *)resp.data.asBytes;
|
||||||
|
|
||||||
if (packet->found) {
|
if (packet->found) {
|
||||||
PrintAndLogEx(SUCCESS, "\nFound a candidate [ " _YELLOW_("%08"PRIX32) " ]", packet->candidate);
|
PrintAndLogEx(SUCCESS, "\nFound a candidate [ " _YELLOW_("%08"PRIX32) " ]", packet->candidate);
|
||||||
|
@ -3224,7 +3224,7 @@ uint8_t tryOnePassword(uint32_t password, uint8_t downlink_mode) {
|
||||||
if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, password, dl_mode)) {
|
if (AcquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, password, dl_mode)) {
|
||||||
// if (getSignalProperties()->isnoise == false) {
|
// if (getSignalProperties()->isnoise == false) {
|
||||||
// } else {
|
// } else {
|
||||||
if (tryDetectModulationEx(dl_mode, T55XX_PrintConfig, 0 ,password)) {
|
if (tryDetectModulationEx(dl_mode, T55XX_PrintConfig, 0, password)) {
|
||||||
return 1 + (dl_mode << 1);
|
return 1 + (dl_mode << 1);
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -115,10 +115,10 @@ static int CmdVikingClone(const char *Cmd) {
|
||||||
num_to_bytes(rawID, 8, &payload.blocks[0]);
|
num_to_bytes(rawID, 8, &payload.blocks[0]);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Preparing to clone Viking tag on " _YELLOW_("%s") " - ID " _YELLOW_("%08X")" raw " _YELLOW_("%s")
|
PrintAndLogEx(INFO, "Preparing to clone Viking tag on " _YELLOW_("%s") " - ID " _YELLOW_("%08X")" raw " _YELLOW_("%s")
|
||||||
, (Q5) ? "Q5/T5555" : "T55x7"
|
, (Q5) ? "Q5/T5555" : "T55x7"
|
||||||
, id
|
, id
|
||||||
, sprint_hex(payload.blocks, sizeof(payload.blocks))
|
, sprint_hex(payload.blocks, sizeof(payload.blocks))
|
||||||
);
|
);
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
||||||
|
|
|
@ -334,10 +334,10 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
// Draw the CRC column
|
// Draw the CRC column
|
||||||
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
|
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
|
||||||
|
|
||||||
// mark short bytes (less than 8 Bit + Parity)
|
// mark short bytes (less than 8 Bit + Parity)
|
||||||
if (protocol == ISO_14443A ||
|
if (protocol == ISO_14443A ||
|
||||||
protocol == PROTO_MIFARE ||
|
protocol == PROTO_MIFARE ||
|
||||||
protocol == THINFILM) {
|
protocol == THINFILM) {
|
||||||
|
|
||||||
// approximated with 128 * (9 * data_len);
|
// approximated with 128 * (9 * data_len);
|
||||||
uint16_t bitime = 1056 + 32;
|
uint16_t bitime = 1056 + 32;
|
||||||
|
@ -346,17 +346,17 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
|
|
||||||
uint8_t m = 7;
|
uint8_t m = 7;
|
||||||
while (m > 0) {
|
while (m > 0) {
|
||||||
bitime -= 128;
|
bitime -= 128;
|
||||||
if ( duration > bitime) {
|
if (duration > bitime) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m--;
|
m--;
|
||||||
}
|
}
|
||||||
line[(data_len-1)/16][((data_len-1)%16) * 4 + 2] = '(';
|
line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 2] = '(';
|
||||||
line[(data_len-1)/16][((data_len-1)%16) * 4 + 3] = m + 0x30;
|
line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 3] = m + 0x30;
|
||||||
line[(data_len-1)/16][((data_len-1)%16) * 4 + 4] = ')';
|
line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 4] = ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t previous_end_of_transmission_timestamp = 0;
|
uint32_t previous_end_of_transmission_timestamp = 0;
|
||||||
|
@ -388,8 +388,8 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
annotateHitagS(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
annotateHitagS(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||||
break;
|
break;
|
||||||
case ICLASS:
|
case ICLASS:
|
||||||
annotateIclass(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
annotateIclass(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,18 +429,18 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
|
||||||
}
|
}
|
||||||
case jsfIclass: {
|
case jsfIclass: {
|
||||||
JsonSaveStr(root, "FileType", "iclass");
|
JsonSaveStr(root, "FileType", "iclass");
|
||||||
|
|
||||||
picopass_hdr *hdr = (picopass_hdr *)data;
|
picopass_hdr *hdr = (picopass_hdr *)data;
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.CSN", hdr->csn, sizeof(hdr->csn));
|
JsonSaveBufAsHexCompact(root, "$.Card.CSN", hdr->csn, sizeof(hdr->csn));
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.Configuration",(uint8_t *)&hdr->conf, sizeof(hdr->conf));
|
JsonSaveBufAsHexCompact(root, "$.Card.Configuration", (uint8_t *)&hdr->conf, sizeof(hdr->conf));
|
||||||
|
|
||||||
uint8_t pagemap = get_pagemap(hdr);
|
uint8_t pagemap = get_pagemap(hdr);
|
||||||
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
|
||||||
picopass_ns_hdr *ns_hdr = (picopass_ns_hdr *)data;
|
picopass_ns_hdr *ns_hdr = (picopass_ns_hdr *)data;
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.AIA", ns_hdr->app_issuer_area, sizeof(ns_hdr->app_issuer_area));
|
JsonSaveBufAsHexCompact(root, "$.Card.AIA", ns_hdr->app_issuer_area, sizeof(ns_hdr->app_issuer_area));
|
||||||
} else {
|
} else {
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.Epurse", hdr->epurse, sizeof(hdr->epurse));
|
JsonSaveBufAsHexCompact(root, "$.Card.Epurse", hdr->epurse, sizeof(hdr->epurse));
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.Kd",hdr->key_d, sizeof(hdr->key_d));
|
JsonSaveBufAsHexCompact(root, "$.Card.Kd", hdr->key_d, sizeof(hdr->key_d));
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.Kc", hdr->key_c, sizeof(hdr->key_c));
|
JsonSaveBufAsHexCompact(root, "$.Card.Kc", hdr->key_c, sizeof(hdr->key_c));
|
||||||
JsonSaveBufAsHexCompact(root, "$.Card.AIA", hdr->app_issuer_area, sizeof(hdr->app_issuer_area));
|
JsonSaveBufAsHexCompact(root, "$.Card.AIA", hdr->app_issuer_area, sizeof(hdr->app_issuer_area));
|
||||||
}
|
}
|
||||||
|
@ -1483,9 +1483,9 @@ static int filelist(const char *path, const char *ext, uint8_t last, bool tentat
|
||||||
char tmp_fullpath[1024] = {0};
|
char tmp_fullpath[1024] = {0};
|
||||||
strncat(tmp_fullpath, path, sizeof(tmp_fullpath) - 1);
|
strncat(tmp_fullpath, path, sizeof(tmp_fullpath) - 1);
|
||||||
strncat(tmp_fullpath, namelist[i]->d_name, strlen(tmp_fullpath) - 1);
|
strncat(tmp_fullpath, namelist[i]->d_name, strlen(tmp_fullpath) - 1);
|
||||||
|
|
||||||
if (is_directory(tmp_fullpath)) {
|
if (is_directory(tmp_fullpath)) {
|
||||||
|
|
||||||
char newpath[1024];
|
char newpath[1024];
|
||||||
if (strcmp(namelist[i]->d_name, ".") == 0 || strcmp(namelist[i]->d_name, "..") == 0)
|
if (strcmp(namelist[i]->d_name, ".") == 0 || strcmp(namelist[i]->d_name, "..") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1496,9 +1496,9 @@ static int filelist(const char *path, const char *ext, uint8_t last, bool tentat
|
||||||
|
|
||||||
filelist(newpath, ext, last + ((i == n - 1) << (indent + 1)), tentative, indent + 1, strlen(path));
|
filelist(newpath, ext, last + ((i == n - 1) << (indent + 1)), tentative, indent + 1, strlen(path));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ((ext == NULL) || (ext && (str_endswith(namelist[i]->d_name, ext)))) {
|
if ((ext == NULL) || (ext && (str_endswith(namelist[i]->d_name, ext)))) {
|
||||||
|
|
||||||
for (uint8_t j = 0; j < indent + 1; j++) {
|
for (uint8_t j = 0; j < indent + 1; j++) {
|
||||||
PrintAndLogEx(NORMAL, "%s " NOLF, ((last >> j) & 1) ? " " : "│");
|
PrintAndLogEx(NORMAL, "%s " NOLF, ((last >> j) & 1) ? " " : "│");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,9 @@ static void calc_score(uint8_t *csn, uint8_t *k) {
|
||||||
|
|
||||||
if (score >= 2 && badscore < 2) {
|
if (score >= 2 && badscore < 2) {
|
||||||
PrintAndLogEx(NORMAL, "CSN\t%02x%02x%02x%02x%02x%02x%02x%02x\t%02x %02x %02x %02x %02x %02x %02x %02x\t" NOLF
|
PrintAndLogEx(NORMAL, "CSN\t%02x%02x%02x%02x%02x%02x%02x%02x\t%02x %02x %02x %02x %02x %02x %02x %02x\t" NOLF
|
||||||
, csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]
|
, csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]
|
||||||
, k[0], k[1], k[2], k[3], k[4], k[5], k[6], k[7]
|
, k[0], k[1], k[2], k[3], k[4], k[5], k[6], k[7]
|
||||||
);
|
);
|
||||||
|
|
||||||
for (i = 0 ; i < score; i++) {
|
for (i = 0 ; i < score; i++) {
|
||||||
PrintAndLogEx(NORMAL, "%d," NOLF, uniq_vals[i]);
|
PrintAndLogEx(NORMAL, "%d," NOLF, uniq_vals[i]);
|
||||||
|
|
|
@ -1199,11 +1199,11 @@ static int l_cwd(lua_State *L) {
|
||||||
|
|
||||||
// ref: https://github.com/RfidResearchGroup/proxmark3/issues/891
|
// ref: https://github.com/RfidResearchGroup/proxmark3/issues/891
|
||||||
// redirect LUA's print to Proxmark3 PrintAndLogEx
|
// redirect LUA's print to Proxmark3 PrintAndLogEx
|
||||||
static int l_printandlogex(lua_State* L) {
|
static int l_printandlogex(lua_State *L) {
|
||||||
|
|
||||||
int n = lua_gettop(L);
|
int n = lua_gettop(L);
|
||||||
for (int i = 1; i <= n; i++) {
|
for (int i = 1; i <= n; i++) {
|
||||||
if (lua_isstring(L, i)) {
|
if (lua_isstring(L, i)) {
|
||||||
PrintAndLogEx(NORMAL, "%s", lua_tostring(L, i));
|
PrintAndLogEx(NORMAL, "%s", lua_tostring(L, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1293,7 @@ int set_pm3_libraries(lua_State *L) {
|
||||||
|
|
||||||
// remove the global environment table from the stack
|
// remove the global environment table from the stack
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
// print redirect here
|
// print redirect here
|
||||||
lua_register(L, "print", l_printandlogex);
|
lua_register(L, "print", l_printandlogex);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue