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) {
bool silent = (Cmd[0] == 's' || Cmd[0] == 'S');
UsbCommand cDisconnect = {CMD_READER_ISO_14443a, {0,0,0}};
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}};
clearCommandBuffer();
SendCommand(&c);
UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
if (Cmd[0] != 's') PrintAndLog("iso14443a card select failed");
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
if (!silent) PrintAndLog("iso14443a card select failed");
SendCommand(&cDisconnect);
return 0;
}
@ -181,15 +182,21 @@ int CmdHF14AReader(const char *Cmd) {
iso14a_card_select_t card;
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 (Cmd[0] != 's') PrintAndLog("iso14443a card select failed");
if (select_status == 0) {
if (!silent) PrintAndLog("iso14443a card select failed");
SendCommand(&cDisconnect);
return 0;
}
if(select_status == 3) {
if (select_status == 3) {
PrintAndLog("Card doesn't support standard iso14443-3 anticollision");
PrintAndLog("ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
SendCommand(&cDisconnect);

View file

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

View file

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

View file

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

View file

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

View file

@ -181,9 +181,8 @@ int CmdHF14ADesInfo(const char *Cmd){
c.arg[1] = 0x01;
c.d.asBytes[0] = GET_FREE_MEMORY;
SendCommand(&c);
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500))
return 0;
}
uint8_t tmp[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[1] = 0x00;
SendCommand(&c);
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1000) ) {
return;
}
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1000) ) { return; }
isOK = resp.arg[0] & 0xff;
if ( !isOK ){
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 * data2= respb.d.asBytes;
if (isOK){
if (isOK)
PrintAndLog("b3:%s", sprint_hex(data2+2, 8));
}
} else {
PrintAndLog("Command execute timeout");
@ -163,7 +162,7 @@ int CmdHF14AMfAESAuth(const char *Cmd){
UsbCommand c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
SendCommand(&c);
UsbCommand resp;
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.arg[0] & 0xff;
cuid = resp.arg[1];
uint8_t * data= resp.d.asBytes;
@ -210,13 +209,12 @@ int CmdHF14AMfAESAuth(const char *Cmd){
SendCommand(&d);
UsbCommand respb;
if (WaitForResponseTimeout(CMD_ACK,&respb,1500)) {
if (WaitForResponseTimeout(CMD_ACK, &respb, 1500)) {
uint8_t isOK = respb.arg[0] & 0xff;
uint8_t * data2= respb.d.asBytes;
if (isOK){
if (isOK)
PrintAndLog("b3:%s", sprint_hex(data2+2, 16));
}
} else {
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 (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) {
//strange second call (iceman)
UsbCommand c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}};
clearCommandBuffer();
SendCommand(&c);

View file

@ -1029,7 +1029,7 @@ int CmdT55xxWriteBlock(const char *Cmd) {
}
clearCommandBuffer();
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)");
return 0;
}