minor corrections..

This commit is contained in:
iceman1001 2017-08-29 15:47:26 +02:00
commit c5616dfe76
9 changed files with 124 additions and 119 deletions

View file

@ -167,13 +167,14 @@ int CmdHF14AList(const char *Cmd) {
} }
int CmdHF14AReader(const char *Cmd) { int CmdHF14AReader(const char *Cmd) {
bool silent = (Cmd[0] == 's' || Cmd[0] == 'S');
UsbCommand cDisconnect = {CMD_READER_ISO_14443a, {0,0,0}}; UsbCommand cDisconnect = {CMD_READER_ISO_14443a, {0,0,0}};
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}}; UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
if (Cmd[0] != 's') PrintAndLog("iso14443a card select failed"); if (!silent) PrintAndLog("iso14443a card select failed");
SendCommand(&cDisconnect); SendCommand(&cDisconnect);
return 0; return 0;
} }
@ -181,15 +182,21 @@ int CmdHF14AReader(const char *Cmd) {
iso14a_card_select_t card; iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t)); memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
uint64_t select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision /*
0: couldn't read
1: OK, with ATS
2: OK, no ATS
3: proprietary Anticollision
*/
uint64_t select_status = resp.arg[0];
if(select_status == 0) { if (select_status == 0) {
if (Cmd[0] != 's') PrintAndLog("iso14443a card select failed"); if (!silent) PrintAndLog("iso14443a card select failed");
SendCommand(&cDisconnect); SendCommand(&cDisconnect);
return 0; return 0;
} }
if(select_status == 3) { if (select_status == 3) {
PrintAndLog("Card doesn't support standard iso14443-3 anticollision"); PrintAndLog("Card doesn't support standard iso14443-3 anticollision");
PrintAndLog("ATQA : %02x %02x", card.atqa[1], card.atqa[0]); PrintAndLog("ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
SendCommand(&cDisconnect); SendCommand(&cDisconnect);

View file

@ -462,7 +462,7 @@ int CmdHF15DumpMem(const char*Cmd) {
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
recv = resp.d.asBytes; recv = resp.d.asBytes;
if (ISO15_CRC_CHECK==Crc(recv,resp.arg[0])) { if (ISO15_CRC_CHECK==Crc(recv,resp.arg[0])) {
if (!(recv[0] & ISO15_RES_ERROR)) { if (!(recv[0] & ISO15_RES_ERROR)) {
@ -484,7 +484,8 @@ int CmdHF15DumpMem(const char*Cmd) {
return 1; return 1;
} }
} // else PrintAndLog("crc"); } // else PrintAndLog("crc");
} // else PrintAndLog("r null"); }
// else PrintAndLog("r null");
} // retry } // retry
// TODO: need fix // TODO: need fix
// if (resp.arg[0]<3) // if (resp.arg[0]<3)
@ -547,7 +548,7 @@ int CmdHF15CmdInquiry(const char *Cmd)
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) { if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
if (resp.arg[0]>=12) { if (resp.arg[0] >= 12) {
recv = resp.d.asBytes; recv = resp.d.asBytes;
PrintAndLog("UID=%s", sprintUID(NULL, &recv[2])); PrintAndLog("UID=%s", sprintUID(NULL, &recv[2]));
PrintAndLog("Tag Info: %s", getTagInfo_15(&recv[2])); PrintAndLog("Tag Info: %s", getTagInfo_15(&recv[2]));
@ -555,7 +556,7 @@ int CmdHF15CmdInquiry(const char *Cmd)
PrintAndLog("Response to short, just %i bytes. No tag?\n", resp.arg[0]); PrintAndLog("Response to short, just %i bytes. No tag?\n", resp.arg[0]);
} }
} else { } else {
PrintAndLog("timeout."); PrintAndLog("timeout while waiting for reply.");
} }
return 0; return 0;
} }
@ -849,7 +850,7 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
PrintAndLog("CRC failed"); PrintAndLog("CRC failed");
} }
} else { } else {
PrintAndLog("timeout: no answer"); PrintAndLog("timeout while waiting for reply.");
} }
return 0; return 0;
@ -928,7 +929,7 @@ int CmdHF15CmdReadmulti(const char *Cmd) {
PrintAndLog("CRC failed"); PrintAndLog("CRC failed");
} }
} else { } else {
PrintAndLog("no answer"); PrintAndLog("timeout while waiting for reply.");
} }
return 0; return 0;
@ -1002,7 +1003,7 @@ int CmdHF15CmdRead(const char *Cmd) {
PrintAndLog("CRC failed"); PrintAndLog("CRC failed");
} }
} else { } else {
PrintAndLog("no answer"); PrintAndLog("timeout while waiting for reply.");
} }
return 0; return 0;

View file

@ -173,7 +173,7 @@ int CmdHfEmvTrans(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 5000)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 5000)) {
PrintAndLog("Command execute time-out"); PrintAndLog("Command execute time-out");
return 1; return 1;
} }
@ -312,7 +312,7 @@ int CmdHfEmvSim(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
PrintAndLog("Command execute time-out"); PrintAndLog("Command execute time-out");
return 1; return 1;
} }

View file

@ -318,6 +318,7 @@ int CmdHFiClassSim(const char *Cmd) {
memcpy(c.d.asBytes, csns, 8*NUM_CSNS); memcpy(c.d.asBytes, csns, 8*NUM_CSNS);
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
// -1 make it wait all the time (iceman)
if (!WaitForResponseTimeout(CMD_ACK, &resp, -1)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, -1)) {
PrintAndLog("Command timed out"); PrintAndLog("Command timed out");
return 0; return 0;

View file

@ -356,7 +356,7 @@ int CmdHF14AMfWrBl(const char *Cmd) {
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.arg[0] & 0xff; uint8_t isOK = resp.arg[0] & 0xff;
PrintAndLog("isOk:%02x", isOK); PrintAndLog("isOk:%02x", isOK);
} else { } else {
@ -448,10 +448,10 @@ int CmdHF14AMfRdSc(const char *Cmd) {
memcpy(c.d.asBytes, key, 6); memcpy(c.d.asBytes, key, 6);
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
PrintAndLog(" "); PrintAndLog("");
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
isOK = resp.arg[0] & 0xff; isOK = resp.arg[0] & 0xff;
data = resp.d.asBytes; data = resp.d.asBytes;
@ -1619,7 +1619,8 @@ int CmdHF14AMfSniff(const char *Cmd){
} }
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) { if ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) continue;
res = resp.arg[0] & 0xff; res = resp.arg[0] & 0xff;
traceLen = resp.arg[1]; traceLen = resp.arg[1];
len = resp.arg[2]; len = resp.arg[2];
@ -1709,7 +1710,6 @@ int CmdHF14AMfSniff(const char *Cmd){
} }
pckNum = 0; pckNum = 0;
} }
} // resp not NULL
} // while (true) } // while (true)
free(buf); free(buf);

View file

@ -181,9 +181,8 @@ int CmdHF14ADesInfo(const char *Cmd){
c.arg[1] = 0x01; c.arg[1] = 0x01;
c.d.asBytes[0] = GET_FREE_MEMORY; c.d.asBytes[0] = GET_FREE_MEMORY;
SendCommand(&c); SendCommand(&c);
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500)) { if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500))
return 0; return 0;
}
uint8_t tmp[3]; uint8_t tmp[3];
memcpy(tmp, resp.d.asBytes+3,3); memcpy(tmp, resp.d.asBytes+3,3);
@ -299,9 +298,7 @@ void GetKeySettings( uint8_t *aid){
c.d.asBytes[0] = GET_KEY_VERSION; //0x64 c.d.asBytes[0] = GET_KEY_VERSION; //0x64
c.d.asBytes[1] = 0x00; c.d.asBytes[1] = 0x00;
SendCommand(&c); SendCommand(&c);
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1000) ) { if ( !WaitForResponseTimeout(CMD_ACK,&resp,1000) ) { return; }
return;
}
isOK = resp.arg[0] & 0xff; isOK = resp.arg[0] & 0xff;
if ( !isOK ){ if ( !isOK ){
PrintAndLog(" Can't read key-version"); PrintAndLog(" Can't read key-version");

View file

@ -107,9 +107,8 @@ int CmdHF14AMfDESAuth(const char *Cmd){
uint8_t isOK = respb.arg[0] & 0xff; uint8_t isOK = respb.arg[0] & 0xff;
uint8_t * data2= respb.d.asBytes; uint8_t * data2= respb.d.asBytes;
if (isOK){ if (isOK)
PrintAndLog("b3:%s", sprint_hex(data2+2, 8)); PrintAndLog("b3:%s", sprint_hex(data2+2, 8));
}
} else { } else {
PrintAndLog("Command execute timeout"); PrintAndLog("Command execute timeout");
@ -163,7 +162,7 @@ int CmdHF14AMfAESAuth(const char *Cmd){
UsbCommand c = {CMD_MIFARE_DES_AUTH1, {blockNo}}; UsbCommand c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
SendCommand(&c); SendCommand(&c);
UsbCommand resp; UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.arg[0] & 0xff; uint8_t isOK = resp.arg[0] & 0xff;
cuid = resp.arg[1]; cuid = resp.arg[1];
uint8_t * data= resp.d.asBytes; uint8_t * data= resp.d.asBytes;
@ -210,13 +209,12 @@ int CmdHF14AMfAESAuth(const char *Cmd){
SendCommand(&d); SendCommand(&d);
UsbCommand respb; UsbCommand respb;
if (WaitForResponseTimeout(CMD_ACK,&respb,1500)) { if (WaitForResponseTimeout(CMD_ACK, &respb, 1500)) {
uint8_t isOK = respb.arg[0] & 0xff; uint8_t isOK = respb.arg[0] & 0xff;
uint8_t * data2= respb.d.asBytes; uint8_t * data2= respb.d.asBytes;
if (isOK){ if (isOK)
PrintAndLog("b3:%s", sprint_hex(data2+2, 16)); PrintAndLog("b3:%s", sprint_hex(data2+2, 16));
}
} else { } else {
PrintAndLog("Command execute timeout"); PrintAndLog("Command execute timeout");

View file

@ -1459,6 +1459,7 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
if (initialize) { if (initialize) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) { if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) {
//strange second call (iceman)
UsbCommand c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}}; UsbCommand c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);

View file

@ -1029,7 +1029,7 @@ int CmdT55xxWriteBlock(const char *Cmd) {
} }
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)){ if ( !WaitForResponseTimeout(CMD_ACK, &resp, 1500 )){
PrintAndLog("Error occurred, device did not ACK write operation. (May be due to old firmware)"); PrintAndLog("Error occurred, device did not ACK write operation. (May be due to old firmware)");
return 0; return 0;
} }