mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
chg: 'hf iclass sim' - sim2, 4 get less default output, set DBG 4 for verbose
This commit is contained in:
parent
3248bb5a56
commit
e0373212a3
3 changed files with 42 additions and 35 deletions
|
@ -1244,7 +1244,6 @@ int doIClassSimulation( int simulationMode, uint8_t *reader_mac_buf) {
|
||||||
uint8_t anticoll_data[10] = { 0 };
|
uint8_t anticoll_data[10] = { 0 };
|
||||||
uint8_t csn_data[10] = { 0 };
|
uint8_t csn_data[10] = { 0 };
|
||||||
memcpy(csn_data, csn, sizeof(csn_data));
|
memcpy(csn_data, csn, sizeof(csn_data));
|
||||||
Dbprintf("[+] Simulating CSN %02x%02x%02x%02x%02x%02x%02x%02x", csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]);
|
|
||||||
|
|
||||||
// Construct anticollision-CSN
|
// Construct anticollision-CSN
|
||||||
rotateCSN(csn_data, anticoll_data);
|
rotateCSN(csn_data, anticoll_data);
|
||||||
|
@ -1321,50 +1320,50 @@ int doIClassSimulation( int simulationMode, uint8_t *reader_mac_buf) {
|
||||||
// First card answer: SOF
|
// First card answer: SOF
|
||||||
CodeIClassTagSOF();
|
CodeIClassTagSOF();
|
||||||
memcpy(resp_sof, ToSend, ToSendMax); resp_sof_Len = ToSendMax;
|
memcpy(resp_sof, ToSend, ToSendMax); resp_sof_Len = ToSendMax;
|
||||||
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
// if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
DbpString("SOF");
|
// DbpString("SOF");
|
||||||
PrintToSendBuffer();
|
// PrintToSendBuffer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Anticollision CSN
|
// Anticollision CSN
|
||||||
CodeIClassTagAnswer(anticoll_data, sizeof(anticoll_data));
|
CodeIClassTagAnswer(anticoll_data, sizeof(anticoll_data));
|
||||||
memcpy(resp_anticoll, ToSend, ToSendMax); resp_anticoll_len = ToSendMax;
|
memcpy(resp_anticoll, ToSend, ToSendMax); resp_anticoll_len = ToSendMax;
|
||||||
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
// if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
DbpString("ANTI COLL CSN");
|
// DbpString("ANTI COLL CSN");
|
||||||
PrintToSendBuffer();
|
// PrintToSendBuffer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// CSN
|
// CSN
|
||||||
CodeIClassTagAnswer(csn_data, sizeof(csn_data));
|
CodeIClassTagAnswer(csn_data, sizeof(csn_data));
|
||||||
memcpy(resp_csn, ToSend, ToSendMax); resp_csn_len = ToSendMax;
|
memcpy(resp_csn, ToSend, ToSendMax); resp_csn_len = ToSendMax;
|
||||||
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
// if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
DbpString("CSN");
|
// DbpString("CSN");
|
||||||
PrintToSendBuffer();
|
// PrintToSendBuffer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
CodeIClassTagAnswer(conf_data, sizeof(conf_data));
|
CodeIClassTagAnswer(conf_data, sizeof(conf_data));
|
||||||
memcpy(resp_conf, ToSend, ToSendMax); resp_conf_len = ToSendMax;
|
memcpy(resp_conf, ToSend, ToSendMax); resp_conf_len = ToSendMax;
|
||||||
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
// if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
DbpString("Configuration");
|
// DbpString("Configuration");
|
||||||
PrintToSendBuffer();
|
// PrintToSendBuffer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// e-Purse
|
// e-Purse
|
||||||
CodeIClassTagAnswer(card_challenge_data, sizeof(card_challenge_data));
|
CodeIClassTagAnswer(card_challenge_data, sizeof(card_challenge_data));
|
||||||
memcpy(resp_cc, ToSend, ToSendMax); resp_cc_len = ToSendMax;
|
memcpy(resp_cc, ToSend, ToSendMax); resp_cc_len = ToSendMax;
|
||||||
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
// if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
DbpString("e-Purse");
|
// DbpString("e-Purse");
|
||||||
PrintToSendBuffer();
|
// PrintToSendBuffer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Application Issuer Area
|
// Application Issuer Area
|
||||||
CodeIClassTagAnswer(aia_data, sizeof(aia_data));
|
CodeIClassTagAnswer(aia_data, sizeof(aia_data));
|
||||||
memcpy(resp_aia, ToSend, ToSendMax); resp_aia_len = ToSendMax;
|
memcpy(resp_aia, ToSend, ToSendMax); resp_aia_len = ToSendMax;
|
||||||
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
// if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
DbpString("Application Issuer Data");
|
// DbpString("Application Issuer Data");
|
||||||
PrintToSendBuffer();
|
// PrintToSendBuffer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
//This is used for responding to READ-block commands or other data which is dynamically generated
|
//This is used for responding to READ-block commands or other data which is dynamically generated
|
||||||
//First the 'trace'-data, not encoded for FPGA
|
//First the 'trace'-data, not encoded for FPGA
|
||||||
|
@ -1488,13 +1487,14 @@ int doIClassSimulation( int simulationMode, uint8_t *reader_mac_buf) {
|
||||||
trace_data_size = 0;
|
trace_data_size = 0;
|
||||||
|
|
||||||
if (simulationMode == MODE_EXIT_AFTER_MAC) {
|
if (simulationMode == MODE_EXIT_AFTER_MAC) {
|
||||||
|
|
||||||
Dbprintf("CSN: %02x %02x %02x %02x %02x %02x %02x %02x", csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]);
|
if ( MF_DBGLEVEL == MF_DBG_EXTENDED) {
|
||||||
Dbprintf("RDR: (len=%02d): %02x %02x %02x %02x %02x %02x %02x %02x %02x", len,
|
Dbprintf("[+] CSN: %02x %02x %02x %02x %02x %02x %02x %02x", csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]);
|
||||||
|
Dbprintf("[+] RDR: (len=%02d): %02x %02x %02x %02x %02x %02x %02x %02x %02x", len,
|
||||||
receivedCmd[0], receivedCmd[1], receivedCmd[2],
|
receivedCmd[0], receivedCmd[1], receivedCmd[2],
|
||||||
receivedCmd[3], receivedCmd[4], receivedCmd[5],
|
receivedCmd[3], receivedCmd[4], receivedCmd[5],
|
||||||
receivedCmd[6], receivedCmd[7], receivedCmd[8]);
|
receivedCmd[6], receivedCmd[7], receivedCmd[8]);
|
||||||
|
}
|
||||||
if (reader_mac_buf != NULL) {
|
if (reader_mac_buf != NULL) {
|
||||||
memcpy(reader_mac_buf, receivedCmd+1, 8);
|
memcpy(reader_mac_buf, receivedCmd+1, 8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,6 +350,8 @@ int CmdHFiClassSim(const char *Cmd) {
|
||||||
* <4 byte NR><4 byte MAC>
|
* <4 byte NR><4 byte MAC>
|
||||||
* CC are all zeroes, CSN is the same as was sent in
|
* CC are all zeroes, CSN is the same as was sent in
|
||||||
**/
|
**/
|
||||||
|
uint8_t tries = 0;
|
||||||
|
|
||||||
switch(simType) {
|
switch(simType) {
|
||||||
|
|
||||||
case 2: {
|
case 2: {
|
||||||
|
@ -361,14 +363,17 @@ int CmdHFiClassSim(const char *Cmd) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
||||||
while (true) {
|
while ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) {
|
||||||
|
tries++;
|
||||||
|
printf(".");
|
||||||
|
fflush(stdout);
|
||||||
if (ukbhit()) {
|
if (ukbhit()) {
|
||||||
int gc = getchar(); (void)gc;
|
int gc = getchar(); (void)gc;
|
||||||
PrintAndLog("[!] aborted via keyboard.");
|
PrintAndLog("[!] aborted via keyboard.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
if ( tries > 20) {
|
||||||
PrintAndLog("[!] timeout while waiting for reply.");
|
PrintAndLog("[!] timeout while waiting for reply.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -406,7 +411,7 @@ int CmdHFiClassSim(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
PrintAndLog("[+] Starting the sim 4 keyroll attack");
|
PrintAndLog("[+] Starting the sim 4 key roll attack");
|
||||||
PrintAndLog("[+] press keyboard to cancel");
|
PrintAndLog("[+] press keyboard to cancel");
|
||||||
UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}};
|
UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}};
|
||||||
UsbCommand resp = {0};
|
UsbCommand resp = {0};
|
||||||
|
@ -414,14 +419,17 @@ int CmdHFiClassSim(const char *Cmd) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
||||||
while (true) {
|
while ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) {
|
||||||
|
tries++;
|
||||||
|
printf(".");
|
||||||
|
fflush(stdout);
|
||||||
if (ukbhit()) {
|
if (ukbhit()) {
|
||||||
int gc = getchar(); (void)gc;
|
int gc = getchar(); (void)gc;
|
||||||
PrintAndLog("[!] aborted via keyboard.");
|
PrintAndLog("[!] aborted via keyboard.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
if ( tries > 20) {
|
||||||
PrintAndLog("[!] timeout while waiting for reply.");
|
PrintAndLog("[!] timeout while waiting for reply.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
||||||
if (ukbhit()) {
|
if (ukbhit()) {
|
||||||
int gc = getchar(); (void)gc;
|
int gc = getchar(); (void)gc;
|
||||||
return -5;
|
return -5;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue