chg: 'hf 15 *' first rehaul of the iso15693 commands. Call it a refactor, Started adding helptext, 'h' parameter, usage of sprint_hex

chg: cmdhf15.h - extern keyword in headerfile
This commit is contained in:
iceman1001 2017-09-01 20:34:17 +02:00
commit c0948b5d7b
2 changed files with 284 additions and 274 deletions

View file

@ -53,7 +53,6 @@ typedef struct {
char* desc; char* desc;
} productName; } productName;
const productName uidmapping[] = { const productName uidmapping[] = {
// UID, #significant Bits, "Vendor(+Product)" // UID, #significant Bits, "Vendor(+Product)"
@ -198,22 +197,22 @@ const productName uidmapping[] = {
{ 0,0,"no tag-info available" } // must be the last entry { 0,0,"no tag-info available" } // must be the last entry
}; };
// fast method to just read the UID of a tag (collission detection not supported) // fast method to just read the UID of a tag (collission detection not supported)
// *buf should be large enough to fit the 64bit uid // *buf should be large enough to fit the 64bit uid
// returns 1 if suceeded // returns 1 if suceeded
int getUID(uint8_t *buf) int getUID(uint8_t *buf) {
{
UsbCommand resp; UsbCommand resp;
uint8_t *recv; uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv? UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes; uint8_t *req = c.d.asBytes;
req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
req[1] = ISO15_CMD_INVENTORY;
int reqlen = 0; int reqlen = 0;
for (int retry = 0; retry <3; retry++) { // don't give up the at the first try // don't give up the at the first try
for (int retry = 0; retry <3; retry++) {
req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
req[1] = ISO15_CMD_INVENTORY;
req[2] = 0; // mask length req[2] = 0; // mask length
reqlen = AddCrc(req, 3); reqlen = AddCrc(req, 3);
c.arg[0] = reqlen; c.arg[0] = reqlen;
@ -223,8 +222,8 @@ int getUID(uint8_t *buf)
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
recv = resp.d.asBytes; recv = resp.d.asBytes;
if (resp.arg[0] >= 12 && ISO15_CRC_CHECK == Crc(recv,12)) { if (resp.arg[0] >= 12 && ISO15_CRC_CHECK == Crc(recv, 12)) {
memcpy(buf,&recv[2],8); memcpy(buf, recv + 2, 8);
return 1; return 1;
} }
} }
@ -232,8 +231,6 @@ int getUID(uint8_t *buf)
return 0; return 0;
} }
// get a product description based on the UID // get a product description based on the UID
// uid[8] tag uid // uid[8] tag uid
// returns description of the best match // returns description of the best match
@ -260,7 +257,6 @@ static char* getTagInfo_15(uint8_t *uid) {
return uidmapping[i].desc; return uidmapping[i].desc;
} }
// return a clear-text message to an errorcode // return a clear-text message to an errorcode
static char* TagErrorStr(uint8_t error) { static char* TagErrorStr(uint8_t error) {
switch (error) { switch (error) {
@ -277,12 +273,43 @@ static char* TagErrorStr(uint8_t error) {
} }
} }
int usage_15_demod(void){
PrintAndLog("Tries to demodulate / decode ISO15693, from downloaded samples.");
PrintAndLog("Gather samples with 'hf 15 read' / 'hf 15 record'");
return 0;
}
int usage_15_read(void){
PrintAndLog("Acquire samples as Reader (enables carrier, send inquiry");
return 0;
}
int usage_15_record(void){
PrintAndLog("Record activity without enableing carrier");
return 0;
}
int usage_15_reader(void){
return 0;
}
int usage_15_sim(void){
PrintAndLog("Usage: hf 15 sim <UID>");
PrintAndLog("");
PrintAndLog("sample:");
PrintAndLog(" hf 15 sim E016240000000000");
return 0;
}
int usage_15_findafi(void){
return 0;
}
int usage_15_dumpmem(void){
return 0;
}
// Mode 3 // Mode 3
int CmdHF15Demod(const char *Cmd) //helptext
{ int CmdHF15Demod(const char *Cmd) {
// The sampling rate is 106.353 ksps/s, for T = 18.8 us char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_15_demod();
// The sampling rate is 106.353 ksps/s, for T = 18.8 us
int i, j; int i, j;
int max = 0, maxPos = 0; int max = 0, maxPos = 0;
int skip = 4; int skip = 4;
@ -290,7 +317,7 @@ int CmdHF15Demod(const char *Cmd)
if (GraphTraceLen < 1000) return 0; if (GraphTraceLen < 1000) return 0;
// First, correlate for SOF // First, correlate for SOF
for (i = 0; i < 100; i++) { for (i = 0; i < 1000; i++) {
int corr = 0; int corr = 0;
for (j = 0; j < ARRAYLEN(FrameSOF); j += skip) { for (j = 0; j < ARRAYLEN(FrameSOF); j += skip) {
corr += FrameSOF[j] * GraphBuffer[i + (j / skip)]; corr += FrameSOF[j] * GraphBuffer[i + (j / skip)];
@ -300,6 +327,7 @@ int CmdHF15Demod(const char *Cmd)
maxPos = i; maxPos = i;
} }
} }
PrintAndLog("SOF at %d, correlation %d", maxPos, max / (ARRAYLEN(FrameSOF) / skip)); PrintAndLog("SOF at %d, correlation %d", maxPos, max / (ARRAYLEN(FrameSOF) / skip));
i = maxPos + ARRAYLEN(FrameSOF) / skip; i = maxPos + ARRAYLEN(FrameSOF) / skip;
@ -341,24 +369,26 @@ int CmdHF15Demod(const char *Cmd)
break; break;
} }
} }
if (mask != 0x01) { if (mask != 0x01) {
PrintAndLog("error, uneven octet! (discard extra bits!)"); PrintAndLog("error, uneven octet! (discard extra bits!)");
PrintAndLog(" mask=%02x", mask); PrintAndLog(" mask = %02x", mask);
} }
PrintAndLog("%d octets", k); PrintAndLog("%d octets", k);
for (i = 0; i < k; i++) { for (i = 0; i < k; i++)
PrintAndLog("# %2d: %02x ", i, outBuf[i]); PrintAndLog("# %2d: %02x ", i, outBuf[i]);
}
PrintAndLog("CRC=%04x", Iso15693Crc(outBuf, k - 2)); PrintAndLog("CRC %04x", Iso15693Crc(outBuf, k - 2));
return 0; return 0;
} }
// * Acquire Samples as Reader (enables carrier, sends inquiry) // * Acquire Samples as Reader (enables carrier, sends inquiry)
int CmdHF15Read(const char *Cmd) //helptext
{ int CmdHF15Read(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_15_read();
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693}; UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
@ -366,30 +396,36 @@ int CmdHF15Read(const char *Cmd)
} }
// Record Activity without enabeling carrier // Record Activity without enabeling carrier
int CmdHF15Record(const char *Cmd) //helptext
{ int CmdHF15Record(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_15_record();
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693}; UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
// used with 'hf search'
int HF15Reader(const char *Cmd, bool verbose) int HF15Reader(const char *Cmd, bool verbose)
{ {
uint8_t uid[8]; uint8_t uid[8] = {0,0,0,0,0,0,0,0};
if (!getUID(uid)) { if (!getUID(uid)) {
if (verbose) PrintAndLog("No Tag found."); if (verbose) PrintAndLog("No Tag found.");
return 0; return 0;
} }
PrintAndLog("Tag UID : %s", sprintUID(NULL,uid)); PrintAndLog("Tag UID : %s", sprintUID(NULL, uid));
PrintAndLog("Tag Info: %s", getTagInfo_15(uid)); PrintAndLog("Tag Info: %s", getTagInfo_15(uid));
return 1; return 1;
} }
int CmdHF15Reader(const char *Cmd) //helptext
{ int CmdHF15Reader(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_15_reader();
UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}}; UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
@ -397,29 +433,21 @@ int CmdHF15Reader(const char *Cmd)
} }
// Simulation is still not working very good // Simulation is still not working very good
int CmdHF15Sim(const char *Cmd) // helptext
{ int CmdHF15Sim(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0); char cmdp = param_getchar(Cmd, 0);
uint8_t uid[8] = {0x00}; if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') return usage_15_sim();
//E0 16 24 00 00 00 00 00
if (cmdp == 'h' || cmdp == 'H') {
PrintAndLog("Usage: hf 15 sim <UID>");
PrintAndLog("");
PrintAndLog(" sample: hf 15 sim E016240000000000");
return 0;
}
uint8_t uid[8] = {0,0,0,0,0,0,0,0};
if (param_gethex(Cmd, 0, uid, 16)) { if (param_gethex(Cmd, 0, uid, 16)) {
PrintAndLog("UID must include 16 HEX symbols"); PrintAndLog("UID must include 16 HEX symbols");
return 0; return 0;
} }
PrintAndLog("Starting simulating UID %02X %02X %02X %02X %02X %02X %02X %02X", PrintAndLog("Starting simulating UID %s", sprint_hex(uid, sizeof(uid)) );
uid[0],uid[1],uid[2],uid[3],uid[4], uid[5], uid[6], uid[7]);
UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}}; UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}};
memcpy(c.d.asBytes,uid,8); memcpy(c.d.asBytes, uid, 8);
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
@ -427,8 +455,11 @@ int CmdHF15Sim(const char *Cmd)
// finds the AFI (Application Family Idendifier) of a card, by trying all values // finds the AFI (Application Family Idendifier) of a card, by trying all values
// (There is no standard way of reading the AFI, allthough some tags support this) // (There is no standard way of reading the AFI, allthough some tags support this)
int CmdHF15Afi(const char *Cmd) // helptext
{ int CmdHF15Afi(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_15_findafi();
UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}}; UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
@ -436,15 +467,21 @@ int CmdHF15Afi(const char *Cmd)
} }
// Reads all memory pages // Reads all memory pages
// helptext
int CmdHF15DumpMem(const char*Cmd) { int CmdHF15DumpMem(const char*Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_15_dumpmem();
uint8_t uid[8] = {0,0,0,0,0,0,0,0}; uint8_t uid[8] = {0,0,0,0,0,0,0,0};
uint8_t *recv = NULL; uint8_t *recv = NULL;
UsbCommand resp; UsbCommand resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv? UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes; uint8_t *req = c.d.asBytes;
req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
req[1] = ISO15_CMD_READ;
int reqlen = 0, blocknum = 0; int reqlen = 0, blocknum = 0;
char output[80] = {0};
if (!getUID(uid)) { if (!getUID(uid)) {
PrintAndLog("No Tag found."); PrintAndLog("No Tag found.");
@ -455,10 +492,7 @@ int CmdHF15DumpMem(const char*Cmd) {
PrintAndLog("Tag Info: %s", getTagInfo_15(uid)); PrintAndLog("Tag Info: %s", getTagInfo_15(uid));
for (int retry=0; retry<5; retry++) { for (int retry=0; retry<5; retry++) {
req[0]= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH |
ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
req[1]=ISO15_CMD_READ;
memcpy(&req[2], uid, 8); memcpy(&req[2], uid, 8);
req[10] = blocknum; req[10] = blocknum;
reqlen = AddCrc(req, 11); reqlen = AddCrc(req, 11);
@ -468,30 +502,24 @@ int CmdHF15DumpMem(const char*Cmd) {
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
uint8_t len = resp.arg[0];
recv = resp.d.asBytes; recv = resp.d.asBytes;
if (ISO15_CRC_CHECK==Crc(recv,resp.arg[0])) {
if ( ISO15_CRC_CHECK == Crc(recv, len) ) {
if (!(recv[0] & ISO15_RES_ERROR)) { if (!(recv[0] & ISO15_RES_ERROR)) {
retry = 0; retry = 0;
*output = 0; // reset outputstring PrintAndLog("%Block %02x | %s", blocknum, sprint_hex_ascii( recv, len - 2 ) );
sprintf(output, "Block %02x ",blocknum);
for ( int i=1; i<resp.arg[0]-2; i++) { // data in hex
sprintf(output+strlen(output),"%02X ",recv[i]);
}
strcat(output," ");
for ( int i = 1; i < resp.arg[0]-2; i++) { // data in cleaned ascii
sprintf(output+strlen(output),"%c",(recv[i] > 31 && recv[i] < 127) ? recv[i] : '.');
}
PrintAndLog("%s",output);
blocknum++; blocknum++;
// PrintAndLog("bn=%i",blocknum);
} else { } else {
PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); PrintAndLog("Tag returned Error %i: %s", recv[1], TagErrorStr(recv[1]) );
return 1; return 1;
} }
} // else PrintAndLog("crc"); }
} }
// else PrintAndLog("r null"); }
} // retry
// TODO: need fix // TODO: need fix
// if (resp.arg[0]<3) // if (resp.arg[0]<3)
// PrintAndLog("Lost Connection"); // PrintAndLog("Lost Connection");
@ -501,32 +529,28 @@ int CmdHF15DumpMem(const char*Cmd) {
// PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); // PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1]));
return 1; return 1;
} }
// "HF 15" interface // "HF 15" interface
static command_t CommandTable15[] = {
static command_t CommandTable15[] = {"help", CmdHF15Help, 1, "This help"},
{ {"demod", CmdHF15Demod, 1, "Demodulate ISO15693 from tag"},
{"help", CmdHF15Help, 1, "This help"}, {"read", CmdHF15Read, 0, "Read ISO 15693 tag"},
{"demod", CmdHF15Demod, 1, "Demodulate ISO15693 from tag"}, {"record", CmdHF15Record, 0, "Record Samples (ISO 15693)"},
{"read", CmdHF15Read, 0, "Read HF tag (ISO 15693)"}, {"reader", CmdHF15Reader, 0, "Act like an ISO15693 reader"},
{"record", CmdHF15Record, 0, "Record Samples (ISO 15693)"}, // atrox {"sim", CmdHF15Sim, 0, "Fake an ISO15693 tag"},
{"reader", CmdHF15Reader, 0, "Act like an ISO15693 reader"}, {"findafi", CmdHF15Afi, 0, "Brute force AFI of an ISO15693 tag"},
{"sim", CmdHF15Sim, 0, "Fake an ISO15693 tag"}, {"dumpmemory", CmdHF15DumpMem, 0, "Read all memory pages of an ISO15693 tag"},
{"cmd", CmdHF15Cmd, 0, "Send direct commands to ISO15693 tag"}, {"cmd", CmdHF15Cmd, 0, "Send commands to ISO15693 tag"},
{"findafi", CmdHF15Afi, 0, "Brute force AFI of an ISO15693 tag"}, {"debug", CmdHF15CmdDebug,0, "Turn debugging on/off"},
{"dumpmemory", CmdHF15DumpMem, 0, "Read all memory pages of an ISO15693 tag"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
int CmdHF15(const char *Cmd) int CmdHF15(const char *Cmd) {
{ clearCommandBuffer();
CmdsParse(CommandTable15, Cmd); CmdsParse(CommandTable15, Cmd);
return 0; return 0;
} }
int CmdHF15Help(const char *Cmd) int CmdHF15Help(const char *Cmd) {
{
CmdsHelp(CommandTable15); CmdsHelp(CommandTable15);
return 0; return 0;
} }
@ -534,17 +558,15 @@ int CmdHF15Help(const char *Cmd)
// "HF 15 Cmd" Interface // "HF 15 Cmd" Interface
// Allows direct communication with the tag on command level // Allows direct communication with the tag on command level
int CmdHF15CmdInquiry(const char *Cmd) {
int CmdHF15CmdInquiry(const char *Cmd)
{
UsbCommand resp; UsbCommand resp;
uint8_t *recv; uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv? UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req=c.d.asBytes; uint8_t *req = c.d.asBytes;
int reqlen=0; int reqlen = 0;
req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
req[1] = ISO15_CMD_INVENTORY; req[1] = ISO15_CMD_INVENTORY;
req[2] = 0; // mask length req[2] = 0; // mask length
reqlen = AddCrc(req,3); reqlen = AddCrc(req,3);
@ -553,11 +575,11 @@ int CmdHF15CmdInquiry(const char *Cmd)
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
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) );
} else { } else {
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]);
} }
@ -567,39 +589,27 @@ int CmdHF15CmdInquiry(const char *Cmd)
return 0; return 0;
} }
// Turns debugging on(1)/off(0) // Turns debugging on(1)/off(0)
int CmdHF15CmdDebug( const char *cmd) { int CmdHF15CmdDebug( const char *Cmd) {
int debug = atoi(cmd);
if (strlen(cmd)<1) { char cmdp = param_getchar(Cmd, 0);
if (strlen(Cmd)<1 || cmdp == 'h' || cmdp == 'H') {
PrintAndLog("Usage: hf 15 cmd debug <0|1>"); PrintAndLog("Usage: hf 15 cmd debug <0|1>");
PrintAndLog(" 0 no debugging"); PrintAndLog(" 0 no debugging");
PrintAndLog(" 1 turn debugging on"); PrintAndLog(" 1 turn debugging on");
return 0; return 0;
} }
int debug = atoi(Cmd);
UsbCommand c = {CMD_ISO_15693_DEBUG, {debug, 0, 0}}; UsbCommand c = {CMD_ISO_15693_DEBUG, {debug, 0, 0}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
int CmdHF15CmdRaw(const char *Cmd) {
int CmdHF15CmdRaw (const char *cmd) { char cmdp = param_getchar(Cmd, 0);
UsbCommand resp; if (strlen(Cmd)<3 || cmdp == 'h' || cmdp == 'H') {
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
int reply=1;
int fast=1;
int crc=0;
char buf[5]="";
int i=0;
uint8_t data[100];
unsigned int datalen=0, temp;
char *hexout;
if (strlen(cmd)<3) {
PrintAndLog("Usage: hf 15 cmd raw [-r] [-2] [-c] <0A 0B 0C ... hex>"); PrintAndLog("Usage: hf 15 cmd raw [-r] [-2] [-c] <0A 0B 0C ... hex>");
PrintAndLog(" -r do not read response"); PrintAndLog(" -r do not read response");
PrintAndLog(" -2 use slower '1 out of 256' mode"); PrintAndLog(" -2 use slower '1 out of 256' mode");
@ -608,13 +618,20 @@ int CmdHF15CmdRaw (const char *cmd) {
return 0; return 0;
} }
// strip UsbCommand resp;
while (*cmd==' ' || *cmd=='\t') cmd++; UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
int reply = 1, fast = 1, crc = 0, i = 0;
char buf[5] = "";
uint8_t data[100];
uint32_t datalen = 0, temp;
while (cmd[i]!='\0') { // strip
if (cmd[i]==' ' || cmd[i]=='\t') { i++; continue; } while (*Cmd==' ' || *Cmd=='\t') Cmd++;
if (cmd[i]=='-') {
switch (cmd[i+1]) { while (Cmd[i]!='\0') {
if (Cmd[i]==' ' || Cmd[i]=='\t') { i++; continue; }
if (Cmd[i]=='-') {
switch (Cmd[i+1]) {
case 'r': case 'r':
case 'R': case 'R':
reply=0; reply=0;
@ -633,11 +650,11 @@ int CmdHF15CmdRaw (const char *cmd) {
i+=2; i+=2;
continue; continue;
} }
if ((cmd[i]>='0' && cmd[i]<='9') || if ((Cmd[i]>='0' && Cmd[i]<='9') ||
(cmd[i]>='a' && cmd[i]<='f') || (Cmd[i]>='a' && Cmd[i]<='f') ||
(cmd[i]>='A' && cmd[i]<='F') ) { (Cmd[i]>='A' && Cmd[i]<='F') ) {
buf[strlen(buf)+1] = 0; buf[strlen(buf)+1] = 0;
buf[strlen(buf)] = cmd[i]; buf[strlen(buf)] = Cmd[i];
i++; i++;
if (strlen(buf) >= 2) { if (strlen(buf) >= 2) {
@ -651,37 +668,28 @@ int CmdHF15CmdRaw (const char *cmd) {
PrintAndLog("Invalid char on input"); PrintAndLog("Invalid char on input");
return 0; return 0;
} }
if (crc) datalen = AddCrc(data,datalen); if (crc) datalen = AddCrc(data, datalen);
c.arg[0] = datalen; c.arg[0] = datalen;
c.arg[1] = fast; c.arg[1] = fast;
c.arg[2] = reply; c.arg[2] = reply;
memcpy(c.d.asBytes,data,datalen); memcpy(c.d.asBytes, data, datalen);
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (reply) { if (reply) {
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
recv = resp.d.asBytes; uint8_t len = resp.arg[0];
PrintAndLog("received %i octets",resp.arg[0]); PrintAndLog("received %i octets", len);
hexout = (char *)malloc(resp.arg[0] * 3 + 1); PrintAndLog("%s", sprint_hex(resp.d.asBytes, len) );
if (hexout != NULL) {
for (int i = 0; i < resp.arg[0]; i++) { // data in hex
sprintf(&hexout[i * 3], "%02X ", recv[i]);
}
PrintAndLog("%s", hexout);
free(hexout);
}
} else { } else {
PrintAndLog("timeout while waiting for reply."); PrintAndLog("timeout while waiting for reply.");
} }
}
} // if reply
return 0; return 0;
} }
/** /**
* parses common HF 15 CMD parameters and prepares some data structures * parses common HF 15 CMD parameters and prepares some data structures
* Parameters: * Parameters:
@ -696,17 +704,17 @@ int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd[], int iso15cmdle
// strip // strip
while (**cmd==' ' || **cmd=='\t') (*cmd)++; while (**cmd==' ' || **cmd=='\t') (*cmd)++;
if (strstr(*cmd,"-2")==*cmd) { if (strstr(*cmd, "-2") == *cmd) {
c->arg[1]=0; // use 1of256 c->arg[1] = 0; // use 1of256
(*cmd)+=2; (*cmd) += 2;
} }
// strip // strip
while (**cmd==' ' || **cmd=='\t') (*cmd)++; while (**cmd==' ' || **cmd=='\t') (*cmd)++;
if (strstr(*cmd,"-o")==*cmd) { if (strstr(*cmd,"-o") == *cmd) {
req[reqlen]=ISO15_REQ_OPTION; req[reqlen] = ISO15_REQ_OPTION;
(*cmd)+=2; (*cmd) += 2;
} }
// strip // strip
@ -720,59 +728,52 @@ int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd[], int iso15cmdle
case 's': case 's':
case 'S': case 'S':
// you must have selected the tag earlier // you must have selected the tag earlier
req[reqlen++]|= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_SELECT;
ISO15_REQ_NONINVENTORY | ISO15_REQ_SELECT; memcpy(&req[reqlen], &iso15cmd[0], iso15cmdlen);
memcpy(&req[reqlen],&iso15cmd[0],iso15cmdlen); reqlen += iso15cmdlen;
reqlen+=iso15cmdlen; break;
break;
case 'u': case 'u':
case 'U': case 'U':
// unaddressed mode may not be supported by all vendors // unaddressed mode may not be supported by all vendors
req[reqlen++]|= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY;
ISO15_REQ_NONINVENTORY; memcpy(&req[reqlen], &iso15cmd[0], iso15cmdlen);
memcpy(&req[reqlen],&iso15cmd[0],iso15cmdlen); reqlen += iso15cmdlen;
reqlen+=iso15cmdlen; break;
break;
case '*': case '*':
// we scan for the UID ourself // we scan for the UID ourself
req[reqlen++]|= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS; memcpy(&req[reqlen], &iso15cmd[0], iso15cmdlen);
memcpy(&req[reqlen],&iso15cmd[0],iso15cmdlen); reqlen += iso15cmdlen;
reqlen+=iso15cmdlen; if (!getUID(uid)) {
if (!getUID(uid)) { PrintAndLog("No Tag found");
PrintAndLog("No Tag found"); return 0;
return 0; }
} memcpy(req+reqlen, uid, 8);
memcpy(req+reqlen,uid,8); PrintAndLog("Detected UID %s", sprintUID(NULL, uid));
PrintAndLog("Detected UID %s",sprintUID(NULL,uid)); reqlen += 8;
reqlen+=8;
break; break;
default: default:
req[reqlen++]|= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS; memcpy(&req[reqlen], &iso15cmd[0], iso15cmdlen);
memcpy(&req[reqlen],&iso15cmd[0],iso15cmdlen); reqlen += iso15cmdlen;
reqlen+=iso15cmdlen;
/* sscanf(cmd,"%hX%hX%hX%hX%hX%hX%hX%hX", // parse UID
(short unsigned int *)&uid[7],(short unsigned int *)&uid[6], for (int i=0; i<8 && (*cmd)[i*2] && (*cmd)[i*2+1]; i++) {
(short unsigned int *)&uid[5],(short unsigned int *)&uid[4], sscanf((char[]){(*cmd)[i*2], (*cmd)[i*2+1],0}, "%X", &temp);
(short unsigned int *)&uid[3],(short unsigned int *)&uid[2], uid[7-i] = temp&0xff;
(short unsigned int *)&uid[1],(short unsigned int *)&uid[0]); */
for (int i=0;i<8 && (*cmd)[i*2] && (*cmd)[i*2+1];i++) { // parse UID
sscanf((char[]){(*cmd)[i*2],(*cmd)[i*2+1],0},"%X",&temp);
uid[7-i]=temp&0xff;
} }
PrintAndLog("Using UID %s",sprintUID(NULL,uid)); PrintAndLog("Using UID %s", sprintUID(NULL, uid));
memcpy(&req[reqlen],&uid[0],8); memcpy(&req[reqlen], &uid[0], 8);
reqlen+=8; reqlen += 8;
break;
} }
// skip to next space // skip to next space
while (**cmd!=' ' && **cmd!='\t') (*cmd)++; while (**cmd!=' ' && **cmd!='\t') (*cmd)++;
// skip over the space // skip over the space
while (**cmd==' ' || **cmd=='\t') (*cmd)++; while (**cmd==' ' || **cmd=='\t') (*cmd)++;
c->arg[0]=reqlen; c->arg[0] = reqlen;
return 1; return 1;
} }
@ -781,20 +782,9 @@ int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd[], int iso15cmdle
* get system information from tag/VICC * get system information from tag/VICC
*/ */
int CmdHF15CmdSysinfo(const char *Cmd) { int CmdHF15CmdSysinfo(const char *Cmd) {
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0;
char cmdbuf[100];
char *cmd = cmdbuf;
char output[2048]="";
int i;
strncpy(cmd, Cmd, 99);
// usage: char cmdp = param_getchar(Cmd, 0);
if (strlen(cmd)<1) { if (strlen(Cmd)<1 || cmdp == 'h' || cmdp == 'H') {
PrintAndLog("Usage: hf 15 cmd sysinfo [options] <uid|s|u|*>"); PrintAndLog("Usage: hf 15 cmd sysinfo [options] <uid|s|u|*>");
PrintAndLog(" options:"); PrintAndLog(" options:");
PrintAndLog(" -2 use slower '1 out of 256' mode"); PrintAndLog(" -2 use slower '1 out of 256' mode");
@ -808,6 +798,18 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
return 0; return 0;
} }
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0;
char cmdbuf[100];
char *cmd = cmdbuf;
char output[2048] = "\0";
int i;
strncpy(cmd, Cmd, 99);
prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_SYSINFO},1); prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_SYSINFO},1);
reqlen = c.arg[0]; reqlen = c.arg[0];
@ -817,7 +819,7 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2000) && resp.arg[0] > 2) {
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)) {
@ -831,7 +833,7 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
strcat(output, "\n\r"); strcat(output, "\n\r");
strcat(output, getTagInfo_15(recv+2)); //ABC strcat(output, getTagInfo_15(recv+2)); //ABC
strcat(output, "\n\r"); strcat(output, "\n\r");
i=10; i = 10;
if (recv[1] & 0x01) if (recv[1] & 0x01)
sprintf(output+strlen(output),"DSFID supported, set to %02X\n\r",recv[i++]); sprintf(output+strlen(output),"DSFID supported, set to %02X\n\r",recv[i++]);
else else
@ -860,8 +862,7 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
} }
} else { } else {
PrintAndLog("timeout while waiting for reply."); PrintAndLog("timeout while waiting for reply.");
} }
return 0; return 0;
} }
@ -870,19 +871,9 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
* Read multiple blocks at once (not all tags support this) * Read multiple blocks at once (not all tags support this)
*/ */
int CmdHF15CmdReadmulti(const char *Cmd) { int CmdHF15CmdReadmulti(const char *Cmd) {
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum,pagecount;
char cmdbuf[100];
char *cmd = cmdbuf;
char output[2048] = "";
strncpy(cmd, Cmd, 99);
// usage: char cmdp = param_getchar(Cmd, 0);
if (strlen(cmd)<3) { if (strlen(Cmd)<3 || cmdp == 'h' || cmdp == 'H') {
PrintAndLog("Usage: hf 15 cmd readmulti [options] <uid|s|u|*> <start#> <count#>"); PrintAndLog("Usage: hf 15 cmd readmulti [options] <uid|s|u|*> <start#> <count#>");
PrintAndLog(" options:"); PrintAndLog(" options:");
PrintAndLog(" -2 use slower '1 out of 256' mode"); PrintAndLog(" -2 use slower '1 out of 256' mode");
@ -895,7 +886,18 @@ int CmdHF15CmdReadmulti(const char *Cmd) {
PrintAndLog(" count#: number of pages"); PrintAndLog(" count#: number of pages");
return 0; return 0;
} }
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum,pagecount;
char cmdbuf[100];
char *cmd = cmdbuf;
char output[2048] = "";
strncpy(cmd, Cmd, 99);
prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_READMULTI},1); prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_READMULTI},1);
reqlen = c.arg[0]; reqlen = c.arg[0];
@ -919,9 +921,9 @@ int CmdHF15CmdReadmulti(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2000) && resp.arg[0] > 2) {
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)) {
*output=0; // reset outputstring *output=0; // reset outputstring
for ( int i=1; i<resp.arg[0]-2; i++) { for ( int i=1; i<resp.arg[0]-2; i++) {
@ -950,19 +952,9 @@ int CmdHF15CmdReadmulti(const char *Cmd) {
* Reads a single Block * Reads a single Block
*/ */
int CmdHF15CmdRead(const char *Cmd) { int CmdHF15CmdRead(const char *Cmd) {
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum;
char cmdbuf[100];
char *cmd = cmdbuf;
char output[100] = "";
strncpy(cmd,Cmd,99);
// usage: char cmdp = param_getchar(Cmd, 0);
if (strlen(cmd)<3) { if (strlen(Cmd)<3 || cmdp == 'h' || cmdp == 'H') {
PrintAndLog("Usage: hf 15 cmd read [options] <uid|s|u|*> <page#>"); PrintAndLog("Usage: hf 15 cmd read [options] <uid|s|u|*> <page#>");
PrintAndLog(" options:"); PrintAndLog(" options:");
PrintAndLog(" -2 use slower '1 out of 256' mode"); PrintAndLog(" -2 use slower '1 out of 256' mode");
@ -975,27 +967,39 @@ int CmdHF15CmdRead(const char *Cmd) {
return 0; return 0;
} }
UsbCommand resp;
uint8_t *recv;
// UsbCommand arg: len, speed, recv?
// arg0 (datalen, cmd len? )
// arg1 (speed == 0 == 1 of 256, == 1 == 1 of 4 )
// arg2 (recv == 1 == expect a response)
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}};
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum;
char cmdbuf[100];
char *cmd = cmdbuf;
char output[100] = "";
strncpy(cmd, Cmd, 99);
prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_READ},1); prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_READ},1);
reqlen = c.arg[0]; reqlen = c.arg[0];
pagenum = strtol(cmd, NULL, 0); pagenum = strtol(cmd, NULL, 0);
/*if (pagenum<0) {
PrintAndLog("invalid pagenum");
return 0;
} */
req[reqlen++] = (uint8_t)pagenum; req[reqlen++] = (uint8_t)pagenum;
reqlen = AddCrc(req,reqlen); reqlen = AddCrc(req, reqlen);
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2000) && resp.arg[0] > 2) {
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)) {
*output=0; // reset outputstring *output=0; // reset outputstring
//sprintf(output, "Block %2i ",blocknum); //sprintf(output, "Block %2i ",blocknum);
@ -1006,7 +1010,7 @@ int CmdHF15CmdRead(const char *Cmd) {
for ( int i=1; i<resp.arg[0]-2; i++) { for ( int i=1; i<resp.arg[0]-2; i++) {
sprintf(output+strlen(output),"%c",recv[i]>31 && recv[i]<127?recv[i]:'.'); sprintf(output+strlen(output),"%c",recv[i]>31 && recv[i]<127?recv[i]:'.');
} }
PrintAndLog("%s",output); PrintAndLog("%s", output);
} else { } else {
PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1]));
} }
@ -1016,7 +1020,6 @@ int CmdHF15CmdRead(const char *Cmd) {
} else { } else {
PrintAndLog("timeout while waiting for reply."); PrintAndLog("timeout while waiting for reply.");
} }
return 0; return 0;
} }
@ -1026,19 +1029,9 @@ int CmdHF15CmdRead(const char *Cmd) {
* Writes a single Block - might run into timeout, even when successful * Writes a single Block - might run into timeout, even when successful
*/ */
int CmdHF15CmdWrite(const char *Cmd) { int CmdHF15CmdWrite(const char *Cmd) {
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req=c.d.asBytes;
int reqlen=0, pagenum, temp;
char cmdbuf[100];
char *cmd=cmdbuf;
char *cmd2;
strncpy(cmd,Cmd,99);
// usage: char cmdp = param_getchar(Cmd, 0);
if (strlen(cmd)<3) { if (strlen(Cmd)<3 || cmdp == 'h' || cmdp == 'H') {
PrintAndLog("Usage: hf 15 cmd write [options] <uid|s|u|*> <page#> <hexdata>"); PrintAndLog("Usage: hf 15 cmd write [options] <uid|s|u|*> <page#> <hexdata>");
PrintAndLog(" options:"); PrintAndLog(" options:");
PrintAndLog(" -2 use slower '1 out of 256' mode"); PrintAndLog(" -2 use slower '1 out of 256' mode");
@ -1053,22 +1046,29 @@ int CmdHF15CmdWrite(const char *Cmd) {
return 0; return 0;
} }
UsbCommand resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum, temp;
char cmdbuf[100];
char *cmd = cmdbuf;
char *cmd2;
strncpy(cmd,Cmd,99);
prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_WRITE},1); prepareHF15Cmd(&cmd, &c,(uint8_t[]){ISO15_CMD_WRITE},1);
reqlen=c.arg[0]; reqlen=c.arg[0];
// *cmd -> page num ; *cmd2 -> data // *cmd -> page num ; *cmd2 -> data
cmd2=cmd; cmd2=cmd;
while (*cmd2!=' ' && *cmd2!='\t' && *cmd2) cmd2++; while (*cmd2!=' ' && *cmd2!='\t' && *cmd2) cmd2++;
*cmd2=0; *cmd2 = 0;
cmd2++; cmd2++;
pagenum=strtol(cmd,NULL,0); pagenum = strtol(cmd, NULL, 0);
/*if (pagenum<0) {
PrintAndLog("invalid pagenum"); req[reqlen++] = (uint8_t)pagenum;
return 0;
} */
req[reqlen++]=(uint8_t)pagenum;
while (cmd2[0] && cmd2[1]) { // hexdata, read by 2 hexchars while (cmd2[0] && cmd2[1]) { // hexdata, read by 2 hexchars
if (*cmd2==' ') { if (*cmd2==' ') {
@ -1080,19 +1080,19 @@ int CmdHF15CmdWrite(const char *Cmd) {
cmd2+=2; cmd2+=2;
} }
reqlen=AddCrc(req,reqlen); reqlen = AddCrc(req,reqlen);
c.arg[0]=reqlen; c.arg[0] = reqlen;
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,2000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK,&resp,2000) && resp.arg[0]>2) {
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)) {
PrintAndLog("OK"); PrintAndLog("OK");
} else { } else {
PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); PrintAndLog("Tag returned Error %i: %s", recv[1], TagErrorStr(recv[1]));
} }
} else { } else {
PrintAndLog("CRC failed"); PrintAndLog("CRC failed");
@ -1100,7 +1100,6 @@ int CmdHF15CmdWrite(const char *Cmd) {
} else { } else {
PrintAndLog("timeout: no answer - data may be written anyway"); PrintAndLog("timeout: no answer - data may be written anyway");
} }
return 0; return 0;
} }
@ -1113,11 +1112,11 @@ static command_t CommandTable15Cmd[] = {
{"readmulti", CmdHF15CmdReadmulti, 0, "Reads multiple Blocks"}, {"readmulti", CmdHF15CmdReadmulti, 0, "Reads multiple Blocks"},
{"sysinfo", CmdHF15CmdSysinfo, 0, "Get Card Information"}, {"sysinfo", CmdHF15CmdSysinfo, 0, "Get Card Information"},
{"raw", CmdHF15CmdRaw, 0, "Send raw hex data to tag"}, {"raw", CmdHF15CmdRaw, 0, "Send raw hex data to tag"},
{"debug", CmdHF15CmdDebug, 0, "Turn debugging on/off"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
int CmdHF15Cmd(const char *Cmd) { int CmdHF15Cmd(const char *Cmd) {
clearCommandBuffer();
CmdsParse(CommandTable15Cmd, Cmd); CmdsParse(CommandTable15Cmd, Cmd);
return 0; return 0;
} }
@ -1126,4 +1125,3 @@ int CmdHF15CmdHelp(const char *Cmd) {
CmdsHelp(CommandTable15Cmd); CmdsHelp(CommandTable15Cmd);
return 0; return 0;
} }

View file

@ -13,14 +13,26 @@
int CmdHF15(const char *Cmd); int CmdHF15(const char *Cmd);
int CmdHF15Demod(const char *Cmd); extern int CmdHF15Demod(const char *Cmd);
int CmdHF15Read(const char *Cmd); extern int CmdHF15Read(const char *Cmd);
int HF15Reader(const char *Cmd, bool verbose); extern int CmdHF15Record(const char *Cmd);
int CmdHF15Reader(const char *Cmd); extern int HF15Reader(const char *Cmd, bool verbose);
int CmdHF15Sim(const char *Cmd); extern int CmdHF15Reader(const char *Cmd);
int CmdHF15Record(const char *Cmd); extern int CmdHF15Sim(const char *Cmd);
int CmdHF15Cmd(const char*Cmd); extern int CmdHF15Cmd(const char*Cmd);
int CmdHF15CmdHelp(const char*Cmd); extern int CmdHF15Afi(const char *Cmd);
int CmdHF15Help(const char*Cmd); extern int CmdHF15DumpMem(const char*Cmd);
extern int CmdHF15CmdDebug( const char *Cmd);
// cmd sub.
extern int CmdHF15CmdInquiry(const char *Cmd);
extern int CmdHF15CmdRaw(const char *cmd);
extern int CmdHF15CmdSysinfo(const char *Cmd);
extern int CmdHF15CmdReadmulti(const char *Cmd);
extern int CmdHF15CmdRead(const char *Cmd);
extern int CmdHF15CmdWrite(const char *Cmd);
extern int CmdHF15CmdHelp(const char*Cmd);
extern int CmdHF15Help(const char*Cmd);
#endif #endif