mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
minor corrections..
This commit is contained in:
parent
9f54a5e4b9
commit
c5616dfe76
9 changed files with 124 additions and 119 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
176
client/cmdhfmf.c
176
client/cmdhfmf.c
|
@ -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,97 +1619,97 @@ int CmdHF14AMfSniff(const char *Cmd){
|
|||
}
|
||||
|
||||
UsbCommand resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
res = resp.arg[0] & 0xff;
|
||||
traceLen = resp.arg[1];
|
||||
len = resp.arg[2];
|
||||
if ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) continue;
|
||||
|
||||
res = resp.arg[0] & 0xff;
|
||||
traceLen = resp.arg[1];
|
||||
len = resp.arg[2];
|
||||
|
||||
// we are done?
|
||||
if (res == 0) {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
// we are done?
|
||||
if (res == 0) {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (res == 1) { // there is (more) data to be transferred
|
||||
if (pckNum == 0) { // first packet, (re)allocate necessary buffer
|
||||
if (traceLen > bufsize || buf == NULL) {
|
||||
uint8_t *p;
|
||||
if (buf == NULL) // not yet allocated
|
||||
p = malloc(traceLen);
|
||||
else // need more memory
|
||||
p = realloc(buf, traceLen);
|
||||
|
||||
if (p == NULL) {
|
||||
PrintAndLog("Cannot allocate memory for trace");
|
||||
free(buf);
|
||||
return 2;
|
||||
}
|
||||
buf = p;
|
||||
if (res == 1) { // there is (more) data to be transferred
|
||||
if (pckNum == 0) { // first packet, (re)allocate necessary buffer
|
||||
if (traceLen > bufsize || buf == NULL) {
|
||||
uint8_t *p;
|
||||
if (buf == NULL) // not yet allocated
|
||||
p = malloc(traceLen);
|
||||
else // need more memory
|
||||
p = realloc(buf, traceLen);
|
||||
|
||||
if (p == NULL) {
|
||||
PrintAndLog("Cannot allocate memory for trace");
|
||||
free(buf);
|
||||
return 2;
|
||||
}
|
||||
bufPtr = buf;
|
||||
bufsize = traceLen;
|
||||
memset(buf, 0x00, traceLen);
|
||||
buf = p;
|
||||
}
|
||||
if (bufPtr == NULL) {
|
||||
PrintAndLog("Cannot allocate memory for trace");
|
||||
free(buf);
|
||||
return 2;
|
||||
}
|
||||
// what happens if LEN is bigger then TRACELEN --iceman
|
||||
memcpy(bufPtr, resp.d.asBytes, len);
|
||||
bufPtr += len;
|
||||
pckNum++;
|
||||
}
|
||||
|
||||
if (res == 2) { // received all data, start displaying
|
||||
blockLen = bufPtr - buf;
|
||||
bufPtr = buf;
|
||||
printf(">\n");
|
||||
PrintAndLog("received trace len: %d packages: %d", blockLen, pckNum);
|
||||
while (bufPtr - buf < blockLen) {
|
||||
bufPtr += 6; // skip (void) timing information
|
||||
len = *((uint16_t *)bufPtr);
|
||||
if(len & 0x8000) {
|
||||
isTag = true;
|
||||
len &= 0x7fff;
|
||||
} else {
|
||||
isTag = false;
|
||||
}
|
||||
bufPtr += 2;
|
||||
if ((len == 17) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff) && (bufPtr[15] == 0xff) && (bufPtr[16] == 0xff)) {
|
||||
memcpy(uid, bufPtr + 2, 10);
|
||||
memcpy(atqa, bufPtr + 2 + 10, 2);
|
||||
switch (atqa[0] & 0xC0) {
|
||||
case 0x80: uid_len = 10; break;
|
||||
case 0x40: uid_len = 7; break;
|
||||
default: uid_len = 4; break;
|
||||
}
|
||||
sak = bufPtr[14];
|
||||
PrintAndLog("tag select uid| %s atqa:0x%02x%02x sak:0x%02x",
|
||||
sprint_hex(uid, uid_len),
|
||||
atqa[1],
|
||||
atqa[0],
|
||||
sak);
|
||||
if (wantLogToFile || wantDecrypt) {
|
||||
FillFileNameByUID(logHexFileName, uid, ".log", uid_len);
|
||||
AddLogCurrentDT(logHexFileName);
|
||||
}
|
||||
if (wantDecrypt)
|
||||
mfTraceInit(uid, uid_len, atqa, sak, wantSaveToEmlFile);
|
||||
} else {
|
||||
PrintAndLog("%03d| %s |%s", num, isTag ? "TAG" : "RDR", sprint_hex(bufPtr, len));
|
||||
if (wantLogToFile)
|
||||
AddLogHex(logHexFileName, isTag ? "TAG| ":"RDR| ", bufPtr, len);
|
||||
if (wantDecrypt)
|
||||
mfTraceDecode(bufPtr, len, wantSaveToEmlFile);
|
||||
num++;
|
||||
}
|
||||
bufPtr += len;
|
||||
bufPtr += ((len-1)/8+1); // ignore parity
|
||||
}
|
||||
pckNum = 0;
|
||||
bufsize = traceLen;
|
||||
memset(buf, 0x00, traceLen);
|
||||
}
|
||||
} // resp not NULL
|
||||
if (bufPtr == NULL) {
|
||||
PrintAndLog("Cannot allocate memory for trace");
|
||||
free(buf);
|
||||
return 2;
|
||||
}
|
||||
// what happens if LEN is bigger then TRACELEN --iceman
|
||||
memcpy(bufPtr, resp.d.asBytes, len);
|
||||
bufPtr += len;
|
||||
pckNum++;
|
||||
}
|
||||
|
||||
if (res == 2) { // received all data, start displaying
|
||||
blockLen = bufPtr - buf;
|
||||
bufPtr = buf;
|
||||
printf(">\n");
|
||||
PrintAndLog("received trace len: %d packages: %d", blockLen, pckNum);
|
||||
while (bufPtr - buf < blockLen) {
|
||||
bufPtr += 6; // skip (void) timing information
|
||||
len = *((uint16_t *)bufPtr);
|
||||
if(len & 0x8000) {
|
||||
isTag = true;
|
||||
len &= 0x7fff;
|
||||
} else {
|
||||
isTag = false;
|
||||
}
|
||||
bufPtr += 2;
|
||||
if ((len == 17) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff) && (bufPtr[15] == 0xff) && (bufPtr[16] == 0xff)) {
|
||||
memcpy(uid, bufPtr + 2, 10);
|
||||
memcpy(atqa, bufPtr + 2 + 10, 2);
|
||||
switch (atqa[0] & 0xC0) {
|
||||
case 0x80: uid_len = 10; break;
|
||||
case 0x40: uid_len = 7; break;
|
||||
default: uid_len = 4; break;
|
||||
}
|
||||
sak = bufPtr[14];
|
||||
PrintAndLog("tag select uid| %s atqa:0x%02x%02x sak:0x%02x",
|
||||
sprint_hex(uid, uid_len),
|
||||
atqa[1],
|
||||
atqa[0],
|
||||
sak);
|
||||
if (wantLogToFile || wantDecrypt) {
|
||||
FillFileNameByUID(logHexFileName, uid, ".log", uid_len);
|
||||
AddLogCurrentDT(logHexFileName);
|
||||
}
|
||||
if (wantDecrypt)
|
||||
mfTraceInit(uid, uid_len, atqa, sak, wantSaveToEmlFile);
|
||||
} else {
|
||||
PrintAndLog("%03d| %s |%s", num, isTag ? "TAG" : "RDR", sprint_hex(bufPtr, len));
|
||||
if (wantLogToFile)
|
||||
AddLogHex(logHexFileName, isTag ? "TAG| ":"RDR| ", bufPtr, len);
|
||||
if (wantDecrypt)
|
||||
mfTraceDecode(bufPtr, len, wantSaveToEmlFile);
|
||||
num++;
|
||||
}
|
||||
bufPtr += len;
|
||||
bufPtr += ((len-1)/8+1); // ignore parity
|
||||
}
|
||||
pckNum = 0;
|
||||
}
|
||||
} // while (true)
|
||||
|
||||
free(buf);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -71,7 +71,7 @@ int CmdHF14AMfDESAuth(const char *Cmd){
|
|||
if (isOK){
|
||||
PrintAndLog("enc(nc)/b0:%s", sprint_hex(data+2,8));
|
||||
memcpy(b0,data+2,8);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
}
|
||||
|
@ -107,10 +107,9 @@ 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;
|
||||
|
@ -171,7 +170,7 @@ int CmdHF14AMfAESAuth(const char *Cmd){
|
|||
if (isOK){
|
||||
PrintAndLog("enc(nc)/b0:%s", sprint_hex(data+2,16));
|
||||
memcpy(b0,data+2,16);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
}
|
||||
|
@ -210,14 +209,13 @@ 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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue