mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-29 19:18:35 -07:00
HF Search - refactoring cmds to work with it
This commit is contained in:
parent
8ceb6b03e5
commit
6ce0e5386a
8 changed files with 76 additions and 33 deletions
|
@ -1688,13 +1688,15 @@ void ReaderIClass(uint8_t arg0) {
|
|||
int read_status= 0;
|
||||
uint8_t result_status = 0;
|
||||
bool abort_after_read = arg0 & FLAG_ICLASS_READER_ONLY_ONCE;
|
||||
|
||||
bool try_once = arg0 & FLAG_ICLASS_READER_ONE_TRY;
|
||||
set_tracing(TRUE);
|
||||
setupIclassReader();
|
||||
|
||||
uint16_t tryCnt=0;
|
||||
while(!BUTTON_PRESS())
|
||||
{
|
||||
|
||||
if (try_once && tryCnt > 5) break;
|
||||
tryCnt++;
|
||||
if(!tracing) {
|
||||
DbpString("Trace full");
|
||||
break;
|
||||
|
|
|
@ -87,7 +87,7 @@ void annotateIso14443a(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
|
|||
case MIFARE_ULC_AUTH_2: snprintf(exp,size,"AUTH_ANSW"); break;
|
||||
case MIFARE_ULEV1_AUTH: snprintf(exp,size,"PWD-AUTH"); break;
|
||||
case MIFARE_ULEV1_FASTREAD:{
|
||||
if ( cmdsize >=3 && cmd[2] < 0x21)
|
||||
if ( cmdsize >=3 && cmd[2] <= 0xE6)
|
||||
snprintf(exp,size,"READ RANGE (%d-%d)",cmd[1],cmd[2]);
|
||||
else
|
||||
snprintf(exp,size,"?");
|
||||
|
@ -546,17 +546,28 @@ int CmdHFList(const char *Cmd)
|
|||
|
||||
int CmdHFSearch(const char *Cmd){
|
||||
int ans = 0;
|
||||
ans = CmdHF14AReader(Cmd);
|
||||
if (ans > 0) return ans;
|
||||
PrintAndLog("");
|
||||
ans = CmdHF14AReader("s");
|
||||
if (ans > 0) {
|
||||
PrintAndLog("\nValid ISO14443A Tag Found - Quiting Search\n");
|
||||
return ans;
|
||||
}
|
||||
ans = HFiClassReader("", false, false);
|
||||
if (ans) {
|
||||
PrintAndLog("\nValid iClass Tag (or PicoPass Tag) Found - Quiting Search\n");
|
||||
return ans;
|
||||
}
|
||||
ans = HF15Reader("", false);
|
||||
if (ans) {
|
||||
PrintAndLog("\nValid ISO15693 Tag Found - Quiting Search\n");
|
||||
return ans;
|
||||
}
|
||||
|
||||
ans = CmdHF15Reader(Cmd);
|
||||
|
||||
//14b has issues currently...
|
||||
//ans = CmdHF14BRead(Cmd);
|
||||
//if (ans > 0) return ans;
|
||||
|
||||
ans = CmdHF14BRead(Cmd);
|
||||
//if (ans > 0) return ans;
|
||||
|
||||
ans = CmdHFiClassReader(Cmd);
|
||||
//if (ans > 0) return ans;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -573,7 +584,7 @@ static command_t CommandTable[] =
|
|||
{"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
|
||||
{"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"},
|
||||
{"list", CmdHFList, 1, "List protocol data in trace buffer"},
|
||||
{"search", CmdHFSearch, 1, "Search for known HF tags"},
|
||||
{"search", CmdHFSearch, 1, "Search for known HF tags [preliminary]"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ int CmdHF14AReader(const char *Cmd)
|
|||
uint64_t select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
|
||||
|
||||
if(select_status == 0) {
|
||||
PrintAndLog("iso14443a card select failed");
|
||||
if (Cmd[0] != 's') PrintAndLog("iso14443a card select failed");
|
||||
// disconnect
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = 0;
|
||||
|
|
|
@ -374,6 +374,20 @@ int CmdHF15Record(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int HF15Reader(const char *Cmd, bool verbose)
|
||||
{
|
||||
uint8_t uid[8];
|
||||
|
||||
if (!getUID(uid)) {
|
||||
if (verbose) PrintAndLog("No Tag found.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("Tag UID : %s",sprintUID(NULL,uid));
|
||||
PrintAndLog("Tag Info: %s",getTagInfo(uid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CmdHF15Reader(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
|
||||
|
@ -469,7 +483,7 @@ int CmdHF15DumpMem(const char*Cmd) {
|
|||
// PrintAndLog("bn=%i",blocknum);
|
||||
} else {
|
||||
PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1]));
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
} // else PrintAndLog("crc");
|
||||
} // else PrintAndLog("r null");
|
||||
|
@ -481,7 +495,7 @@ int CmdHF15DumpMem(const char*Cmd) {
|
|||
// PrintAndLog("CRC Failed");
|
||||
// else
|
||||
// PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1]));
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ int CmdHF15(const char *Cmd);
|
|||
|
||||
int CmdHF15Demod(const char *Cmd);
|
||||
int CmdHF15Read(const char *Cmd);
|
||||
int HF15Reader(const char *Cmd, bool verbose);
|
||||
int CmdHF15Reader(const char *Cmd);
|
||||
int CmdHF15Sim(const char *Cmd);
|
||||
int CmdHF15Record(const char *Cmd);
|
||||
|
|
|
@ -165,34 +165,47 @@ int CmdHFiClassSim(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdHFiClassReader(const char *Cmd)
|
||||
int HFiClassReader(const char *Cmd, bool loop, bool verbose)
|
||||
{
|
||||
bool tagFound = false;
|
||||
UsbCommand c = {CMD_READER_ICLASS, {FLAG_ICLASS_READER_CSN|
|
||||
FLAG_ICLASS_READER_CONF|FLAG_ICLASS_READER_AA}};
|
||||
if (!loop) c.arg[0] |= FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_ONE_TRY;
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
while(!ukbhit()){
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,4500)) {
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp, 4500)) {
|
||||
uint8_t readStatus = resp.arg[0] & 0xff;
|
||||
uint8_t * data = resp.d.asBytes;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLog("Readstatus:%02x", readStatus);
|
||||
if( readStatus == 0){
|
||||
//Aborted
|
||||
PrintAndLog("Quitting...");
|
||||
if (verbose) PrintAndLog("Quitting...");
|
||||
return 0;
|
||||
}
|
||||
if( readStatus & FLAG_ICLASS_READER_CSN) PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CSN){
|
||||
PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
tagFound = true;
|
||||
}
|
||||
if( readStatus & FLAG_ICLASS_READER_CC) PrintAndLog("CC: %s",sprint_hex(data+16,8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CONF){
|
||||
printIclassDumpInfo(data);
|
||||
}
|
||||
if (tagFound && !loop) return 1;
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
if (verbose) PrintAndLog("Command execute timeout");
|
||||
}
|
||||
if (!loop) break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int CmdHFiClassReader(const char *Cmd)
|
||||
{
|
||||
return HFiClassReader(Cmd, true, true);
|
||||
}
|
||||
|
||||
int CmdHFiClassReader_Replay(const char *Cmd)
|
||||
|
|
|
@ -17,6 +17,7 @@ int CmdHFiClass(const char *Cmd);
|
|||
int CmdHFiClassSnoop(const char *Cmd);
|
||||
int CmdHFiClassSim(const char *Cmd);
|
||||
int CmdHFiClassList(const char *Cmd);
|
||||
int HFiClassReader(const char *Cmd, bool loop, bool verbose);
|
||||
int CmdHFiClassReader(const char *Cmd);
|
||||
int CmdHFiClassReader_Replay(const char *Cmd);
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ typedef struct{
|
|||
#define FLAG_ICLASS_READER_CSN 0x04
|
||||
#define FLAG_ICLASS_READER_CONF 0x08
|
||||
#define FLAG_ICLASS_READER_AA 0x10
|
||||
#define FLAG_ICLASS_READER_ONE_TRY 0x20
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue